Fossil SCM
ticket show working(without UUID-filter)
Commit
f3f7f138154aef259d2aff0a4d866c3b2eafd64a
Parent
aab38ef02fe7ae1…
2 files changed
+1
-1
+140
-1
+1
-1
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -145,11 +145,11 @@ | ||
| 145 | 145 | ** This is the SQLite authorizer callback used to make sure that the |
| 146 | 146 | ** SQL statements entered by users do not try to do anything untoward. |
| 147 | 147 | ** If anything suspicious is tried, set *(char**)pError to an error |
| 148 | 148 | ** message obtained from malloc. |
| 149 | 149 | */ |
| 150 | -static int report_query_authorizer( | |
| 150 | +int report_query_authorizer( | |
| 151 | 151 | void *pError, |
| 152 | 152 | int code, |
| 153 | 153 | const char *zArg1, |
| 154 | 154 | const char *zArg2, |
| 155 | 155 | const char *zArg3, |
| 156 | 156 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -145,11 +145,11 @@ | |
| 145 | ** This is the SQLite authorizer callback used to make sure that the |
| 146 | ** SQL statements entered by users do not try to do anything untoward. |
| 147 | ** If anything suspicious is tried, set *(char**)pError to an error |
| 148 | ** message obtained from malloc. |
| 149 | */ |
| 150 | static int report_query_authorizer( |
| 151 | void *pError, |
| 152 | int code, |
| 153 | const char *zArg1, |
| 154 | const char *zArg2, |
| 155 | const char *zArg3, |
| 156 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -145,11 +145,11 @@ | |
| 145 | ** This is the SQLite authorizer callback used to make sure that the |
| 146 | ** SQL statements entered by users do not try to do anything untoward. |
| 147 | ** If anything suspicious is tried, set *(char**)pError to an error |
| 148 | ** message obtained from malloc. |
| 149 | */ |
| 150 | int report_query_authorizer( |
| 151 | void *pError, |
| 152 | int code, |
| 153 | const char *zArg1, |
| 154 | const char *zArg2, |
| 155 | const char *zArg3, |
| 156 |
+140
-1
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -346,21 +346,23 @@ | ||
| 346 | 346 | if( cnt==0 ){ |
| 347 | 347 | @ <hr /><h2>Attachments:</h2> |
| 348 | 348 | @ <ul> |
| 349 | 349 | } |
| 350 | 350 | cnt++; |
| 351 | + @ <li> | |
| 351 | 352 | if( g.okRead && g.okHistory ){ |
| 352 | - @ <li><a href="%s(g.zTop)/attachview?tkt=%s(zFullName)&file=%t(zFile)"> | |
| 353 | + @ <a href="%s(g.zTop)/attachview?tkt=%s(zFullName)&file=%t(zFile)"> | |
| 353 | 354 | @ %h(zFile)</a> |
| 354 | 355 | }else{ |
| 355 | 356 | @ %h(zFile) |
| 356 | 357 | } |
| 357 | 358 | @ added by %h(zUser) on |
| 358 | 359 | hyperlink_to_date(zDate, "."); |
| 359 | 360 | if( g.okWrTkt && g.okAttach ){ |
| 360 | 361 | @ [<a href="%s(g.zTop)/attachdelete?tkt=%s(zFullName)&file=%t(zFile)&from=%s(g.zTop)/tktview%%3fname=%s(zFullName)">delete</a>] |
| 361 | 362 | } |
| 363 | + @ </li> | |
| 362 | 364 | } |
| 363 | 365 | if( cnt ){ |
| 364 | 366 | @ </ul> |
| 365 | 367 | } |
| 366 | 368 | db_finalize(&q); |
| @@ -828,5 +830,142 @@ | ||
| 828 | 830 | } |
| 829 | 831 | blob_reset(&val); |
| 830 | 832 | } |
| 831 | 833 | @ </ol> |
| 832 | 834 | } |
| 835 | + | |
| 836 | +/* | |
| 837 | +** user defined separator used by ticket show command | |
| 838 | +*/ | |
| 839 | +static const char *zSep = 0; | |
| 840 | + | |
| 841 | +/* | |
| 842 | +** Output the text given in the argument. Convert tabs and newlines into | |
| 843 | +** spaces. | |
| 844 | +*/ | |
| 845 | +static void output_no_tabs(const char *z){ | |
| 846 | + while( z && z[0] ){ | |
| 847 | + int i, j; | |
| 848 | + for(i=0; z[i] && (!isspace(z[i]) || z[i]==' '); i++){} | |
| 849 | + if( i>0 ){ | |
| 850 | + printf("%.*s", i, z); | |
| 851 | + } | |
| 852 | + for(j=i; isspace(z[j]); j++){} | |
| 853 | + if( j>i ){ | |
| 854 | + printf("%*s", j-i, ""); | |
| 855 | + } | |
| 856 | + z += j; | |
| 857 | + } | |
| 858 | +} | |
| 859 | + | |
| 860 | +/* | |
| 861 | +** Output a row as a tab-separated line of text. | |
| 862 | +*/ | |
| 863 | +int output_separated( | |
| 864 | + void *pUser, /* Pointer to row-count integer */ | |
| 865 | + int nArg, /* Number of columns in this result row */ | |
| 866 | + char **azArg, /* Text of data in all columns */ | |
| 867 | + char **azName /* Names of the columns */ | |
| 868 | +){ | |
| 869 | + int *pCount = (int*)pUser; | |
| 870 | + int i; | |
| 871 | + | |
| 872 | + if( *pCount==0 ){ | |
| 873 | + for(i=0; i<nArg; i++){ | |
| 874 | + output_no_tabs(azName[i]); | |
| 875 | + printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); | |
| 876 | + } | |
| 877 | + } | |
| 878 | + ++*pCount; | |
| 879 | + for(i=0; i<nArg; i++){ | |
| 880 | + output_no_tabs(azArg[i]); | |
| 881 | + printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); | |
| 882 | + } | |
| 883 | + return 0; | |
| 884 | +} | |
| 885 | + | |
| 886 | +/* | |
| 887 | +** COMMAND: ticket | |
| 888 | +** Usage: %fossil ticket SUBCOMMAND ... | |
| 889 | +** | |
| 890 | +** Run various subcommands to control tickets | |
| 891 | +** | |
| 892 | +** %fossil ticket show REPORTNR ?TICKETUUID? ?-l|--limit LIMITCHAR? | |
| 893 | +** | |
| 894 | +** Run the the ticket report, identified by the report number | |
| 895 | +** used in the gui. The data is written as flat file on stdout, | |
| 896 | +** using "," as separator. The seperator "," can be changed using | |
| 897 | +** the -l or --limit option. | |
| 898 | +** If TICKETUUID is given on the commandline, only this ticket | |
| 899 | +** is shown, if the report delivers the uuid, otherwise the | |
| 900 | +** argument is ignored. | |
| 901 | +** | |
| 902 | +** %fossil ticket set FIELD VALUE ?FIELD VALUE ... ? TICKETUUID | |
| 903 | +** | |
| 904 | +** change ticket identified by TICKETUUID and set the value of | |
| 905 | +** field FIELD to VALUE. Valid field descriptions are: | |
| 906 | +** status, type, severity, priority, resolution, | |
| 907 | +** foundin, private_contact, resolution, title or comment | |
| 908 | +** Field names given above are the ones, defined in a standard | |
| 909 | +** fossil environment. If you have added, deleted columns, you | |
| 910 | +** change the all your configured columns. | |
| 911 | +** You can use more than one field/value pair on the commandline. | |
| 912 | +** | |
| 913 | +** %fossil ticket add FIELD VALUE ?FIELD VALUE ... ? | |
| 914 | +** | |
| 915 | +** like set, but create a new ticket with the given values. | |
| 916 | +** | |
| 917 | +*/ | |
| 918 | +void ticket_cmd(void){ | |
| 919 | + int n; | |
| 920 | + | |
| 921 | + db_find_and_open_repository(1); | |
| 922 | + | |
| 923 | + if( g.argc<3 ){ | |
| 924 | + usage("add|set|show"); | |
| 925 | + }else{ | |
| 926 | + n = strlen(g.argv[2]); | |
| 927 | + if( strncmp(g.argv[2],"show",n)==0 ){ | |
| 928 | + if( g.argc==3 ){ | |
| 929 | + usage("ticket show REPORTNR"); | |
| 930 | + }else{ | |
| 931 | + int rn; | |
| 932 | + Stmt q; | |
| 933 | + char *zSql; | |
| 934 | + char *zTitle; | |
| 935 | + char *zOwner; | |
| 936 | + char *zClrKey; | |
| 937 | + char *zErr1 = 0; | |
| 938 | + char *zErr2 = 0; | |
| 939 | + int count = 0; | |
| 940 | + | |
| 941 | + zSep = find_option("limit","l",1); | |
| 942 | +if( g.argc>4 ){ | |
| 943 | + fossil_fatal("show filter not implemented yet"); | |
| 944 | +} | |
| 945 | + | |
| 946 | + rn = atoi(g.argv[3]); | |
| 947 | + /* view_add_functions(tabs); */ | |
| 948 | + db_prepare(&q, | |
| 949 | + "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn); | |
| 950 | + if( db_step(&q)!=SQLITE_ROW ){ | |
| 951 | + db_finalize(&q); | |
| 952 | + fossil_fatal("unkown report format(%d)!",rn); | |
| 953 | + } | |
| 954 | + zTitle = db_column_malloc(&q, 0); | |
| 955 | + zSql = db_column_malloc(&q, 1); | |
| 956 | + zOwner = db_column_malloc(&q, 2); | |
| 957 | + zClrKey = db_column_malloc(&q, 3); | |
| 958 | + db_finalize(&q); | |
| 959 | + count = 0; | |
| 960 | + sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); | |
| 961 | + sqlite3_exec(g.db, zSql, output_separated, &count, &zErr2); | |
| 962 | + sqlite3_set_authorizer(g.db, 0, 0); | |
| 963 | + cgi_set_content_type("text/plain"); | |
| 964 | + } | |
| 965 | + }else if( strncmp(g.argv[2],"set",n)==0 ){ | |
| 966 | + fossil_fatal("set unimplemented"); | |
| 967 | + }else if( strncmp(g.argv[2],"add",n)==0 ){ | |
| 968 | + fossil_fatal("add unimplemented"); | |
| 969 | + } | |
| 970 | + } | |
| 971 | +} | |
| 833 | 972 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -346,21 +346,23 @@ | |
| 346 | if( cnt==0 ){ |
| 347 | @ <hr /><h2>Attachments:</h2> |
| 348 | @ <ul> |
| 349 | } |
| 350 | cnt++; |
| 351 | if( g.okRead && g.okHistory ){ |
| 352 | @ <li><a href="%s(g.zTop)/attachview?tkt=%s(zFullName)&file=%t(zFile)"> |
| 353 | @ %h(zFile)</a> |
| 354 | }else{ |
| 355 | @ %h(zFile) |
| 356 | } |
| 357 | @ added by %h(zUser) on |
| 358 | hyperlink_to_date(zDate, "."); |
| 359 | if( g.okWrTkt && g.okAttach ){ |
| 360 | @ [<a href="%s(g.zTop)/attachdelete?tkt=%s(zFullName)&file=%t(zFile)&from=%s(g.zTop)/tktview%%3fname=%s(zFullName)">delete</a>] |
| 361 | } |
| 362 | } |
| 363 | if( cnt ){ |
| 364 | @ </ul> |
| 365 | } |
| 366 | db_finalize(&q); |
| @@ -828,5 +830,142 @@ | |
| 828 | } |
| 829 | blob_reset(&val); |
| 830 | } |
| 831 | @ </ol> |
| 832 | } |
| 833 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -346,21 +346,23 @@ | |
| 346 | if( cnt==0 ){ |
| 347 | @ <hr /><h2>Attachments:</h2> |
| 348 | @ <ul> |
| 349 | } |
| 350 | cnt++; |
| 351 | @ <li> |
| 352 | if( g.okRead && g.okHistory ){ |
| 353 | @ <a href="%s(g.zTop)/attachview?tkt=%s(zFullName)&file=%t(zFile)"> |
| 354 | @ %h(zFile)</a> |
| 355 | }else{ |
| 356 | @ %h(zFile) |
| 357 | } |
| 358 | @ added by %h(zUser) on |
| 359 | hyperlink_to_date(zDate, "."); |
| 360 | if( g.okWrTkt && g.okAttach ){ |
| 361 | @ [<a href="%s(g.zTop)/attachdelete?tkt=%s(zFullName)&file=%t(zFile)&from=%s(g.zTop)/tktview%%3fname=%s(zFullName)">delete</a>] |
| 362 | } |
| 363 | @ </li> |
| 364 | } |
| 365 | if( cnt ){ |
| 366 | @ </ul> |
| 367 | } |
| 368 | db_finalize(&q); |
| @@ -828,5 +830,142 @@ | |
| 830 | } |
| 831 | blob_reset(&val); |
| 832 | } |
| 833 | @ </ol> |
| 834 | } |
| 835 | |
| 836 | /* |
| 837 | ** user defined separator used by ticket show command |
| 838 | */ |
| 839 | static const char *zSep = 0; |
| 840 | |
| 841 | /* |
| 842 | ** Output the text given in the argument. Convert tabs and newlines into |
| 843 | ** spaces. |
| 844 | */ |
| 845 | static void output_no_tabs(const char *z){ |
| 846 | while( z && z[0] ){ |
| 847 | int i, j; |
| 848 | for(i=0; z[i] && (!isspace(z[i]) || z[i]==' '); i++){} |
| 849 | if( i>0 ){ |
| 850 | printf("%.*s", i, z); |
| 851 | } |
| 852 | for(j=i; isspace(z[j]); j++){} |
| 853 | if( j>i ){ |
| 854 | printf("%*s", j-i, ""); |
| 855 | } |
| 856 | z += j; |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | /* |
| 861 | ** Output a row as a tab-separated line of text. |
| 862 | */ |
| 863 | int output_separated( |
| 864 | void *pUser, /* Pointer to row-count integer */ |
| 865 | int nArg, /* Number of columns in this result row */ |
| 866 | char **azArg, /* Text of data in all columns */ |
| 867 | char **azName /* Names of the columns */ |
| 868 | ){ |
| 869 | int *pCount = (int*)pUser; |
| 870 | int i; |
| 871 | |
| 872 | if( *pCount==0 ){ |
| 873 | for(i=0; i<nArg; i++){ |
| 874 | output_no_tabs(azName[i]); |
| 875 | printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); |
| 876 | } |
| 877 | } |
| 878 | ++*pCount; |
| 879 | for(i=0; i<nArg; i++){ |
| 880 | output_no_tabs(azArg[i]); |
| 881 | printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); |
| 882 | } |
| 883 | return 0; |
| 884 | } |
| 885 | |
| 886 | /* |
| 887 | ** COMMAND: ticket |
| 888 | ** Usage: %fossil ticket SUBCOMMAND ... |
| 889 | ** |
| 890 | ** Run various subcommands to control tickets |
| 891 | ** |
| 892 | ** %fossil ticket show REPORTNR ?TICKETUUID? ?-l|--limit LIMITCHAR? |
| 893 | ** |
| 894 | ** Run the the ticket report, identified by the report number |
| 895 | ** used in the gui. The data is written as flat file on stdout, |
| 896 | ** using "," as separator. The seperator "," can be changed using |
| 897 | ** the -l or --limit option. |
| 898 | ** If TICKETUUID is given on the commandline, only this ticket |
| 899 | ** is shown, if the report delivers the uuid, otherwise the |
| 900 | ** argument is ignored. |
| 901 | ** |
| 902 | ** %fossil ticket set FIELD VALUE ?FIELD VALUE ... ? TICKETUUID |
| 903 | ** |
| 904 | ** change ticket identified by TICKETUUID and set the value of |
| 905 | ** field FIELD to VALUE. Valid field descriptions are: |
| 906 | ** status, type, severity, priority, resolution, |
| 907 | ** foundin, private_contact, resolution, title or comment |
| 908 | ** Field names given above are the ones, defined in a standard |
| 909 | ** fossil environment. If you have added, deleted columns, you |
| 910 | ** change the all your configured columns. |
| 911 | ** You can use more than one field/value pair on the commandline. |
| 912 | ** |
| 913 | ** %fossil ticket add FIELD VALUE ?FIELD VALUE ... ? |
| 914 | ** |
| 915 | ** like set, but create a new ticket with the given values. |
| 916 | ** |
| 917 | */ |
| 918 | void ticket_cmd(void){ |
| 919 | int n; |
| 920 | |
| 921 | db_find_and_open_repository(1); |
| 922 | |
| 923 | if( g.argc<3 ){ |
| 924 | usage("add|set|show"); |
| 925 | }else{ |
| 926 | n = strlen(g.argv[2]); |
| 927 | if( strncmp(g.argv[2],"show",n)==0 ){ |
| 928 | if( g.argc==3 ){ |
| 929 | usage("ticket show REPORTNR"); |
| 930 | }else{ |
| 931 | int rn; |
| 932 | Stmt q; |
| 933 | char *zSql; |
| 934 | char *zTitle; |
| 935 | char *zOwner; |
| 936 | char *zClrKey; |
| 937 | char *zErr1 = 0; |
| 938 | char *zErr2 = 0; |
| 939 | int count = 0; |
| 940 | |
| 941 | zSep = find_option("limit","l",1); |
| 942 | if( g.argc>4 ){ |
| 943 | fossil_fatal("show filter not implemented yet"); |
| 944 | } |
| 945 | |
| 946 | rn = atoi(g.argv[3]); |
| 947 | /* view_add_functions(tabs); */ |
| 948 | db_prepare(&q, |
| 949 | "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn); |
| 950 | if( db_step(&q)!=SQLITE_ROW ){ |
| 951 | db_finalize(&q); |
| 952 | fossil_fatal("unkown report format(%d)!",rn); |
| 953 | } |
| 954 | zTitle = db_column_malloc(&q, 0); |
| 955 | zSql = db_column_malloc(&q, 1); |
| 956 | zOwner = db_column_malloc(&q, 2); |
| 957 | zClrKey = db_column_malloc(&q, 3); |
| 958 | db_finalize(&q); |
| 959 | count = 0; |
| 960 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); |
| 961 | sqlite3_exec(g.db, zSql, output_separated, &count, &zErr2); |
| 962 | sqlite3_set_authorizer(g.db, 0, 0); |
| 963 | cgi_set_content_type("text/plain"); |
| 964 | } |
| 965 | }else if( strncmp(g.argv[2],"set",n)==0 ){ |
| 966 | fossil_fatal("set unimplemented"); |
| 967 | }else if( strncmp(g.argv[2],"add",n)==0 ){ |
| 968 | fossil_fatal("add unimplemented"); |
| 969 | } |
| 970 | } |
| 971 | } |
| 972 |