Index: src/report.c ================================================================== --- src/report.c +++ src/report.c @@ -27,10 +27,19 @@ #ifndef SQLITE_RECURSIVE # define SQLITE_RECURSIVE 33 #endif +/* Settings that can be used to control ticket reports */ +/* +** SETTING: ticket-search-empty-report-number width=10 default=0 +** +** If this setting has an integer value of N, then when the ticket +** search page query is blank, the report with rn=N is shown. +** If N is zero, then no report is shown. +*/ + /* ** WEBPAGE: reportlist ** ** Main menu for Tickets. */ @@ -982,12 +991,23 @@ ** corresponding to REPORTFMT.RN. If the tablist query parameter exists, ** then the output consists of lines of tab-separated fields instead of ** an HTML table. */ void rptview_page(void){ + rptview_page_content(0, 1, 1); +} + +/* +** Render a report. +*/ +void rptview_page_content( + int rn, /* Report number. If 0, retrieve from rn query parameter. */ + int pageWrap, /* If true, render full page; otherwise, just the report */ + int redirectMissing /* If true and report not found, go to reportlist */ +){ int count = 0; - int rn, rc; + int rc; char *zSql; char *zTitle; char *zOwner; char *zClrKey; int tabs; @@ -996,13 +1016,16 @@ char *zErr2 = 0; login_check_credentials(); if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; } tabs = P("tablist")!=0; + if ( rn==0 ) { + rn = atoi(PD("rn","0")); + } db_prepare(&q, "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d", - atoi(PD("rn","0"))); + rn); rc = db_step(&q); if( rc!=SQLITE_ROW ){ db_finalize(&q); db_prepare(&q, "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q", @@ -1009,11 +1032,13 @@ P("title")); rc = db_step(&q); } if( rc!=SQLITE_ROW ){ db_finalize(&q); - cgi_redirect("reportlist"); + if (redirectMissing) { + cgi_redirect("reportlist"); + } return; } zTitle = db_column_malloc(&q, 0); zSql = db_column_malloc(&q, 1); zOwner = db_column_malloc(&q, 2); @@ -1041,29 +1066,31 @@ struct GenerateHTML sState = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; const char *zQS = PD("QUERY_STRING",""); db_multi_exec("PRAGMA empty_result_callbacks=ON"); style_set_current_feature("report"); - /* style_finish_page() should provide escaping via %h formatting */ - if( zQS[0] ){ - style_submenu_element("Raw","%R/%s?tablist=1&%s",g.zPath,zQS); - style_submenu_element("Reports","%R/reportlist?%s",zQS); - } else { - style_submenu_element("Raw","%R/%s?tablist=1",g.zPath); - style_submenu_element("Reports","%R/reportlist"); - } - if( g.perm.Admin - || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ - style_submenu_element("Edit", "rptedit?rn=%d", rn); - } - if( g.perm.TktFmt ){ - style_submenu_element("SQL", "rptsql?rn=%d",rn); - } - if( g.perm.NewTkt ){ - style_submenu_element("New Ticket", "%R/tktnew"); - } - style_header("%s", zTitle); + if ( pageWrap ) { + /* style_finish_page() should provide escaping via %h formatting */ + if( zQS[0] ){ + style_submenu_element("Raw","%R/%s?tablist=1&%s",g.zPath,zQS); + style_submenu_element("Reports","%R/reportlist?%s",zQS); + } else { + style_submenu_element("Raw","%R/%s?tablist=1",g.zPath); + style_submenu_element("Reports","%R/reportlist"); + } + if( g.perm.Admin + || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ + style_submenu_element("Edit", "rptedit?rn=%d", rn); + } + if( g.perm.TktFmt ){ + style_submenu_element("SQL", "rptsql?rn=%d",rn); + } + if( g.perm.NewTkt ){ + style_submenu_element("New Ticket", "%R/tktnew"); + } + style_header("%s", zTitle); + } output_color_key(zClrKey, 1, "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); @