Fossil SCM
Allow the /rptview page to select a report using a GLOB pattern on its name and the title= query parameter.
Commit
6f212b5ffd39fcd9f157db5a4708acdd951292a7
Parent
54bd013176c59cb…
1 file changed
+14
-10
+14
-10
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -1083,11 +1083,11 @@ | ||
| 1083 | 1083 | ** then the output consists of lines of tab-separated fields instead of |
| 1084 | 1084 | ** an HTML table. |
| 1085 | 1085 | */ |
| 1086 | 1086 | void rptview_page(void){ |
| 1087 | 1087 | int count = 0; |
| 1088 | - int rn; | |
| 1088 | + int rn, rc; | |
| 1089 | 1089 | char *zSql; |
| 1090 | 1090 | char *zTitle; |
| 1091 | 1091 | char *zOwner; |
| 1092 | 1092 | char *zClrKey; |
| 1093 | 1093 | int tabs; |
| @@ -1095,28 +1095,32 @@ | ||
| 1095 | 1095 | char *zErr1 = 0; |
| 1096 | 1096 | char *zErr2 = 0; |
| 1097 | 1097 | |
| 1098 | 1098 | login_check_credentials(); |
| 1099 | 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 | 1100 | tabs = P("tablist")!=0; |
| 1106 | - /* view_add_functions(tabs); */ | |
| 1107 | 1101 | 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 ){ | |
| 1111 | 1113 | db_finalize(&q); |
| 1114 | + cgi_redirect("reportlist"); | |
| 1112 | 1115 | return; |
| 1113 | 1116 | } |
| 1114 | 1117 | zTitle = db_column_malloc(&q, 0); |
| 1115 | 1118 | zSql = db_column_malloc(&q, 1); |
| 1116 | 1119 | zOwner = db_column_malloc(&q, 2); |
| 1117 | 1120 | zClrKey = db_column_malloc(&q, 3); |
| 1121 | + rn = db_column_int(&q,4); | |
| 1118 | 1122 | db_finalize(&q); |
| 1119 | 1123 | |
| 1120 | 1124 | if( P("order_by") ){ |
| 1121 | 1125 | /* |
| 1122 | 1126 | ** If the user wants to do a column sort, wrap the query into a sub |
| 1123 | 1127 |
| --- 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 |