Fossil SCM

Allow the /rptview page to select a report using a GLOB pattern on its name and the title= query parameter.

drh 2015-04-30 19:52 trunk
Commit 6f212b5ffd39fcd9f157db5a4708acdd951292a7
1 file changed +14 -10
+14 -10
--- src/report.c
+++ src/report.c
@@ -1083,11 +1083,11 @@
10831083
** then the output consists of lines of tab-separated fields instead of
10841084
** an HTML table.
10851085
*/
10861086
void rptview_page(void){
10871087
int count = 0;
1088
- int rn;
1088
+ int rn, rc;
10891089
char *zSql;
10901090
char *zTitle;
10911091
char *zOwner;
10921092
char *zClrKey;
10931093
int tabs;
@@ -1095,28 +1095,32 @@
10951095
char *zErr1 = 0;
10961096
char *zErr2 = 0;
10971097
10981098
login_check_credentials();
10991099
if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
1100
- rn = atoi(PD("rn","0"));
1101
- if( rn==0 ){
1102
- cgi_redirect("reportlist");
1103
- return;
1104
- }
11051100
tabs = P("tablist")!=0;
1106
- /* view_add_functions(tabs); */
11071101
db_prepare(&q,
1108
- "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
1109
- if( db_step(&q)!=SQLITE_ROW ){
1110
- cgi_redirect("reportlist");
1102
+ "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
1103
+ atoi(PD("rn","0")));
1104
+ rc = db_step(&q);
1105
+ if( rc!=SQLITE_ROW ){
1106
+ db_finalize(&q);
1107
+ db_prepare(&q,
1108
+ "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q",
1109
+ P("title"));
1110
+ rc = db_step(&q);
1111
+ }
1112
+ if( rc!=SQLITE_ROW ){
11111113
db_finalize(&q);
1114
+ cgi_redirect("reportlist");
11121115
return;
11131116
}
11141117
zTitle = db_column_malloc(&q, 0);
11151118
zSql = db_column_malloc(&q, 1);
11161119
zOwner = db_column_malloc(&q, 2);
11171120
zClrKey = db_column_malloc(&q, 3);
1121
+ rn = db_column_int(&q,4);
11181122
db_finalize(&q);
11191123
11201124
if( P("order_by") ){
11211125
/*
11221126
** If the user wants to do a column sort, wrap the query into a sub
11231127
--- src/report.c
+++ src/report.c
@@ -1083,11 +1083,11 @@
1083 ** then the output consists of lines of tab-separated fields instead of
1084 ** an HTML table.
1085 */
1086 void rptview_page(void){
1087 int count = 0;
1088 int rn;
1089 char *zSql;
1090 char *zTitle;
1091 char *zOwner;
1092 char *zClrKey;
1093 int tabs;
@@ -1095,28 +1095,32 @@
1095 char *zErr1 = 0;
1096 char *zErr2 = 0;
1097
1098 login_check_credentials();
1099 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
1100 rn = atoi(PD("rn","0"));
1101 if( rn==0 ){
1102 cgi_redirect("reportlist");
1103 return;
1104 }
1105 tabs = P("tablist")!=0;
1106 /* view_add_functions(tabs); */
1107 db_prepare(&q,
1108 "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
1109 if( db_step(&q)!=SQLITE_ROW ){
1110 cgi_redirect("reportlist");
 
 
 
 
 
 
 
 
1111 db_finalize(&q);
 
1112 return;
1113 }
1114 zTitle = db_column_malloc(&q, 0);
1115 zSql = db_column_malloc(&q, 1);
1116 zOwner = db_column_malloc(&q, 2);
1117 zClrKey = db_column_malloc(&q, 3);
 
1118 db_finalize(&q);
1119
1120 if( P("order_by") ){
1121 /*
1122 ** If the user wants to do a column sort, wrap the query into a sub
1123
--- src/report.c
+++ src/report.c
@@ -1083,11 +1083,11 @@
1083 ** then the output consists of lines of tab-separated fields instead of
1084 ** an HTML table.
1085 */
1086 void rptview_page(void){
1087 int count = 0;
1088 int rn, rc;
1089 char *zSql;
1090 char *zTitle;
1091 char *zOwner;
1092 char *zClrKey;
1093 int tabs;
@@ -1095,28 +1095,32 @@
1095 char *zErr1 = 0;
1096 char *zErr2 = 0;
1097
1098 login_check_credentials();
1099 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
 
 
 
 
 
1100 tabs = P("tablist")!=0;
 
1101 db_prepare(&q,
1102 "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
1103 atoi(PD("rn","0")));
1104 rc = db_step(&q);
1105 if( rc!=SQLITE_ROW ){
1106 db_finalize(&q);
1107 db_prepare(&q,
1108 "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q",
1109 P("title"));
1110 rc = db_step(&q);
1111 }
1112 if( rc!=SQLITE_ROW ){
1113 db_finalize(&q);
1114 cgi_redirect("reportlist");
1115 return;
1116 }
1117 zTitle = db_column_malloc(&q, 0);
1118 zSql = db_column_malloc(&q, 1);
1119 zOwner = db_column_malloc(&q, 2);
1120 zClrKey = db_column_malloc(&q, 3);
1121 rn = db_column_int(&q,4);
1122 db_finalize(&q);
1123
1124 if( P("order_by") ){
1125 /*
1126 ** If the user wants to do a column sort, wrap the query into a sub
1127

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button