Fossil SCM

After deleting a newly proposed ticket or wiki page via moderation, redirect to the list of pending moderation requests. Changes to permit easier debugging of the moderation subsystem. Fix some TH1 script errors that could occur when attempting to view non-existent tickets.

mistachkin 2014-09-18 23:22 trunk merge
Commit 636c3346d0de6f1f521727b21c6c65eedc60daea
+2 -2
--- src/attach.c
+++ src/attach.c
@@ -288,12 +288,12 @@
288288
if( pManifest ){
289289
blob_compress(&content, &content);
290290
addCompress = 1;
291291
}
292292
needModerator =
293
- (zTkt!=0 && g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1) ||
294
- (zPage!=0 && g.perm.ModWiki==0 && db_get_boolean("modreq-wiki",0)==1);
293
+ (zTkt!=0 && ticket_need_moderation(0)) ||
294
+ (zPage!=0 && wiki_need_moderation(0));
295295
rid = content_put_ex(&content, 0, 0, 0, needModerator);
296296
zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
297297
blob_zero(&manifest);
298298
for(i=n=0; zName[i]; i++){
299299
if( zName[i]=='/' || zName[i]=='\\' ) n = i;
300300
--- src/attach.c
+++ src/attach.c
@@ -288,12 +288,12 @@
288 if( pManifest ){
289 blob_compress(&content, &content);
290 addCompress = 1;
291 }
292 needModerator =
293 (zTkt!=0 && g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1) ||
294 (zPage!=0 && g.perm.ModWiki==0 && db_get_boolean("modreq-wiki",0)==1);
295 rid = content_put_ex(&content, 0, 0, 0, needModerator);
296 zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
297 blob_zero(&manifest);
298 for(i=n=0; zName[i]; i++){
299 if( zName[i]=='/' || zName[i]=='\\' ) n = i;
300
--- src/attach.c
+++ src/attach.c
@@ -288,12 +288,12 @@
288 if( pManifest ){
289 blob_compress(&content, &content);
290 addCompress = 1;
291 }
292 needModerator =
293 (zTkt!=0 && ticket_need_moderation(0)) ||
294 (zPage!=0 && wiki_need_moderation(0));
295 rid = content_put_ex(&content, 0, 0, 0, needModerator);
296 zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
297 blob_zero(&manifest);
298 for(i=n=0; zName[i]; i++){
299 if( zName[i]=='/' || zName[i]=='\\' ) n = i;
300
+24 -4
--- src/info.c
+++ src/info.c
@@ -764,12 +764,22 @@
764764
return;
765765
}
766766
if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
767767
if( strcmp(zModAction,"delete")==0 ){
768768
moderation_disapprove(rid);
769
- cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
770
- /*NOTREACHED*/
769
+ /*
770
+ ** Next, check if the wiki page still exists; if not, we cannot
771
+ ** redirect to it.
772
+ */
773
+ if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
774
+ " WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){
775
+ cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
776
+ /*NOTREACHED*/
777
+ }else{
778
+ cgi_redirectf("%R/modreq");
779
+ /*NOTREACHED*/
780
+ }
771781
}
772782
if( strcmp(zModAction,"approve")==0 ){
773783
moderation_approve(rid);
774784
}
775785
}
@@ -1889,12 +1899,22 @@
18891899
zDate = db_text(0, "SELECT datetime(%.12f)", pTktChng->rDate);
18901900
memcpy(zTktName, pTktChng->zTicketUuid, UUID_SIZE+1);
18911901
if( g.perm.ModTkt && (zModAction = P("modaction"))!=0 ){
18921902
if( strcmp(zModAction,"delete")==0 ){
18931903
moderation_disapprove(rid);
1894
- cgi_redirectf("%R/tktview/%s", zTktName);
1895
- /*NOTREACHED*/
1904
+ /*
1905
+ ** Next, check if the ticket still exists; if not, we cannot
1906
+ ** redirect to it.
1907
+ */
1908
+ if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'",
1909
+ zTktName) ){
1910
+ cgi_redirectf("%R/tktview/%s", zTktName);
1911
+ /*NOTREACHED*/
1912
+ }else{
1913
+ cgi_redirectf("%R/modreq");
1914
+ /*NOTREACHED*/
1915
+ }
18961916
}
18971917
if( strcmp(zModAction,"approve")==0 ){
18981918
moderation_approve(rid);
18991919
}
19001920
}
19011921
--- src/info.c
+++ src/info.c
@@ -764,12 +764,22 @@
764 return;
765 }
766 if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
767 if( strcmp(zModAction,"delete")==0 ){
768 moderation_disapprove(rid);
769 cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
770 /*NOTREACHED*/
 
 
 
 
 
 
 
 
 
 
771 }
772 if( strcmp(zModAction,"approve")==0 ){
773 moderation_approve(rid);
774 }
775 }
@@ -1889,12 +1899,22 @@
1889 zDate = db_text(0, "SELECT datetime(%.12f)", pTktChng->rDate);
1890 memcpy(zTktName, pTktChng->zTicketUuid, UUID_SIZE+1);
1891 if( g.perm.ModTkt && (zModAction = P("modaction"))!=0 ){
1892 if( strcmp(zModAction,"delete")==0 ){
1893 moderation_disapprove(rid);
1894 cgi_redirectf("%R/tktview/%s", zTktName);
1895 /*NOTREACHED*/
 
 
 
 
 
 
 
 
 
 
1896 }
1897 if( strcmp(zModAction,"approve")==0 ){
1898 moderation_approve(rid);
1899 }
1900 }
1901
--- src/info.c
+++ src/info.c
@@ -764,12 +764,22 @@
764 return;
765 }
766 if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
767 if( strcmp(zModAction,"delete")==0 ){
768 moderation_disapprove(rid);
769 /*
770 ** Next, check if the wiki page still exists; if not, we cannot
771 ** redirect to it.
772 */
773 if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
774 " WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){
775 cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
776 /*NOTREACHED*/
777 }else{
778 cgi_redirectf("%R/modreq");
779 /*NOTREACHED*/
780 }
781 }
782 if( strcmp(zModAction,"approve")==0 ){
783 moderation_approve(rid);
784 }
785 }
@@ -1889,12 +1899,22 @@
1899 zDate = db_text(0, "SELECT datetime(%.12f)", pTktChng->rDate);
1900 memcpy(zTktName, pTktChng->zTicketUuid, UUID_SIZE+1);
1901 if( g.perm.ModTkt && (zModAction = P("modaction"))!=0 ){
1902 if( strcmp(zModAction,"delete")==0 ){
1903 moderation_disapprove(rid);
1904 /*
1905 ** Next, check if the ticket still exists; if not, we cannot
1906 ** redirect to it.
1907 */
1908 if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'",
1909 zTktName) ){
1910 cgi_redirectf("%R/tktview/%s", zTktName);
1911 /*NOTREACHED*/
1912 }else{
1913 cgi_redirectf("%R/modreq");
1914 /*NOTREACHED*/
1915 }
1916 }
1917 if( strcmp(zModAction,"approve")==0 ){
1918 moderation_approve(rid);
1919 }
1920 }
1921
+1 -1
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -375,11 +375,11 @@
375375
blob_append(&content, cson_string_cstr(jstr),contentLen);
376376
}
377377
378378
zMimeType = json_find_option_cstr("mimetype","mimetype","M");
379379
380
- wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType);
380
+ wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType, 0);
381381
blob_reset(&content);
382382
/*
383383
Our return value here has a race condition: if this operation
384384
is called concurrently for the same wiki page via two requests,
385385
payV could reflect the results of the other save operation.
386386
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -375,11 +375,11 @@
375 blob_append(&content, cson_string_cstr(jstr),contentLen);
376 }
377
378 zMimeType = json_find_option_cstr("mimetype","mimetype","M");
379
380 wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType);
381 blob_reset(&content);
382 /*
383 Our return value here has a race condition: if this operation
384 is called concurrently for the same wiki page via two requests,
385 payV could reflect the results of the other save operation.
386
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -375,11 +375,11 @@
375 blob_append(&content, cson_string_cstr(jstr),contentLen);
376 }
377
378 zMimeType = json_find_option_cstr("mimetype","mimetype","M");
379
380 wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType, 0);
381 blob_reset(&content);
382 /*
383 Our return value here has a race condition: if this operation
384 is called concurrently for the same wiki page via two requests,
385 payV could reflect the results of the other save operation.
386
+29 -3
--- src/tkt.c
+++ src/tkt.c
@@ -273,10 +273,33 @@
273273
blob_reset(&sql2);
274274
blob_reset(&sql3);
275275
fossil_free(aUsed);
276276
return tktid;
277277
}
278
+
279
+/*
280
+** Returns non-zero if moderation is required for ticket changes and ticket
281
+** attachments.
282
+*/
283
+int ticket_need_moderation(
284
+ int localUser /* Are we being called for a local interactive user? */
285
+){
286
+ /*
287
+ ** If the FOSSIL_FORCE_TICKET_MODERATION variable is set, *ALL* changes for
288
+ ** tickets will be required to go through moderation (even those performed
289
+ ** by the local interactive user via the command line). This can be useful
290
+ ** for local (or remote) testing of the moderation subsystem and its impact
291
+ ** on the contents and status of tickets.
292
+ */
293
+ if( fossil_getenv("FOSSIL_FORCE_TICKET_MODERATION")!=0 ){
294
+ return 1;
295
+ }
296
+ if( localUser ){
297
+ return 0;
298
+ }
299
+ return g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1;
300
+}
278301
279302
/*
280303
** Rebuild an entire entry in the TICKET table
281304
*/
282305
void ticket_rebuild_entry(const char *zTktUuid){
@@ -567,10 +590,11 @@
567590
char *zDate;
568591
const char *zUuid;
569592
int i;
570593
int nJ = 0;
571594
Blob tktchng, cksum;
595
+ int needMod;
572596
573597
login_verify_csrf_secret();
574598
if( !captcha_is_correct() ){
575599
@ <p class="generalError">Error: Incorrect security code.</p>
576600
return TH_OK;
@@ -622,25 +646,27 @@
622646
blob_appendf(&tktchng, "Z %b\n", &cksum);
623647
if( nJ==0 ){
624648
blob_reset(&tktchng);
625649
return TH_OK;
626650
}
651
+ needMod = ticket_need_moderation(0);
627652
if( g.zPath[0]=='d' ){
653
+ const char *zNeedMod = needMod ? "required" : "skipped";
628654
/* If called from /debug_tktnew or /debug_tktedit... */
629655
@ <font color="blue">
630656
@ <p>Ticket artifact that would have been submitted:</p>
631657
@ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
658
+ @ <blockquote><pre>Moderation would be %h(zNeedMod).</pre></blockquote>
632659
@ <hr /></font>
633660
return TH_OK;
634661
}else{
635662
if( g.thTrace ){
636663
Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
637664
"}<br />\n",
638665
blob_str(&tktchng));
639666
}
640
- ticket_put(&tktchng, zUuid,
641
- (g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
667
+ ticket_put(&tktchng, zUuid, needMod);
642668
}
643669
return ticket_change(zUuid);
644670
}
645671
646672
@@ -1347,14 +1373,14 @@
13471373
}
13481374
blob_appendf(&tktchng, "K %s\n", zTktUuid);
13491375
blob_appendf(&tktchng, "U %F\n", zUser);
13501376
md5sum_blob(&tktchng, &cksum);
13511377
blob_appendf(&tktchng, "Z %b\n", &cksum);
1352
- if( ticket_put(&tktchng, zTktUuid, 0) ){
1378
+ if( ticket_put(&tktchng, zTktUuid, ticket_need_moderation(1)) ){
13531379
fossil_fatal("%s\n", g.zErrMsg);
13541380
}else{
13551381
fossil_print("ticket %s succeeded for %s\n",
13561382
(eCmd==set?"set":"add"),zTktUuid);
13571383
}
13581384
}
13591385
}
13601386
}
13611387
--- src/tkt.c
+++ src/tkt.c
@@ -273,10 +273,33 @@
273 blob_reset(&sql2);
274 blob_reset(&sql3);
275 fossil_free(aUsed);
276 return tktid;
277 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
279 /*
280 ** Rebuild an entire entry in the TICKET table
281 */
282 void ticket_rebuild_entry(const char *zTktUuid){
@@ -567,10 +590,11 @@
567 char *zDate;
568 const char *zUuid;
569 int i;
570 int nJ = 0;
571 Blob tktchng, cksum;
 
572
573 login_verify_csrf_secret();
574 if( !captcha_is_correct() ){
575 @ <p class="generalError">Error: Incorrect security code.</p>
576 return TH_OK;
@@ -622,25 +646,27 @@
622 blob_appendf(&tktchng, "Z %b\n", &cksum);
623 if( nJ==0 ){
624 blob_reset(&tktchng);
625 return TH_OK;
626 }
 
627 if( g.zPath[0]=='d' ){
 
628 /* If called from /debug_tktnew or /debug_tktedit... */
629 @ <font color="blue">
630 @ <p>Ticket artifact that would have been submitted:</p>
631 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
 
632 @ <hr /></font>
633 return TH_OK;
634 }else{
635 if( g.thTrace ){
636 Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
637 "}<br />\n",
638 blob_str(&tktchng));
639 }
640 ticket_put(&tktchng, zUuid,
641 (g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
642 }
643 return ticket_change(zUuid);
644 }
645
646
@@ -1347,14 +1373,14 @@
1347 }
1348 blob_appendf(&tktchng, "K %s\n", zTktUuid);
1349 blob_appendf(&tktchng, "U %F\n", zUser);
1350 md5sum_blob(&tktchng, &cksum);
1351 blob_appendf(&tktchng, "Z %b\n", &cksum);
1352 if( ticket_put(&tktchng, zTktUuid, 0) ){
1353 fossil_fatal("%s\n", g.zErrMsg);
1354 }else{
1355 fossil_print("ticket %s succeeded for %s\n",
1356 (eCmd==set?"set":"add"),zTktUuid);
1357 }
1358 }
1359 }
1360 }
1361
--- src/tkt.c
+++ src/tkt.c
@@ -273,10 +273,33 @@
273 blob_reset(&sql2);
274 blob_reset(&sql3);
275 fossil_free(aUsed);
276 return tktid;
277 }
278
279 /*
280 ** Returns non-zero if moderation is required for ticket changes and ticket
281 ** attachments.
282 */
283 int ticket_need_moderation(
284 int localUser /* Are we being called for a local interactive user? */
285 ){
286 /*
287 ** If the FOSSIL_FORCE_TICKET_MODERATION variable is set, *ALL* changes for
288 ** tickets will be required to go through moderation (even those performed
289 ** by the local interactive user via the command line). This can be useful
290 ** for local (or remote) testing of the moderation subsystem and its impact
291 ** on the contents and status of tickets.
292 */
293 if( fossil_getenv("FOSSIL_FORCE_TICKET_MODERATION")!=0 ){
294 return 1;
295 }
296 if( localUser ){
297 return 0;
298 }
299 return g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1;
300 }
301
302 /*
303 ** Rebuild an entire entry in the TICKET table
304 */
305 void ticket_rebuild_entry(const char *zTktUuid){
@@ -567,10 +590,11 @@
590 char *zDate;
591 const char *zUuid;
592 int i;
593 int nJ = 0;
594 Blob tktchng, cksum;
595 int needMod;
596
597 login_verify_csrf_secret();
598 if( !captcha_is_correct() ){
599 @ <p class="generalError">Error: Incorrect security code.</p>
600 return TH_OK;
@@ -622,25 +646,27 @@
646 blob_appendf(&tktchng, "Z %b\n", &cksum);
647 if( nJ==0 ){
648 blob_reset(&tktchng);
649 return TH_OK;
650 }
651 needMod = ticket_need_moderation(0);
652 if( g.zPath[0]=='d' ){
653 const char *zNeedMod = needMod ? "required" : "skipped";
654 /* If called from /debug_tktnew or /debug_tktedit... */
655 @ <font color="blue">
656 @ <p>Ticket artifact that would have been submitted:</p>
657 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
658 @ <blockquote><pre>Moderation would be %h(zNeedMod).</pre></blockquote>
659 @ <hr /></font>
660 return TH_OK;
661 }else{
662 if( g.thTrace ){
663 Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
664 "}<br />\n",
665 blob_str(&tktchng));
666 }
667 ticket_put(&tktchng, zUuid, needMod);
 
668 }
669 return ticket_change(zUuid);
670 }
671
672
@@ -1347,14 +1373,14 @@
1373 }
1374 blob_appendf(&tktchng, "K %s\n", zTktUuid);
1375 blob_appendf(&tktchng, "U %F\n", zUser);
1376 md5sum_blob(&tktchng, &cksum);
1377 blob_appendf(&tktchng, "Z %b\n", &cksum);
1378 if( ticket_put(&tktchng, zTktUuid, ticket_need_moderation(1)) ){
1379 fossil_fatal("%s\n", g.zErrMsg);
1380 }else{
1381 fossil_print("ticket %s succeeded for %s\n",
1382 (eCmd==set?"set":"add"),zTktUuid);
1383 }
1384 }
1385 }
1386 }
1387
+30 -15
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -435,15 +435,24 @@
435435
436436
static const char zDefaultView[] =
437437
@ <table cellpadding="5">
438438
@ <tr><td class="tktDspLabel">Ticket&nbsp;UUID:</td>
439439
@ <th1>
440
-@ if {[hascap s]} {
441
-@ html "<td class='tktDspValue' colspan='3'>$tkt_uuid "
442
-@ html "($tkt_id)</td></tr>\n"
440
+@ if {[info exists tkt_uuid]} {
441
+@ if {[hascap s]} {
442
+@ html "<td class='tktDspValue' colspan='3'>$tkt_uuid "
443
+@ html "($tkt_id)</td></tr>\n"
444
+@ } else {
445
+@ html "<td class='tktDspValue' colspan='3'>$tkt_uuid</td></tr>\n"
446
+@ }
443447
@ } else {
444
-@ html "<td class='tktDspValue' colspan='3'>$tkt_uuid</td></tr>\n"
448
+@ if {[hascap s]} {
449
+@ html "<td class='tktDspValue' colspan='3'>Deleted "
450
+@ html "(0)</td></tr>\n"
451
+@ } else {
452
+@ html "<td class='tktDspValue' colspan='3'>Deleted</td></tr>\n"
453
+@ }
445454
@ }
446455
@ </th1>
447456
@ <tr><td class="tktDspLabel">Title:</td>
448457
@ <td class="tktDspValue" colspan="3">
449458
@ $<title>
@@ -465,11 +474,15 @@
465474
@ </td>
466475
@ <td class="tktDspLabel">Resolution:</td><td class="tktDspValue">
467476
@ $<resolution>
468477
@ </td></tr>
469478
@ <tr><td class="tktDspLabel">Last&nbsp;Modified:</td><td class="tktDspValue">
470
-@ $<tkt_datetime>
479
+@ <th1>
480
+@ if {[info exists tkt_datetime]} {
481
+@ html $tkt_datetime
482
+@ }
483
+@ </th1>
471484
@ </td>
472485
@ <th1>enable_output [hascap e]</th1>
473486
@ <td class="tktDspLabel">Contact:</td><td class="tktDspValue">
474487
@ $<private_contact>
475488
@ </td>
@@ -479,20 +492,22 @@
479492
@ <td colspan="3" valign="top" class="tktDspValue">
480493
@ $<foundin>
481494
@ </td></tr>
482495
@
483496
@ <th1>
484
-@ if {[info exists comment] && [string length $comment]>10} {
485
-@ html {
486
-@ <tr><td class="tktDspLabel">Description:</td></tr>
487
-@ <tr><td colspan="5" class="tktDspValue">
488
-@ }
489
-@ if {[info exists plaintext]} {
490
-@ set r [randhex]
491
-@ wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
492
-@ } else {
493
-@ wiki $comment
497
+@ if {[info exists comment]} {
498
+@ if {[string length $comment]>10} {
499
+@ html {
500
+@ <tr><td class="tktDspLabel">Description:</td></tr>
501
+@ <tr><td colspan="5" class="tktDspValue">
502
+@ }
503
+@ if {[info exists plaintext]} {
504
+@ set r [randhex]
505
+@ wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
506
+@ } else {
507
+@ wiki $comment
508
+@ }
494509
@ }
495510
@ }
496511
@ set seenRow 0
497512
@ set alwaysPlaintext [info exists plaintext]
498513
@ query {SELECT datetime(tkt_mtime) AS xdate, login AS xlogin,
499514
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -435,15 +435,24 @@
435
436 static const char zDefaultView[] =
437 @ <table cellpadding="5">
438 @ <tr><td class="tktDspLabel">Ticket&nbsp;UUID:</td>
439 @ <th1>
440 @ if {[hascap s]} {
441 @ html "<td class='tktDspValue' colspan='3'>$tkt_uuid "
442 @ html "($tkt_id)</td></tr>\n"
 
 
 
 
443 @ } else {
444 @ html "<td class='tktDspValue' colspan='3'>$tkt_uuid</td></tr>\n"
 
 
 
 
 
445 @ }
446 @ </th1>
447 @ <tr><td class="tktDspLabel">Title:</td>
448 @ <td class="tktDspValue" colspan="3">
449 @ $<title>
@@ -465,11 +474,15 @@
465 @ </td>
466 @ <td class="tktDspLabel">Resolution:</td><td class="tktDspValue">
467 @ $<resolution>
468 @ </td></tr>
469 @ <tr><td class="tktDspLabel">Last&nbsp;Modified:</td><td class="tktDspValue">
470 @ $<tkt_datetime>
 
 
 
 
471 @ </td>
472 @ <th1>enable_output [hascap e]</th1>
473 @ <td class="tktDspLabel">Contact:</td><td class="tktDspValue">
474 @ $<private_contact>
475 @ </td>
@@ -479,20 +492,22 @@
479 @ <td colspan="3" valign="top" class="tktDspValue">
480 @ $<foundin>
481 @ </td></tr>
482 @
483 @ <th1>
484 @ if {[info exists comment] && [string length $comment]>10} {
485 @ html {
486 @ <tr><td class="tktDspLabel">Description:</td></tr>
487 @ <tr><td colspan="5" class="tktDspValue">
488 @ }
489 @ if {[info exists plaintext]} {
490 @ set r [randhex]
491 @ wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
492 @ } else {
493 @ wiki $comment
 
 
494 @ }
495 @ }
496 @ set seenRow 0
497 @ set alwaysPlaintext [info exists plaintext]
498 @ query {SELECT datetime(tkt_mtime) AS xdate, login AS xlogin,
499
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -435,15 +435,24 @@
435
436 static const char zDefaultView[] =
437 @ <table cellpadding="5">
438 @ <tr><td class="tktDspLabel">Ticket&nbsp;UUID:</td>
439 @ <th1>
440 @ if {[info exists tkt_uuid]} {
441 @ if {[hascap s]} {
442 @ html "<td class='tktDspValue' colspan='3'>$tkt_uuid "
443 @ html "($tkt_id)</td></tr>\n"
444 @ } else {
445 @ html "<td class='tktDspValue' colspan='3'>$tkt_uuid</td></tr>\n"
446 @ }
447 @ } else {
448 @ if {[hascap s]} {
449 @ html "<td class='tktDspValue' colspan='3'>Deleted "
450 @ html "(0)</td></tr>\n"
451 @ } else {
452 @ html "<td class='tktDspValue' colspan='3'>Deleted</td></tr>\n"
453 @ }
454 @ }
455 @ </th1>
456 @ <tr><td class="tktDspLabel">Title:</td>
457 @ <td class="tktDspValue" colspan="3">
458 @ $<title>
@@ -465,11 +474,15 @@
474 @ </td>
475 @ <td class="tktDspLabel">Resolution:</td><td class="tktDspValue">
476 @ $<resolution>
477 @ </td></tr>
478 @ <tr><td class="tktDspLabel">Last&nbsp;Modified:</td><td class="tktDspValue">
479 @ <th1>
480 @ if {[info exists tkt_datetime]} {
481 @ html $tkt_datetime
482 @ }
483 @ </th1>
484 @ </td>
485 @ <th1>enable_output [hascap e]</th1>
486 @ <td class="tktDspLabel">Contact:</td><td class="tktDspValue">
487 @ $<private_contact>
488 @ </td>
@@ -479,20 +492,22 @@
492 @ <td colspan="3" valign="top" class="tktDspValue">
493 @ $<foundin>
494 @ </td></tr>
495 @
496 @ <th1>
497 @ if {[info exists comment]} {
498 @ if {[string length $comment]>10} {
499 @ html {
500 @ <tr><td class="tktDspLabel">Description:</td></tr>
501 @ <tr><td colspan="5" class="tktDspValue">
502 @ }
503 @ if {[info exists plaintext]} {
504 @ set r [randhex]
505 @ wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
506 @ } else {
507 @ wiki $comment
508 @ }
509 @ }
510 @ }
511 @ set seenRow 0
512 @ set alwaysPlaintext [info exists plaintext]
513 @ query {SELECT datetime(tkt_mtime) AS xdate, login AS xlogin,
514
+30 -8
--- src/wiki.c
+++ src/wiki.c
@@ -156,10 +156,32 @@
156156
@ %h(blob_str(pWiki))
157157
@ </pre>
158158
}
159159
}
160160
161
+/*
162
+** Returns non-zero if moderation is required for wiki changes and wiki
163
+** attachments.
164
+*/
165
+int wiki_need_moderation(
166
+ int localUser /* Are we being called for a local interactive user? */
167
+){
168
+ /*
169
+ ** If the FOSSIL_FORCE_WIKI_MODERATION variable is set, *ALL* changes for
170
+ ** wiki pages will be required to go through moderation (even those performed
171
+ ** by the local interactive user via the command line). This can be useful
172
+ ** for local (or remote) testing of the moderation subsystem and its impact
173
+ ** on the contents and status of wiki pages.
174
+ */
175
+ if( fossil_getenv("FOSSIL_FORCE_WIKI_MODERATION")!=0 ){
176
+ return 1;
177
+ }
178
+ if( localUser ){
179
+ return 0;
180
+ }
181
+ return g.perm.ModWiki==0 && db_get_boolean("modreq-wiki",0)==1;
182
+}
161183
162184
/*
163185
** WEBPAGE: wiki
164186
** URL: /wiki?name=PAGENAME
165187
*/
@@ -282,13 +304,13 @@
282304
}
283305
284306
/*
285307
** Write a wiki artifact into the repository
286308
*/
287
-static void wiki_put(Blob *pWiki, int parent){
309
+static void wiki_put(Blob *pWiki, int parent, int needMod){
288310
int nrid;
289
- if( g.perm.ModWiki || db_get_boolean("modreq-wiki",0)==0 ){
311
+ if( !needMod ){
290312
nrid = content_put_ex(pWiki, 0, 0, 0, 0);
291313
if( parent) content_deltify(parent, nrid, 0);
292314
}else{
293315
nrid = content_put_ex(pWiki, 0, 0, 0, 1);
294316
moderation_table_create();
@@ -427,11 +449,11 @@
427449
}
428450
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
429451
md5sum_blob(&wiki, &cksum);
430452
blob_appendf(&wiki, "Z %b\n", &cksum);
431453
blob_reset(&cksum);
432
- wiki_put(&wiki, 0);
454
+ wiki_put(&wiki, 0, wiki_need_moderation(0));
433455
}
434456
db_end_transaction(0);
435457
cgi_redirectf("wiki?name=%T", zPageName);
436458
}
437459
if( P("cancel")!=0 ){
@@ -658,11 +680,11 @@
658680
appendRemark(&body, zMimetype);
659681
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
660682
md5sum_blob(&wiki, &cksum);
661683
blob_appendf(&wiki, "Z %b\n", &cksum);
662684
blob_reset(&cksum);
663
- wiki_put(&wiki, rid);
685
+ wiki_put(&wiki, rid, wiki_need_moderation(0));
664686
db_end_transaction(0);
665687
}
666688
cgi_redirectf("wiki?name=%T", zPageName);
667689
}
668690
if( P("cancel")!=0 ){
@@ -961,11 +983,11 @@
961983
** zMimeType specifies the N-card for the wiki page. If it is 0,
962984
** empty, or "text/x-fossil-wiki" (the default format) then it is
963985
** ignored.
964986
*/
965987
int wiki_cmd_commit(const char *zPageName, int isNew, Blob *pContent,
966
- const char *zMimeType){
988
+ const char *zMimeType, int localUser){
967989
Blob wiki; /* Wiki page content */
968990
Blob cksum; /* wiki checksum */
969991
int rid; /* artifact ID of parent page */
970992
char *zDate; /* timestamp */
971993
char *zUuid; /* uuid for rid */
@@ -1011,11 +1033,11 @@
10111033
blob_str(pContent) );
10121034
md5sum_blob(&wiki, &cksum);
10131035
blob_appendf(&wiki, "Z %b\n", &cksum);
10141036
blob_reset(&cksum);
10151037
db_begin_transaction();
1016
- wiki_put(&wiki, 0);
1038
+ wiki_put(&wiki, 0, wiki_need_moderation(localUser));
10171039
db_end_transaction(0);
10181040
return 1;
10191041
}
10201042
10211043
/*
@@ -1119,14 +1141,14 @@
11191141
&& (pWiki->zMimetype && *pWiki->zMimetype)){
11201142
zMimeType = pWiki->zMimetype;
11211143
}
11221144
}
11231145
if( g.argv[2][1]=='r' ){
1124
- wiki_cmd_commit(zPageName, 1, &content, zMimeType);
1146
+ wiki_cmd_commit(zPageName, 1, &content, zMimeType, 1);
11251147
fossil_print("Created new wiki page %s.\n", zPageName);
11261148
}else{
1127
- wiki_cmd_commit(zPageName, 0, &content, zMimeType);
1149
+ wiki_cmd_commit(zPageName, 0, &content, zMimeType, 1);
11281150
fossil_print("Updated wiki page %s.\n", zPageName);
11291151
}
11301152
manifest_destroy(pWiki);
11311153
blob_reset(&content);
11321154
}else if( strncmp(g.argv[2],"delete",n)==0 ){
11331155
--- src/wiki.c
+++ src/wiki.c
@@ -156,10 +156,32 @@
156 @ %h(blob_str(pWiki))
157 @ </pre>
158 }
159 }
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
162 /*
163 ** WEBPAGE: wiki
164 ** URL: /wiki?name=PAGENAME
165 */
@@ -282,13 +304,13 @@
282 }
283
284 /*
285 ** Write a wiki artifact into the repository
286 */
287 static void wiki_put(Blob *pWiki, int parent){
288 int nrid;
289 if( g.perm.ModWiki || db_get_boolean("modreq-wiki",0)==0 ){
290 nrid = content_put_ex(pWiki, 0, 0, 0, 0);
291 if( parent) content_deltify(parent, nrid, 0);
292 }else{
293 nrid = content_put_ex(pWiki, 0, 0, 0, 1);
294 moderation_table_create();
@@ -427,11 +449,11 @@
427 }
428 blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
429 md5sum_blob(&wiki, &cksum);
430 blob_appendf(&wiki, "Z %b\n", &cksum);
431 blob_reset(&cksum);
432 wiki_put(&wiki, 0);
433 }
434 db_end_transaction(0);
435 cgi_redirectf("wiki?name=%T", zPageName);
436 }
437 if( P("cancel")!=0 ){
@@ -658,11 +680,11 @@
658 appendRemark(&body, zMimetype);
659 blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
660 md5sum_blob(&wiki, &cksum);
661 blob_appendf(&wiki, "Z %b\n", &cksum);
662 blob_reset(&cksum);
663 wiki_put(&wiki, rid);
664 db_end_transaction(0);
665 }
666 cgi_redirectf("wiki?name=%T", zPageName);
667 }
668 if( P("cancel")!=0 ){
@@ -961,11 +983,11 @@
961 ** zMimeType specifies the N-card for the wiki page. If it is 0,
962 ** empty, or "text/x-fossil-wiki" (the default format) then it is
963 ** ignored.
964 */
965 int wiki_cmd_commit(const char *zPageName, int isNew, Blob *pContent,
966 const char *zMimeType){
967 Blob wiki; /* Wiki page content */
968 Blob cksum; /* wiki checksum */
969 int rid; /* artifact ID of parent page */
970 char *zDate; /* timestamp */
971 char *zUuid; /* uuid for rid */
@@ -1011,11 +1033,11 @@
1011 blob_str(pContent) );
1012 md5sum_blob(&wiki, &cksum);
1013 blob_appendf(&wiki, "Z %b\n", &cksum);
1014 blob_reset(&cksum);
1015 db_begin_transaction();
1016 wiki_put(&wiki, 0);
1017 db_end_transaction(0);
1018 return 1;
1019 }
1020
1021 /*
@@ -1119,14 +1141,14 @@
1119 && (pWiki->zMimetype && *pWiki->zMimetype)){
1120 zMimeType = pWiki->zMimetype;
1121 }
1122 }
1123 if( g.argv[2][1]=='r' ){
1124 wiki_cmd_commit(zPageName, 1, &content, zMimeType);
1125 fossil_print("Created new wiki page %s.\n", zPageName);
1126 }else{
1127 wiki_cmd_commit(zPageName, 0, &content, zMimeType);
1128 fossil_print("Updated wiki page %s.\n", zPageName);
1129 }
1130 manifest_destroy(pWiki);
1131 blob_reset(&content);
1132 }else if( strncmp(g.argv[2],"delete",n)==0 ){
1133
--- src/wiki.c
+++ src/wiki.c
@@ -156,10 +156,32 @@
156 @ %h(blob_str(pWiki))
157 @ </pre>
158 }
159 }
160
161 /*
162 ** Returns non-zero if moderation is required for wiki changes and wiki
163 ** attachments.
164 */
165 int wiki_need_moderation(
166 int localUser /* Are we being called for a local interactive user? */
167 ){
168 /*
169 ** If the FOSSIL_FORCE_WIKI_MODERATION variable is set, *ALL* changes for
170 ** wiki pages will be required to go through moderation (even those performed
171 ** by the local interactive user via the command line). This can be useful
172 ** for local (or remote) testing of the moderation subsystem and its impact
173 ** on the contents and status of wiki pages.
174 */
175 if( fossil_getenv("FOSSIL_FORCE_WIKI_MODERATION")!=0 ){
176 return 1;
177 }
178 if( localUser ){
179 return 0;
180 }
181 return g.perm.ModWiki==0 && db_get_boolean("modreq-wiki",0)==1;
182 }
183
184 /*
185 ** WEBPAGE: wiki
186 ** URL: /wiki?name=PAGENAME
187 */
@@ -282,13 +304,13 @@
304 }
305
306 /*
307 ** Write a wiki artifact into the repository
308 */
309 static void wiki_put(Blob *pWiki, int parent, int needMod){
310 int nrid;
311 if( !needMod ){
312 nrid = content_put_ex(pWiki, 0, 0, 0, 0);
313 if( parent) content_deltify(parent, nrid, 0);
314 }else{
315 nrid = content_put_ex(pWiki, 0, 0, 0, 1);
316 moderation_table_create();
@@ -427,11 +449,11 @@
449 }
450 blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
451 md5sum_blob(&wiki, &cksum);
452 blob_appendf(&wiki, "Z %b\n", &cksum);
453 blob_reset(&cksum);
454 wiki_put(&wiki, 0, wiki_need_moderation(0));
455 }
456 db_end_transaction(0);
457 cgi_redirectf("wiki?name=%T", zPageName);
458 }
459 if( P("cancel")!=0 ){
@@ -658,11 +680,11 @@
680 appendRemark(&body, zMimetype);
681 blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
682 md5sum_blob(&wiki, &cksum);
683 blob_appendf(&wiki, "Z %b\n", &cksum);
684 blob_reset(&cksum);
685 wiki_put(&wiki, rid, wiki_need_moderation(0));
686 db_end_transaction(0);
687 }
688 cgi_redirectf("wiki?name=%T", zPageName);
689 }
690 if( P("cancel")!=0 ){
@@ -961,11 +983,11 @@
983 ** zMimeType specifies the N-card for the wiki page. If it is 0,
984 ** empty, or "text/x-fossil-wiki" (the default format) then it is
985 ** ignored.
986 */
987 int wiki_cmd_commit(const char *zPageName, int isNew, Blob *pContent,
988 const char *zMimeType, int localUser){
989 Blob wiki; /* Wiki page content */
990 Blob cksum; /* wiki checksum */
991 int rid; /* artifact ID of parent page */
992 char *zDate; /* timestamp */
993 char *zUuid; /* uuid for rid */
@@ -1011,11 +1033,11 @@
1033 blob_str(pContent) );
1034 md5sum_blob(&wiki, &cksum);
1035 blob_appendf(&wiki, "Z %b\n", &cksum);
1036 blob_reset(&cksum);
1037 db_begin_transaction();
1038 wiki_put(&wiki, 0, wiki_need_moderation(localUser));
1039 db_end_transaction(0);
1040 return 1;
1041 }
1042
1043 /*
@@ -1119,14 +1141,14 @@
1141 && (pWiki->zMimetype && *pWiki->zMimetype)){
1142 zMimeType = pWiki->zMimetype;
1143 }
1144 }
1145 if( g.argv[2][1]=='r' ){
1146 wiki_cmd_commit(zPageName, 1, &content, zMimeType, 1);
1147 fossil_print("Created new wiki page %s.\n", zPageName);
1148 }else{
1149 wiki_cmd_commit(zPageName, 0, &content, zMimeType, 1);
1150 fossil_print("Updated wiki page %s.\n", zPageName);
1151 }
1152 manifest_destroy(pWiki);
1153 blob_reset(&content);
1154 }else if( strncmp(g.argv[2],"delete",n)==0 ){
1155

Keyboard Shortcuts

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