Fossil SCM

Wiki moderation now appears to be working.

drh 2012-11-01 14:34 UTC moderation
Commit b7ccf110f37cf390e5b8a2c9439a426f73273027
4 files changed +35 -3 +2 -1 +12 -3 +20 -15
+35 -3
--- src/info.c
+++ src/info.c
@@ -723,10 +723,12 @@
723723
int rid;
724724
Manifest *pWiki;
725725
char *zUuid;
726726
char *zDate;
727727
Blob wiki;
728
+ int modPending;
729
+ const char *zModAction;
728730
729731
login_check_credentials();
730732
if( !g.perm.RdWiki ){ login_needed(); return; }
731733
rid = name_to_rid_www("name");
732734
if( rid==0 || (pWiki = manifest_get(rid, CFTYPE_WIKI))==0 ){
@@ -733,11 +735,21 @@
733735
style_header("Wiki Page Information Error");
734736
@ No such object: %h(P("name"))
735737
style_footer();
736738
return;
737739
}
738
- style_header("Edit To %h", pWiki->zWikiTitle);
740
+ if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
741
+ if( strcmp(zModAction,"delete")==0 ){
742
+ moderation_disapprove(rid);
743
+ cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
744
+ /*NOTREACHED*/
745
+ }
746
+ if( strcmp(zModAction,"approve")==0 ){
747
+ moderation_approve(rid);
748
+ }
749
+ }
750
+ style_header("Update of \"%h\"", pWiki->zWikiTitle);
739751
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
740752
zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate);
741753
style_submenu_element("Raw", "Raw", "artifact/%S", zUuid);
742754
style_submenu_element("History", "History", "whistory?name=%t",
743755
pWiki->zWikiTitle);
@@ -744,14 +756,19 @@
744756
style_submenu_element("Page", "Page", "wiki?name=%t",
745757
pWiki->zWikiTitle);
746758
login_anonymous_available();
747759
@ <div class="section">Overview</div>
748760
@ <p><table class="label-value">
749
- @ <tr><th>Artifact&nbsp;ID:</th><td>%s(zUuid)
761
+ @ <tr><th>Artifact&nbsp;ID:</th>
762
+ @ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a>
750763
if( g.perm.Setup ){
751764
@ (%d(rid))
752765
}
766
+ modPending = moderation_pending(rid);
767
+ if( modPending ){
768
+ @ <span class="modpending">*** Moderation Pending ***</span>
769
+ }
753770
@ </td></tr>
754771
@ <tr><th>Page&nbsp;Name:</th><td>%h(pWiki->zWikiTitle)</td></tr>
755772
@ <tr><th>Date:</th><td>
756773
hyperlink_to_date(zDate, "</td></tr>");
757774
@ <tr><th>Original&nbsp;User:</th><td>
@@ -764,12 +781,27 @@
764781
@ %z(href("info/%S",zParent))%s(zParent)</a>
765782
}
766783
@ </td></tr>
767784
}
768785
@ </table>
769
- blob_init(&wiki, pWiki->zWiki, -1);
786
+
787
+ if( g.perm.ModWiki && modPending ){
788
+ @ <div class="section">Moderation</div>
789
+ @ <blockquote>
790
+ @ <form method="POST" action="%R/winfo/%s(zUuid)">
791
+ @ <label><input type="radio" name="modaction" value="delete">
792
+ @ Delete this change</label><br />
793
+ @ <label><input type="radio" name="modaction" value="approve">
794
+ @ Approve this change</label><br />
795
+ @ <input type="submit" value="Submit">
796
+ @ </form>
797
+ @ </blockquote>
798
+ }
799
+
800
+
770801
@ <div class="section">Content</div>
802
+ blob_init(&wiki, pWiki->zWiki, -1);
771803
wiki_convert(&wiki, 0, 0);
772804
blob_reset(&wiki);
773805
manifest_destroy(pWiki);
774806
style_footer();
775807
}
776808
--- src/info.c
+++ src/info.c
@@ -723,10 +723,12 @@
723 int rid;
724 Manifest *pWiki;
725 char *zUuid;
726 char *zDate;
727 Blob wiki;
 
 
728
729 login_check_credentials();
730 if( !g.perm.RdWiki ){ login_needed(); return; }
731 rid = name_to_rid_www("name");
732 if( rid==0 || (pWiki = manifest_get(rid, CFTYPE_WIKI))==0 ){
@@ -733,11 +735,21 @@
733 style_header("Wiki Page Information Error");
734 @ No such object: %h(P("name"))
735 style_footer();
736 return;
737 }
738 style_header("Edit To %h", pWiki->zWikiTitle);
 
 
 
 
 
 
 
 
 
 
739 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
740 zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate);
741 style_submenu_element("Raw", "Raw", "artifact/%S", zUuid);
742 style_submenu_element("History", "History", "whistory?name=%t",
743 pWiki->zWikiTitle);
@@ -744,14 +756,19 @@
744 style_submenu_element("Page", "Page", "wiki?name=%t",
745 pWiki->zWikiTitle);
746 login_anonymous_available();
747 @ <div class="section">Overview</div>
748 @ <p><table class="label-value">
749 @ <tr><th>Artifact&nbsp;ID:</th><td>%s(zUuid)
 
750 if( g.perm.Setup ){
751 @ (%d(rid))
752 }
 
 
 
 
753 @ </td></tr>
754 @ <tr><th>Page&nbsp;Name:</th><td>%h(pWiki->zWikiTitle)</td></tr>
755 @ <tr><th>Date:</th><td>
756 hyperlink_to_date(zDate, "</td></tr>");
757 @ <tr><th>Original&nbsp;User:</th><td>
@@ -764,12 +781,27 @@
764 @ %z(href("info/%S",zParent))%s(zParent)</a>
765 }
766 @ </td></tr>
767 }
768 @ </table>
769 blob_init(&wiki, pWiki->zWiki, -1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770 @ <div class="section">Content</div>
 
771 wiki_convert(&wiki, 0, 0);
772 blob_reset(&wiki);
773 manifest_destroy(pWiki);
774 style_footer();
775 }
776
--- src/info.c
+++ src/info.c
@@ -723,10 +723,12 @@
723 int rid;
724 Manifest *pWiki;
725 char *zUuid;
726 char *zDate;
727 Blob wiki;
728 int modPending;
729 const char *zModAction;
730
731 login_check_credentials();
732 if( !g.perm.RdWiki ){ login_needed(); return; }
733 rid = name_to_rid_www("name");
734 if( rid==0 || (pWiki = manifest_get(rid, CFTYPE_WIKI))==0 ){
@@ -733,11 +735,21 @@
735 style_header("Wiki Page Information Error");
736 @ No such object: %h(P("name"))
737 style_footer();
738 return;
739 }
740 if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
741 if( strcmp(zModAction,"delete")==0 ){
742 moderation_disapprove(rid);
743 cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
744 /*NOTREACHED*/
745 }
746 if( strcmp(zModAction,"approve")==0 ){
747 moderation_approve(rid);
748 }
749 }
750 style_header("Update of \"%h\"", pWiki->zWikiTitle);
751 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
752 zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate);
753 style_submenu_element("Raw", "Raw", "artifact/%S", zUuid);
754 style_submenu_element("History", "History", "whistory?name=%t",
755 pWiki->zWikiTitle);
@@ -744,14 +756,19 @@
756 style_submenu_element("Page", "Page", "wiki?name=%t",
757 pWiki->zWikiTitle);
758 login_anonymous_available();
759 @ <div class="section">Overview</div>
760 @ <p><table class="label-value">
761 @ <tr><th>Artifact&nbsp;ID:</th>
762 @ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a>
763 if( g.perm.Setup ){
764 @ (%d(rid))
765 }
766 modPending = moderation_pending(rid);
767 if( modPending ){
768 @ <span class="modpending">*** Moderation Pending ***</span>
769 }
770 @ </td></tr>
771 @ <tr><th>Page&nbsp;Name:</th><td>%h(pWiki->zWikiTitle)</td></tr>
772 @ <tr><th>Date:</th><td>
773 hyperlink_to_date(zDate, "</td></tr>");
774 @ <tr><th>Original&nbsp;User:</th><td>
@@ -764,12 +781,27 @@
781 @ %z(href("info/%S",zParent))%s(zParent)</a>
782 }
783 @ </td></tr>
784 }
785 @ </table>
786
787 if( g.perm.ModWiki && modPending ){
788 @ <div class="section">Moderation</div>
789 @ <blockquote>
790 @ <form method="POST" action="%R/winfo/%s(zUuid)">
791 @ <label><input type="radio" name="modaction" value="delete">
792 @ Delete this change</label><br />
793 @ <label><input type="radio" name="modaction" value="approve">
794 @ Approve this change</label><br />
795 @ <input type="submit" value="Submit">
796 @ </form>
797 @ </blockquote>
798 }
799
800
801 @ <div class="section">Content</div>
802 blob_init(&wiki, pWiki->zWiki, -1);
803 wiki_convert(&wiki, 0, 0);
804 blob_reset(&wiki);
805 manifest_destroy(pWiki);
806 style_footer();
807 }
808
+2 -1
--- src/login.c
+++ src/login.c
@@ -977,11 +977,12 @@
977977
case 's': g.perm.Setup = 1; /* Fall thru into Admin */
978978
case 'a': g.perm.Admin = g.perm.RdTkt = g.perm.WrTkt = g.perm.Zip =
979979
g.perm.RdWiki = g.perm.WrWiki = g.perm.NewWiki =
980980
g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone =
981981
g.perm.NewTkt = g.perm.Password = g.perm.RdAddr =
982
- g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt = 1;
982
+ g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt =
983
+ g.perm.ModWiki = g.perm.ModTkt = 1;
983984
/* Fall thru into Read/Write */
984985
case 'i': g.perm.Read = g.perm.Write = 1; break;
985986
case 'o': g.perm.Read = 1; break;
986987
case 'z': g.perm.Zip = 1; break;
987988
988989
--- src/login.c
+++ src/login.c
@@ -977,11 +977,12 @@
977 case 's': g.perm.Setup = 1; /* Fall thru into Admin */
978 case 'a': g.perm.Admin = g.perm.RdTkt = g.perm.WrTkt = g.perm.Zip =
979 g.perm.RdWiki = g.perm.WrWiki = g.perm.NewWiki =
980 g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone =
981 g.perm.NewTkt = g.perm.Password = g.perm.RdAddr =
982 g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt = 1;
 
983 /* Fall thru into Read/Write */
984 case 'i': g.perm.Read = g.perm.Write = 1; break;
985 case 'o': g.perm.Read = 1; break;
986 case 'z': g.perm.Zip = 1; break;
987
988
--- src/login.c
+++ src/login.c
@@ -977,11 +977,12 @@
977 case 's': g.perm.Setup = 1; /* Fall thru into Admin */
978 case 'a': g.perm.Admin = g.perm.RdTkt = g.perm.WrTkt = g.perm.Zip =
979 g.perm.RdWiki = g.perm.WrWiki = g.perm.NewWiki =
980 g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone =
981 g.perm.NewTkt = g.perm.Password = g.perm.RdAddr =
982 g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt =
983 g.perm.ModWiki = g.perm.ModTkt = 1;
984 /* Fall thru into Read/Write */
985 case 'i': g.perm.Read = g.perm.Write = 1; break;
986 case 'o': g.perm.Read = 1; break;
987 case 'z': g.perm.Zip = 1; break;
988
989
+12 -3
--- src/moderate.c
+++ src/moderate.c
@@ -67,10 +67,11 @@
6767
*/
6868
void moderation_disapprove(int rid){
6969
Stmt q;
7070
char *zTktid;
7171
if( !moderation_pending(rid) ) return;
72
+ db_begin_transaction();
7273
if( content_is_private(rid) ){
7374
db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
7475
while( db_step(&q)==SQLITE_ROW ){
7576
int ridUser = db_column_int(&q, 0);
7677
content_undelta(ridUser);
@@ -88,39 +89,47 @@
8889
if( zTktid ){
8990
ticket_rebuild_entry(zTktid);
9091
fossil_free(zTktid);
9192
}
9293
}
93
- db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d AND "
94
+ db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d "
9495
"UNION SELECT parent FROM modreq WHERE objid=%d",
9596
rid, rid);
9697
while( db_step(&q)==SQLITE_ROW ){
9798
int other = db_column_int(&q, 0);
9899
if( other==rid ) continue;
99100
moderation_approve(other);
100101
}
101102
db_finalize(&q);
102103
db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
104
+ db_end_transaction(0);
103105
}
104106
105107
/*
106108
** Approve an object held for moderation.
107109
*/
108110
void moderation_approve(int rid){
109111
Stmt q;
110112
if( !moderation_pending(rid) ) return;
111
- db_multi_exec("DELETE FROM private WHERE rid=%d;", rid);
112
- db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d AND "
113
+ db_begin_transaction();
114
+ db_multi_exec(
115
+ "DELETE FROM private WHERE rid=%d;"
116
+ "INSERT OR IGNORE INTO unclustered VALUES(%d);"
117
+ "INSERT OR IGNORE INTO unsent VALUES(%d);",
118
+ rid, rid, rid
119
+ );
120
+ db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d "
113121
"UNION SELECT parent FROM modreq WHERE objid=%d",
114122
rid, rid);
115123
while( db_step(&q)==SQLITE_ROW ){
116124
int other = db_column_int(&q, 0);
117125
if( other==rid ) continue;
118126
moderation_approve(other);
119127
}
120128
db_finalize(&q);
121129
db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
130
+ db_end_transaction(0);
122131
}
123132
124133
/*
125134
** WEBPAGE: modreq
126135
**
127136
--- src/moderate.c
+++ src/moderate.c
@@ -67,10 +67,11 @@
67 */
68 void moderation_disapprove(int rid){
69 Stmt q;
70 char *zTktid;
71 if( !moderation_pending(rid) ) return;
 
72 if( content_is_private(rid) ){
73 db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
74 while( db_step(&q)==SQLITE_ROW ){
75 int ridUser = db_column_int(&q, 0);
76 content_undelta(ridUser);
@@ -88,39 +89,47 @@
88 if( zTktid ){
89 ticket_rebuild_entry(zTktid);
90 fossil_free(zTktid);
91 }
92 }
93 db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d AND "
94 "UNION SELECT parent FROM modreq WHERE objid=%d",
95 rid, rid);
96 while( db_step(&q)==SQLITE_ROW ){
97 int other = db_column_int(&q, 0);
98 if( other==rid ) continue;
99 moderation_approve(other);
100 }
101 db_finalize(&q);
102 db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
 
103 }
104
105 /*
106 ** Approve an object held for moderation.
107 */
108 void moderation_approve(int rid){
109 Stmt q;
110 if( !moderation_pending(rid) ) return;
111 db_multi_exec("DELETE FROM private WHERE rid=%d;", rid);
112 db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d AND "
 
 
 
 
 
 
113 "UNION SELECT parent FROM modreq WHERE objid=%d",
114 rid, rid);
115 while( db_step(&q)==SQLITE_ROW ){
116 int other = db_column_int(&q, 0);
117 if( other==rid ) continue;
118 moderation_approve(other);
119 }
120 db_finalize(&q);
121 db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
 
122 }
123
124 /*
125 ** WEBPAGE: modreq
126 **
127
--- src/moderate.c
+++ src/moderate.c
@@ -67,10 +67,11 @@
67 */
68 void moderation_disapprove(int rid){
69 Stmt q;
70 char *zTktid;
71 if( !moderation_pending(rid) ) return;
72 db_begin_transaction();
73 if( content_is_private(rid) ){
74 db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
75 while( db_step(&q)==SQLITE_ROW ){
76 int ridUser = db_column_int(&q, 0);
77 content_undelta(ridUser);
@@ -88,39 +89,47 @@
89 if( zTktid ){
90 ticket_rebuild_entry(zTktid);
91 fossil_free(zTktid);
92 }
93 }
94 db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d "
95 "UNION SELECT parent FROM modreq WHERE objid=%d",
96 rid, rid);
97 while( db_step(&q)==SQLITE_ROW ){
98 int other = db_column_int(&q, 0);
99 if( other==rid ) continue;
100 moderation_approve(other);
101 }
102 db_finalize(&q);
103 db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
104 db_end_transaction(0);
105 }
106
107 /*
108 ** Approve an object held for moderation.
109 */
110 void moderation_approve(int rid){
111 Stmt q;
112 if( !moderation_pending(rid) ) return;
113 db_begin_transaction();
114 db_multi_exec(
115 "DELETE FROM private WHERE rid=%d;"
116 "INSERT OR IGNORE INTO unclustered VALUES(%d);"
117 "INSERT OR IGNORE INTO unsent VALUES(%d);",
118 rid, rid, rid
119 );
120 db_prepare(&q, "SELECT objid FROM modreq WHERE parent=%d "
121 "UNION SELECT parent FROM modreq WHERE objid=%d",
122 rid, rid);
123 while( db_step(&q)==SQLITE_ROW ){
124 int other = db_column_int(&q, 0);
125 if( other==rid ) continue;
126 moderation_approve(other);
127 }
128 db_finalize(&q);
129 db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
130 db_end_transaction(0);
131 }
132
133 /*
134 ** WEBPAGE: modreq
135 **
136
+20 -15
--- src/wiki.c
+++ src/wiki.c
@@ -255,10 +255,27 @@
255255
db_finalize(&q);
256256
257257
manifest_destroy(pWiki);
258258
style_footer();
259259
}
260
+
261
+/*
262
+** Write a wiki artifact into the repository
263
+*/
264
+static void wiki_put(Blob *pWiki, int parent){
265
+ int nrid;
266
+ if( g.perm.ModWiki ){
267
+ nrid = content_put_ex(pWiki, 0, 0, 0, 0);
268
+ if( parent) content_deltify(parent, nrid, 0);
269
+ }else{
270
+ nrid = content_put_ex(pWiki, 0, 0, 0, 1);
271
+ moderation_table_create();
272
+ db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
273
+ }
274
+ db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
275
+ manifest_crosslink(nrid, pWiki);
276
+}
260277
261278
/*
262279
** WEBPAGE: wikiedit
263280
** URL: /wikiedit?name=PAGENAME
264281
*/
@@ -338,15 +355,11 @@
338355
}
339356
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
340357
md5sum_blob(&wiki, &cksum);
341358
blob_appendf(&wiki, "Z %b\n", &cksum);
342359
blob_reset(&cksum);
343
- nrid = content_put(&wiki);
344
- db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
345
- manifest_crosslink(nrid, &wiki);
346
- assert( blob_is_reset(&wiki) );
347
- content_deltify(rid, nrid, 0);
360
+ wiki_put(&wiki, 0);
348361
}
349362
db_end_transaction(0);
350363
cgi_redirectf("wiki?name=%T", zPageName);
351364
}
352365
if( P("cancel")!=0 ){
@@ -538,15 +551,11 @@
538551
appendRemark(&body);
539552
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
540553
md5sum_blob(&wiki, &cksum);
541554
blob_appendf(&wiki, "Z %b\n", &cksum);
542555
blob_reset(&cksum);
543
- nrid = content_put(&wiki);
544
- db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
545
- manifest_crosslink(nrid, &wiki);
546
- assert( blob_is_reset(&wiki) );
547
- content_deltify(rid, nrid, 0);
556
+ wiki_put(&wiki, rid);
548557
db_end_transaction(0);
549558
}
550559
cgi_redirectf("wiki?name=%T", zPageName);
551560
}
552561
if( P("cancel")!=0 ){
@@ -881,15 +890,11 @@
881890
blob_str(pContent) );
882891
md5sum_blob(&wiki, &cksum);
883892
blob_appendf(&wiki, "Z %b\n", &cksum);
884893
blob_reset(&cksum);
885894
db_begin_transaction();
886
- nrid = content_put( &wiki);
887
- db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
888
- manifest_crosslink(nrid,&wiki);
889
- assert( blob_is_reset(&wiki) );
890
- content_deltify(rid,nrid,0);
895
+ wiki_put(&wiki, 0);
891896
db_end_transaction(0);
892897
return 1;
893898
}
894899
895900
/*
896901
--- src/wiki.c
+++ src/wiki.c
@@ -255,10 +255,27 @@
255 db_finalize(&q);
256
257 manifest_destroy(pWiki);
258 style_footer();
259 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
261 /*
262 ** WEBPAGE: wikiedit
263 ** URL: /wikiedit?name=PAGENAME
264 */
@@ -338,15 +355,11 @@
338 }
339 blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
340 md5sum_blob(&wiki, &cksum);
341 blob_appendf(&wiki, "Z %b\n", &cksum);
342 blob_reset(&cksum);
343 nrid = content_put(&wiki);
344 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
345 manifest_crosslink(nrid, &wiki);
346 assert( blob_is_reset(&wiki) );
347 content_deltify(rid, nrid, 0);
348 }
349 db_end_transaction(0);
350 cgi_redirectf("wiki?name=%T", zPageName);
351 }
352 if( P("cancel")!=0 ){
@@ -538,15 +551,11 @@
538 appendRemark(&body);
539 blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
540 md5sum_blob(&wiki, &cksum);
541 blob_appendf(&wiki, "Z %b\n", &cksum);
542 blob_reset(&cksum);
543 nrid = content_put(&wiki);
544 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
545 manifest_crosslink(nrid, &wiki);
546 assert( blob_is_reset(&wiki) );
547 content_deltify(rid, nrid, 0);
548 db_end_transaction(0);
549 }
550 cgi_redirectf("wiki?name=%T", zPageName);
551 }
552 if( P("cancel")!=0 ){
@@ -881,15 +890,11 @@
881 blob_str(pContent) );
882 md5sum_blob(&wiki, &cksum);
883 blob_appendf(&wiki, "Z %b\n", &cksum);
884 blob_reset(&cksum);
885 db_begin_transaction();
886 nrid = content_put( &wiki);
887 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
888 manifest_crosslink(nrid,&wiki);
889 assert( blob_is_reset(&wiki) );
890 content_deltify(rid,nrid,0);
891 db_end_transaction(0);
892 return 1;
893 }
894
895 /*
896
--- src/wiki.c
+++ src/wiki.c
@@ -255,10 +255,27 @@
255 db_finalize(&q);
256
257 manifest_destroy(pWiki);
258 style_footer();
259 }
260
261 /*
262 ** Write a wiki artifact into the repository
263 */
264 static void wiki_put(Blob *pWiki, int parent){
265 int nrid;
266 if( g.perm.ModWiki ){
267 nrid = content_put_ex(pWiki, 0, 0, 0, 0);
268 if( parent) content_deltify(parent, nrid, 0);
269 }else{
270 nrid = content_put_ex(pWiki, 0, 0, 0, 1);
271 moderation_table_create();
272 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
273 }
274 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
275 manifest_crosslink(nrid, pWiki);
276 }
277
278 /*
279 ** WEBPAGE: wikiedit
280 ** URL: /wikiedit?name=PAGENAME
281 */
@@ -338,15 +355,11 @@
355 }
356 blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
357 md5sum_blob(&wiki, &cksum);
358 blob_appendf(&wiki, "Z %b\n", &cksum);
359 blob_reset(&cksum);
360 wiki_put(&wiki, 0);
 
 
 
 
361 }
362 db_end_transaction(0);
363 cgi_redirectf("wiki?name=%T", zPageName);
364 }
365 if( P("cancel")!=0 ){
@@ -538,15 +551,11 @@
551 appendRemark(&body);
552 blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
553 md5sum_blob(&wiki, &cksum);
554 blob_appendf(&wiki, "Z %b\n", &cksum);
555 blob_reset(&cksum);
556 wiki_put(&wiki, rid);
 
 
 
 
557 db_end_transaction(0);
558 }
559 cgi_redirectf("wiki?name=%T", zPageName);
560 }
561 if( P("cancel")!=0 ){
@@ -881,15 +890,11 @@
890 blob_str(pContent) );
891 md5sum_blob(&wiki, &cksum);
892 blob_appendf(&wiki, "Z %b\n", &cksum);
893 blob_reset(&cksum);
894 db_begin_transaction();
895 wiki_put(&wiki, 0);
 
 
 
 
896 db_end_transaction(0);
897 return 1;
898 }
899
900 /*
901

Keyboard Shortcuts

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