Fossil SCM

Allow users with Forum Supervisor permission ('6') to add Forum Write Trusted permission ('4') to users as they are approving a post by that user.

drh 2018-10-04 13:45 trunk
Commit d33d446f9c882506e9c7b219b09733c8ee76b8eca58244a0b0c37ae4da9c49d0
1 file changed +29
+29
--- src/forum.c
+++ src/forum.c
@@ -265,10 +265,28 @@
265265
}
266266
if( zClass ){
267267
@ </div>
268268
}
269269
}
270
+
271
+/*
272
+** Generate the buttons in the display that allow a forum supervisor to
273
+** mark a user as trusted. Only do this if:
274
+**
275
+** (1) The poster is an individual, not a special user like "anonymous"
276
+** (2) The current user has Forum Supervisor privilege
277
+*/
278
+static void generateTrustControls(Manifest *pPost){
279
+ if( !g.perm.AdminForum ) return;
280
+ if( login_is_special(pPost->zUser) ) return;
281
+ @ <br>
282
+ @ <label><input type="checkbox" name="trust">
283
+ @ Trust user "%h(pPost->zUser)"
284
+ @ so that future posts by "%h(pPost->zUser)" do not require moderation.
285
+ @ </label>
286
+ @ <input type="hidden" name="trustuser" value="%h(pPost->zUser)">
287
+}
270288
271289
/*
272290
** Display all posts in a forum thread in chronological order
273291
*/
274292
static void forum_display_chronological(int froot, int target){
@@ -340,10 +358,11 @@
340358
}else if( g.perm.ModForum ){
341359
/* Provide moderators with moderation buttons for posts that
342360
** are pending moderation */
343361
@ <input type="submit" name="approve" value="Approve">
344362
@ <input type="submit" name="reject" value="Reject">
363
+ generateTrustControls(pPost);
345364
}else if( sameUser ){
346365
/* A post that is pending moderation can be deleted by the
347366
** person who originally submitted the post */
348367
@ <input type="submit" name="reject" value="Delete">
349368
}
@@ -446,10 +465,11 @@
446465
}else if( g.perm.ModForum ){
447466
/* Provide moderators with moderation buttons for posts that
448467
** are pending moderation */
449468
@ <input type="submit" name="approve" value="Approve">
450469
@ <input type="submit" name="reject" value="Reject">
470
+ generateTrustControls(pPost);
451471
}else if( sameUser ){
452472
/* A post that is pending moderation can be deleted by the
453473
** person who originally submitted the post */
454474
@ <input type="submit" name="reject" value="Delete">
455475
}
@@ -803,11 +823,20 @@
803823
return;
804824
}
805825
isCsrfSafe = cgi_csrf_safe(1);
806826
if( g.perm.ModForum && isCsrfSafe ){
807827
if( P("approve") ){
828
+ const char *zUserToTrust;
808829
moderation_approve(fpid);
830
+ if( g.perm.AdminForum
831
+ && PB("trust")
832
+ && (zUserToTrust = P("trustuser"))!=0
833
+ ){
834
+ db_multi_exec("UPDATE user SET cap=cap||'4' "
835
+ "WHERE login=%Q AND cap NOT GLOB '*4*'",
836
+ zUserToTrust);
837
+ }
809838
cgi_redirectf("%R/forumpost/%S",P("fpid"));
810839
return;
811840
}
812841
if( P("reject") ){
813842
char *zParent =
814843
--- src/forum.c
+++ src/forum.c
@@ -265,10 +265,28 @@
265 }
266 if( zClass ){
267 @ </div>
268 }
269 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
271 /*
272 ** Display all posts in a forum thread in chronological order
273 */
274 static void forum_display_chronological(int froot, int target){
@@ -340,10 +358,11 @@
340 }else if( g.perm.ModForum ){
341 /* Provide moderators with moderation buttons for posts that
342 ** are pending moderation */
343 @ <input type="submit" name="approve" value="Approve">
344 @ <input type="submit" name="reject" value="Reject">
 
345 }else if( sameUser ){
346 /* A post that is pending moderation can be deleted by the
347 ** person who originally submitted the post */
348 @ <input type="submit" name="reject" value="Delete">
349 }
@@ -446,10 +465,11 @@
446 }else if( g.perm.ModForum ){
447 /* Provide moderators with moderation buttons for posts that
448 ** are pending moderation */
449 @ <input type="submit" name="approve" value="Approve">
450 @ <input type="submit" name="reject" value="Reject">
 
451 }else if( sameUser ){
452 /* A post that is pending moderation can be deleted by the
453 ** person who originally submitted the post */
454 @ <input type="submit" name="reject" value="Delete">
455 }
@@ -803,11 +823,20 @@
803 return;
804 }
805 isCsrfSafe = cgi_csrf_safe(1);
806 if( g.perm.ModForum && isCsrfSafe ){
807 if( P("approve") ){
 
808 moderation_approve(fpid);
 
 
 
 
 
 
 
 
809 cgi_redirectf("%R/forumpost/%S",P("fpid"));
810 return;
811 }
812 if( P("reject") ){
813 char *zParent =
814
--- src/forum.c
+++ src/forum.c
@@ -265,10 +265,28 @@
265 }
266 if( zClass ){
267 @ </div>
268 }
269 }
270
271 /*
272 ** Generate the buttons in the display that allow a forum supervisor to
273 ** mark a user as trusted. Only do this if:
274 **
275 ** (1) The poster is an individual, not a special user like "anonymous"
276 ** (2) The current user has Forum Supervisor privilege
277 */
278 static void generateTrustControls(Manifest *pPost){
279 if( !g.perm.AdminForum ) return;
280 if( login_is_special(pPost->zUser) ) return;
281 @ <br>
282 @ <label><input type="checkbox" name="trust">
283 @ Trust user "%h(pPost->zUser)"
284 @ so that future posts by "%h(pPost->zUser)" do not require moderation.
285 @ </label>
286 @ <input type="hidden" name="trustuser" value="%h(pPost->zUser)">
287 }
288
289 /*
290 ** Display all posts in a forum thread in chronological order
291 */
292 static void forum_display_chronological(int froot, int target){
@@ -340,10 +358,11 @@
358 }else if( g.perm.ModForum ){
359 /* Provide moderators with moderation buttons for posts that
360 ** are pending moderation */
361 @ <input type="submit" name="approve" value="Approve">
362 @ <input type="submit" name="reject" value="Reject">
363 generateTrustControls(pPost);
364 }else if( sameUser ){
365 /* A post that is pending moderation can be deleted by the
366 ** person who originally submitted the post */
367 @ <input type="submit" name="reject" value="Delete">
368 }
@@ -446,10 +465,11 @@
465 }else if( g.perm.ModForum ){
466 /* Provide moderators with moderation buttons for posts that
467 ** are pending moderation */
468 @ <input type="submit" name="approve" value="Approve">
469 @ <input type="submit" name="reject" value="Reject">
470 generateTrustControls(pPost);
471 }else if( sameUser ){
472 /* A post that is pending moderation can be deleted by the
473 ** person who originally submitted the post */
474 @ <input type="submit" name="reject" value="Delete">
475 }
@@ -803,11 +823,20 @@
823 return;
824 }
825 isCsrfSafe = cgi_csrf_safe(1);
826 if( g.perm.ModForum && isCsrfSafe ){
827 if( P("approve") ){
828 const char *zUserToTrust;
829 moderation_approve(fpid);
830 if( g.perm.AdminForum
831 && PB("trust")
832 && (zUserToTrust = P("trustuser"))!=0
833 ){
834 db_multi_exec("UPDATE user SET cap=cap||'4' "
835 "WHERE login=%Q AND cap NOT GLOB '*4*'",
836 zUserToTrust);
837 }
838 cgi_redirectf("%R/forumpost/%S",P("fpid"));
839 return;
840 }
841 if( P("reject") ){
842 char *zParent =
843

Keyboard Shortcuts

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