Fossil

Check-in [14253e9b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added a user configurable TH1 template for the ticket report list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:14253e9b3336a629243248dbb4c96da27705304e
User & Date: jeremy_c 2010-01-09 18:32:28
Context
2010-01-09
18:43
Call ticket_init() from the report view so users can have access to all the common ticket code check-in: 6d0b76d0 user: jeremy_c tags: trunk
18:32
Added a user configurable TH1 template for the ticket report list. check-in: 14253e9b user: jeremy_c tags: trunk
13:11
If a ticket query begins with an underscore then:
  1. Do not include a link to execute the query directly
  2. Do not show to those users that do not have ticket report access

This allows you to create ticket report queries that are for form submissions only, not direct access. check-in: 6069602a user: jeremy_c tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/report.c.

31
32
33
34
35
36
37


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

72
73

74
75
76

77
78
79
80

81
82
83

84
85
86

87
88
89

90
91

92
93
94
95
96
97
98
99

100





101
102
103
104
105
106
107
/* Forward references to static routines */
static void report_format_hints(void);

/*
** WEBPAGE: /reportlist
*/
void view_list(void){


  Stmt q;
  int rn = 0;
  int cnt = 0;

  login_check_credentials();
  if( !g.okRdTkt && !g.okNewTkt ){ login_needed(); return; }
  style_header("Ticket Main Menu");
  if( g.okNewTkt ){
    @ <p>Enter a new ticket:</p>
    @ <ol><li value="1"><a href="tktnew">New ticket</a></li></ol>
    @
    cnt++;
  }else if( db_exists(
      "SELECT 1 FROM user"
      " WHERE login='anonymous' AND cap GLOB '*n*'")
  ){
    @ <p><a href="login?anon=1&g=tktnew">Login as "anonymous"</a>
    @ to enter a new ticket.</p>

  }
  if( !g.okRdTkt ){
    @ <p>You are not authorized to view existing tickets.</p>
  }else{
    db_prepare(&q, "SELECT rn, title, owner FROM reportfmt ORDER BY title");
    @ <p>Choose a report format from the following list:</p>
    @ <ol>
    while( db_step(&q)==SQLITE_ROW ){
      const char *zTitle = db_column_text(&q, 1);
      const char *zOwner = db_column_text(&q, 2);
      if( zTitle[0] =='_' && !g.okTktFmt ){
        continue;
      }
      rn = db_column_int(&q, 0);
      cnt++;
      @ <li value="%d(cnt)">

      if( zTitle[0] == '_' ){
        @%h(zTitle)

      } else {
        @<a href="rptview?rn=%d(rn)"
        @        rel="nofollow">%h(zTitle)</a>        

      }
      @&nbsp;&nbsp;&nbsp;
      if( g.okWrite && zOwner && zOwner[0] ){
        @ (by <i>%h(zOwner)</i>)

      }
      if( g.okTktFmt ){
        @ [<a href="rptedit?rn=%d(rn)&amp;copy=1" rel="nofollow">copy</a>]

      }
      if( g.okAdmin || (g.okWrTkt && zOwner && strcmp(g.zLogin,zOwner)==0) ){
        @ [<a href="rptedit?rn=%d(rn)" rel="nofollow">edit</a>]

      }
      if( g.okTktFmt ){
        @ [<a href="rptsql?rn=%d(rn)" rel="nofollow">sql</a>]

      }
      @ </li>

    }
  }
  @ </ol>
  if( g.okTktFmt ){
    @ <p>Create a new ticket display format:</p>
    @ <ol>
    @ <li value="%d(cnt+1)"><a href="rptnew">New report format</a></li>
    @ </ol>

  }





  style_footer();
}

/*
** Remove whitespace from both ends of a string.
*/
char *trim_string(const char *zOrig){







>
>







|
|
|
|
<
<
<
<
<
<
<
>
|
<
<
<
|
<
<
|
|
|
|
|
|
|
|
<
>
|
<
>
|
<
<
>
|
|
|
<
>
|
|
<
>
|
|
<
>
|
|
<
>
|
<
>
|
|
<
<
<
<
<
<
>
|
>
>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50







51
52



53


54
55
56
57
58
59
60
61

62
63

64
65


66
67
68
69

70
71
72

73
74
75

76
77
78

79
80

81
82
83






84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Forward references to static routines */
static void report_format_hints(void);

/*
** WEBPAGE: /reportlist
*/
void view_list(void){
  const char *zScript;
  Blob ril;   /* Report Item List */
  Stmt q;
  int rn = 0;
  int cnt = 0;

  login_check_credentials();
  if( !g.okRdTkt && !g.okNewTkt ){ login_needed(); return; }
  style_header("Ticket Main Menu");
  if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST<br />\n", -1);
  zScript = ticket_reportlist_code();
  if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST_SCRIPT<br />\n", -1);
  







  blob_zero(&ril);




  db_prepare(&q, "SELECT rn, title, owner FROM reportfmt ORDER BY title");


  while( db_step(&q)==SQLITE_ROW ){
    const char *zTitle = db_column_text(&q, 1);
    const char *zOwner = db_column_text(&q, 2);
    if( zTitle[0] =='_' && !g.okTktFmt ){
      continue;
    }
    rn = db_column_int(&q, 0);
    cnt++;

    blob_appendf(&ril, "<li>");
    if( zTitle[0] == '_' ){

      blob_appendf(&ril, "%s", zTitle);
    } else {


      blob_appendf(&ril, "<a href=\"rptview?rn=%d\" rel=\"nofollow\">%h</a>", rn, zTitle);
    }
    blob_appendf(&ril, "&nbsp;&nbsp;&nbsp;");
    if( g.okWrite && zOwner && zOwner[0] ){

      blob_appendf(&ril, "(by <i>%h</i></i>) ", zOwner);
    }
    if( g.okTktFmt ){

      blob_appendf(&ril, "[<a href=\"rptedit?rn=%d&amp;copy=1\" rel=\"nofollow\">copy</a>] ", rn);
    }
    if( g.okAdmin || (g.okWrTkt && zOwner && strcmp(g.zLogin,zOwner)==0) ){

      blob_appendf(&ril, "[<a href=\"rptedit?rn=%d\" rel=\"nofollow\">edit</a>] ", rn);
    }
    if( g.okTktFmt ){

      blob_appendf(&ril, "[<a href=\"rptsql?rn=%d\" rel=\"nofollow\">sql</a>] ", rn);
    }

    blob_appendf(&ril, "</li>\n");
  }







  Th_Store("report_items", blob_str(&ril));
  
  Th_Render(zScript);
  
  blob_reset(&ril);
  if( g.thTrace ) Th_Trace("END_REPORTLIST<br />\n", -1);

  style_footer();
}

/*
** Remove whitespace from both ends of a string.
*/
char *trim_string(const char *zOrig){

Changes to src/tktsetup.c.

48
49
50
51
52
53
54


55
56
57
58
59
60
61
...
546
547
548
549
550
551
552


















































553
554
555
556
557
558
559
    "Common TH1 code run before all ticket processing.");
  setup_menu_entry("New Ticket Page", "tktsetup_newpage",
    "HTML with embedded TH1 code for the \"new ticket\" webpage.");
  setup_menu_entry("View Ticket Page", "tktsetup_viewpage",
    "HTML with embedded TH1 code for the \"view ticket\" webpage.");
  setup_menu_entry("Edit Ticket Page", "tktsetup_editpage",
    "HTML with embedded TH1 code for the \"edit ticket\" webpage.");


  setup_menu_entry("Report Template", "tktsetup_rpttplt",
    "The default ticket report format.");
  setup_menu_entry("Key Template", "tktsetup_keytplt",
    "The default color key for reports.");
  @ </table>
  style_footer();
}
................................................................................
  ;
  tktsetup_generic(
    "HTML For Editing Tickets",
    "ticket-editpage",
    zDefaultEdit,
    zDesc,
    0,


















































    0,
    40
  );
}

/*
** The default template ticket report format:







>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
    "Common TH1 code run before all ticket processing.");
  setup_menu_entry("New Ticket Page", "tktsetup_newpage",
    "HTML with embedded TH1 code for the \"new ticket\" webpage.");
  setup_menu_entry("View Ticket Page", "tktsetup_viewpage",
    "HTML with embedded TH1 code for the \"view ticket\" webpage.");
  setup_menu_entry("Edit Ticket Page", "tktsetup_editpage",
    "HTML with embedded TH1 code for the \"edit ticket\" webpage.");
  setup_menu_entry("Report List Page", "tktsetup_reportlist",
    "HTML with embedded TH1 code for the \"report list\" webpage.");
  setup_menu_entry("Report Template", "tktsetup_rpttplt",
    "The default ticket report format.");
  setup_menu_entry("Key Template", "tktsetup_keytplt",
    "The default color key for reports.");
  @ </table>
  style_footer();
}
................................................................................
  ;
  tktsetup_generic(
    "HTML For Editing Tickets",
    "ticket-editpage",
    zDefaultEdit,
    zDesc,
    0,
    0,
    40
  );
}

/*
** The default report list page
*/
static const char zDefaultReportList[] =
@ <th1>
@ if {[hascap n]} {
@   html "<p>Enter a new ticket:</p>"
@   html "<ul><li><a href='tktnew'>New ticket</a></li></ul>"
@ }
@ </th1>
@ 
@ <p>Choose a report format from the following list:</p>
@ <ol>
@ <th1>html $report_items</th1>
@ </ol>
@ 
@ <th1>
@ if {[hascap t]} {
@   html "<p>Create a new ticket display format:</p>"
@   html "<ul><li><a href='rptnew'>New report format</a></li></ul>"
@ }
@ </th1>
;

/*
** Return the code used to generate the report list
*/
const char *ticket_reportlist_code(void){
  return db_get("ticket-reportlist", (char*)zDefaultEdit);
}

/*
** WEBPAGE: tktsetup_reportlist
*/
void tktsetup_reportlist(void){
  static const char zDesc[] =
  @ <p>Enter HTML with embedded TH1 script that will render the "report list"
  @ page</p>
  ;
  tktsetup_generic(
    "HTML For Report List",
    "ticket-reportlist",
    zDefaultReportList,
    zDesc,
    0,
    0,
    40
  );
}

/*
** The default template ticket report format: