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.
Commit
d33d446f9c882506e9c7b219b09733c8ee76b8eca58244a0b0c37ae4da9c49d0
Parent
9dc49e61cf839d8…
1 file changed
+29
+29
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -265,10 +265,28 @@ | ||
| 265 | 265 | } |
| 266 | 266 | if( zClass ){ |
| 267 | 267 | @ </div> |
| 268 | 268 | } |
| 269 | 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 | +} | |
| 270 | 288 | |
| 271 | 289 | /* |
| 272 | 290 | ** Display all posts in a forum thread in chronological order |
| 273 | 291 | */ |
| 274 | 292 | static void forum_display_chronological(int froot, int target){ |
| @@ -340,10 +358,11 @@ | ||
| 340 | 358 | }else if( g.perm.ModForum ){ |
| 341 | 359 | /* Provide moderators with moderation buttons for posts that |
| 342 | 360 | ** are pending moderation */ |
| 343 | 361 | @ <input type="submit" name="approve" value="Approve"> |
| 344 | 362 | @ <input type="submit" name="reject" value="Reject"> |
| 363 | + generateTrustControls(pPost); | |
| 345 | 364 | }else if( sameUser ){ |
| 346 | 365 | /* A post that is pending moderation can be deleted by the |
| 347 | 366 | ** person who originally submitted the post */ |
| 348 | 367 | @ <input type="submit" name="reject" value="Delete"> |
| 349 | 368 | } |
| @@ -446,10 +465,11 @@ | ||
| 446 | 465 | }else if( g.perm.ModForum ){ |
| 447 | 466 | /* Provide moderators with moderation buttons for posts that |
| 448 | 467 | ** are pending moderation */ |
| 449 | 468 | @ <input type="submit" name="approve" value="Approve"> |
| 450 | 469 | @ <input type="submit" name="reject" value="Reject"> |
| 470 | + generateTrustControls(pPost); | |
| 451 | 471 | }else if( sameUser ){ |
| 452 | 472 | /* A post that is pending moderation can be deleted by the |
| 453 | 473 | ** person who originally submitted the post */ |
| 454 | 474 | @ <input type="submit" name="reject" value="Delete"> |
| 455 | 475 | } |
| @@ -803,11 +823,20 @@ | ||
| 803 | 823 | return; |
| 804 | 824 | } |
| 805 | 825 | isCsrfSafe = cgi_csrf_safe(1); |
| 806 | 826 | if( g.perm.ModForum && isCsrfSafe ){ |
| 807 | 827 | if( P("approve") ){ |
| 828 | + const char *zUserToTrust; | |
| 808 | 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 | + } | |
| 809 | 838 | cgi_redirectf("%R/forumpost/%S",P("fpid")); |
| 810 | 839 | return; |
| 811 | 840 | } |
| 812 | 841 | if( P("reject") ){ |
| 813 | 842 | char *zParent = |
| 814 | 843 |
| --- 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 |