Fossil SCM

Move forumpost close/re-open controls around. Add, if appropriate, a Close/Re-open button to the thread view, but only for the currently-selected post.

stephan 2023-02-24 23:39 forumpost-locking
Commit ecc324b6af5d1e2142c558a42597246bfa7d1c36502bb69cee1a7967ffc9bdf8
2 files changed +9 -5 +23 -13
+9 -5
--- src/default.css
+++ src/default.css
@@ -910,24 +910,28 @@
910910
content: "[CLOSED] ";
911911
}
912912
/*div.forumClosed > div.forumPostBody {
913913
filter: blur(5px);
914914
}*/
915
-div.forumpost-closed-warning {
915
+div.forumpost-closure-warning {
916916
margin-top: 1em;
917917
margin-bottom: 1em;
918918
border-style: solid;
919919
padding: 0.25em 0.5em;
920
- background: yellow;
921
- color: darkred;
922
- font-weight: bold;
920
+ background: #f4f400bb;
921
+ /*font-weight: bold;*/
923922
}
924
-div.forumpost-closed-warning input[type=submit] {
923
+div.forumpost-closure-warning input[type=submit] {
925924
padding: 0.25em;
925
+}
926
+div.forumpost-single-controls {
927
+ /* UI controls along the bottom of a single post
928
+ ** in the thread view. */
926929
}
927930
.forum div > form {
928931
margin: 0.5em 0;
932
+ display: inline-block;
929933
}
930934
.forum-post-collapser {
931935
/* Common style for the bottom-of-post and right-of-post
932936
expand/collapse widgets. */
933937
font-size: 0.8em;
934938
--- src/default.css
+++ src/default.css
@@ -910,24 +910,28 @@
910 content: "[CLOSED] ";
911 }
912 /*div.forumClosed > div.forumPostBody {
913 filter: blur(5px);
914 }*/
915 div.forumpost-closed-warning {
916 margin-top: 1em;
917 margin-bottom: 1em;
918 border-style: solid;
919 padding: 0.25em 0.5em;
920 background: yellow;
921 color: darkred;
922 font-weight: bold;
923 }
924 div.forumpost-closed-warning input[type=submit] {
925 padding: 0.25em;
 
 
 
 
926 }
927 .forum div > form {
928 margin: 0.5em 0;
 
929 }
930 .forum-post-collapser {
931 /* Common style for the bottom-of-post and right-of-post
932 expand/collapse widgets. */
933 font-size: 0.8em;
934
--- src/default.css
+++ src/default.css
@@ -910,24 +910,28 @@
910 content: "[CLOSED] ";
911 }
912 /*div.forumClosed > div.forumPostBody {
913 filter: blur(5px);
914 }*/
915 div.forumpost-closure-warning {
916 margin-top: 1em;
917 margin-bottom: 1em;
918 border-style: solid;
919 padding: 0.25em 0.5em;
920 background: #f4f400bb;
921 /*font-weight: bold;*/
 
922 }
923 div.forumpost-closure-warning input[type=submit] {
924 padding: 0.25em;
925 }
926 div.forumpost-single-controls {
927 /* UI controls along the bottom of a single post
928 ** in the thread view. */
929 }
930 .forum div > form {
931 margin: 0.5em 0;
932 display: inline-block;
933 }
934 .forum-post-collapser {
935 /* Common style for the bottom-of-post and right-of-post
936 expand/collapse widgets. */
937 font-size: 0.8em;
938
+23 -13
--- src/forum.c
+++ src/forum.c
@@ -277,18 +277,18 @@
277277
if( iHead != fpid ){
278278
iClosed = forum_rid_is_closed(iHead, 1);
279279
/*@ forumpost_emit_closed_state() %d(iHead), %d(iClosed)*/
280280
}
281281
if( iClosed<0 ){
282
- @ <div class="warning forumpost-closed-warning">\
282
+ @ <div class="warning forumpost-closure-warning">\
283283
@ This post is CLOSED via a parent post. %s(zCommon)\
284284
@ </div>
285285
return;
286286
}
287287
else if( iClosed==0 ){
288288
if( g.perm.Admin==0 ) return;
289
- @ <div class="warning forumpost-closed-warning">
289
+ @ <div class="warning forumpost-closure-warning">
290290
@ <form method="post" action="%R/forumpost_close">
291291
@ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
292292
@ <input type="submit" value="CLOSE this post and its responses" />
293293
@ %s(zCommon)
294294
@ </form></div>
@@ -295,16 +295,18 @@
295295
return;
296296
}
297297
assert( iClosed>0 );
298298
/* Only show the "unlock" checkbox on a post which is actually
299299
** closed, not on a post which inherits that state. */
300
- @ <div class="warning forumpost-closed-warning">\
300
+ @ <div class="warning forumpost-closure-warning">\
301301
@ This post is CLOSED. %s(zCommon)
302
- @ <form method="post" action="%R/forumpost_reopen">
303
- @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
304
- @ <input type="submit" value="Re-open this post and its responses" />
305
- @ </form>
302
+ if( g.perm.Admin ){
303
+ @ <form method="post" action="%R/forumpost_reopen">
304
+ @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
305
+ @ <input type="submit" value="Re-open this post and its responses" />
306
+ @ </form>
307
+ }
306308
@ </div>
307309
}
308310
309311
/*
310312
** Emits a warning that the current forum post is CLOSED and can only
@@ -823,11 +825,12 @@
823825
/* When not in raw mode, finish creating the border around the post. */
824826
if( !bRaw ){
825827
/* If the user is able to write to the forum and if this post has not been
826828
** edited, create a form with various interaction buttons. */
827829
if( g.perm.WrForum && !p->pEditTail ){
828
- @ <div><form action="%R/forumedit" method="POST">
830
+ @ <div class="forumpost-single-controls">\
831
+ @ <form action="%R/forumedit" method="POST">
829832
@ <input type="hidden" name="fpid" value="%s(p->zUuid)">
830833
if( !bPrivate ){
831834
/* Reply and Edit are only available if the post has been
832835
** approved. Closed threads can only be edited or replied to
833836
** by an admin but a user may delete their own posts even if
@@ -856,11 +859,20 @@
856859
}
857860
}else if( bSameUser ){
858861
/* Allow users to delete (reject) their own pending posts. */
859862
@ <input type="submit" name="reject" value="Delete">
860863
}
861
- @ </form></div>
864
+ @ </form>
865
+ if( bSelect && g.perm.Admin && iClosed>=0 ){
866
+ int iHead = forumpost_head_rid(p->fpid);
867
+ @ <form method="post" \
868
+ @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'>
869
+ @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
870
+ @ <input type="submit" value='%s(iClosed ? "Re-open" : "Close")' />
871
+ @ </form>
872
+ }
873
+ @ </div>
862874
}
863875
@ </div>
864876
}
865877
866878
/* Clean up. */
@@ -1351,13 +1363,11 @@
13511363
if( fpid<=0 ){
13521364
webpage_error("Missing or invalid fpid query parameter");
13531365
}
13541366
fClose = sqlite3_strglob("*_close*", g.zPath)==0;
13551367
if( fClose ) zReason = PD("reason",0);
1356
- if( forumpost_close(fpid, fClose, zReason)!=0 ){
1357
- admin_log("%s forum post %S", fClose ? "Close" : "Re-open", zFpid);
1358
- }
1368
+ forumpost_close(fpid, fClose, zReason);
13591369
cgi_redirectf("%R/forumpost/%S",zFpid);
13601370
return;
13611371
}
13621372
13631373
/*
@@ -1612,11 +1622,10 @@
16121622
}
16131623
style_header("Edit %s", zTitle ? "Post" : "Reply");
16141624
@ <h2>Original Post:</h2>
16151625
forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki,
16161626
"forumEdit", 1);
1617
- forumpost_emit_closed_state(fpid, iClosed);
16181627
if( bPreview ){
16191628
@ <h2>Preview of Edited Post:</h2>
16201629
forum_render(zTitle, zMimetype, zContent,"forumEdit", 1);
16211630
}
16221631
@ <h2>Revised Message:</h2>
@@ -1675,10 +1684,11 @@
16751684
@ Show query parameters</label>
16761685
@ </div>
16771686
}
16781687
@ </form>
16791688
forum_emit_js();
1689
+ forumpost_emit_closed_state(fpid, iClosed);
16801690
style_finish_page();
16811691
}
16821692
16831693
/*
16841694
** WEBPAGE: forummain
16851695
--- src/forum.c
+++ src/forum.c
@@ -277,18 +277,18 @@
277 if( iHead != fpid ){
278 iClosed = forum_rid_is_closed(iHead, 1);
279 /*@ forumpost_emit_closed_state() %d(iHead), %d(iClosed)*/
280 }
281 if( iClosed<0 ){
282 @ <div class="warning forumpost-closed-warning">\
283 @ This post is CLOSED via a parent post. %s(zCommon)\
284 @ </div>
285 return;
286 }
287 else if( iClosed==0 ){
288 if( g.perm.Admin==0 ) return;
289 @ <div class="warning forumpost-closed-warning">
290 @ <form method="post" action="%R/forumpost_close">
291 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
292 @ <input type="submit" value="CLOSE this post and its responses" />
293 @ %s(zCommon)
294 @ </form></div>
@@ -295,16 +295,18 @@
295 return;
296 }
297 assert( iClosed>0 );
298 /* Only show the "unlock" checkbox on a post which is actually
299 ** closed, not on a post which inherits that state. */
300 @ <div class="warning forumpost-closed-warning">\
301 @ This post is CLOSED. %s(zCommon)
302 @ <form method="post" action="%R/forumpost_reopen">
303 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
304 @ <input type="submit" value="Re-open this post and its responses" />
305 @ </form>
 
 
306 @ </div>
307 }
308
309 /*
310 ** Emits a warning that the current forum post is CLOSED and can only
@@ -823,11 +825,12 @@
823 /* When not in raw mode, finish creating the border around the post. */
824 if( !bRaw ){
825 /* If the user is able to write to the forum and if this post has not been
826 ** edited, create a form with various interaction buttons. */
827 if( g.perm.WrForum && !p->pEditTail ){
828 @ <div><form action="%R/forumedit" method="POST">
 
829 @ <input type="hidden" name="fpid" value="%s(p->zUuid)">
830 if( !bPrivate ){
831 /* Reply and Edit are only available if the post has been
832 ** approved. Closed threads can only be edited or replied to
833 ** by an admin but a user may delete their own posts even if
@@ -856,11 +859,20 @@
856 }
857 }else if( bSameUser ){
858 /* Allow users to delete (reject) their own pending posts. */
859 @ <input type="submit" name="reject" value="Delete">
860 }
861 @ </form></div>
 
 
 
 
 
 
 
 
 
862 }
863 @ </div>
864 }
865
866 /* Clean up. */
@@ -1351,13 +1363,11 @@
1351 if( fpid<=0 ){
1352 webpage_error("Missing or invalid fpid query parameter");
1353 }
1354 fClose = sqlite3_strglob("*_close*", g.zPath)==0;
1355 if( fClose ) zReason = PD("reason",0);
1356 if( forumpost_close(fpid, fClose, zReason)!=0 ){
1357 admin_log("%s forum post %S", fClose ? "Close" : "Re-open", zFpid);
1358 }
1359 cgi_redirectf("%R/forumpost/%S",zFpid);
1360 return;
1361 }
1362
1363 /*
@@ -1612,11 +1622,10 @@
1612 }
1613 style_header("Edit %s", zTitle ? "Post" : "Reply");
1614 @ <h2>Original Post:</h2>
1615 forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki,
1616 "forumEdit", 1);
1617 forumpost_emit_closed_state(fpid, iClosed);
1618 if( bPreview ){
1619 @ <h2>Preview of Edited Post:</h2>
1620 forum_render(zTitle, zMimetype, zContent,"forumEdit", 1);
1621 }
1622 @ <h2>Revised Message:</h2>
@@ -1675,10 +1684,11 @@
1675 @ Show query parameters</label>
1676 @ </div>
1677 }
1678 @ </form>
1679 forum_emit_js();
 
1680 style_finish_page();
1681 }
1682
1683 /*
1684 ** WEBPAGE: forummain
1685
--- src/forum.c
+++ src/forum.c
@@ -277,18 +277,18 @@
277 if( iHead != fpid ){
278 iClosed = forum_rid_is_closed(iHead, 1);
279 /*@ forumpost_emit_closed_state() %d(iHead), %d(iClosed)*/
280 }
281 if( iClosed<0 ){
282 @ <div class="warning forumpost-closure-warning">\
283 @ This post is CLOSED via a parent post. %s(zCommon)\
284 @ </div>
285 return;
286 }
287 else if( iClosed==0 ){
288 if( g.perm.Admin==0 ) return;
289 @ <div class="warning forumpost-closure-warning">
290 @ <form method="post" action="%R/forumpost_close">
291 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
292 @ <input type="submit" value="CLOSE this post and its responses" />
293 @ %s(zCommon)
294 @ </form></div>
@@ -295,16 +295,18 @@
295 return;
296 }
297 assert( iClosed>0 );
298 /* Only show the "unlock" checkbox on a post which is actually
299 ** closed, not on a post which inherits that state. */
300 @ <div class="warning forumpost-closure-warning">\
301 @ This post is CLOSED. %s(zCommon)
302 if( g.perm.Admin ){
303 @ <form method="post" action="%R/forumpost_reopen">
304 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
305 @ <input type="submit" value="Re-open this post and its responses" />
306 @ </form>
307 }
308 @ </div>
309 }
310
311 /*
312 ** Emits a warning that the current forum post is CLOSED and can only
@@ -823,11 +825,12 @@
825 /* When not in raw mode, finish creating the border around the post. */
826 if( !bRaw ){
827 /* If the user is able to write to the forum and if this post has not been
828 ** edited, create a form with various interaction buttons. */
829 if( g.perm.WrForum && !p->pEditTail ){
830 @ <div class="forumpost-single-controls">\
831 @ <form action="%R/forumedit" method="POST">
832 @ <input type="hidden" name="fpid" value="%s(p->zUuid)">
833 if( !bPrivate ){
834 /* Reply and Edit are only available if the post has been
835 ** approved. Closed threads can only be edited or replied to
836 ** by an admin but a user may delete their own posts even if
@@ -856,11 +859,20 @@
859 }
860 }else if( bSameUser ){
861 /* Allow users to delete (reject) their own pending posts. */
862 @ <input type="submit" name="reject" value="Delete">
863 }
864 @ </form>
865 if( bSelect && g.perm.Admin && iClosed>=0 ){
866 int iHead = forumpost_head_rid(p->fpid);
867 @ <form method="post" \
868 @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'>
869 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
870 @ <input type="submit" value='%s(iClosed ? "Re-open" : "Close")' />
871 @ </form>
872 }
873 @ </div>
874 }
875 @ </div>
876 }
877
878 /* Clean up. */
@@ -1351,13 +1363,11 @@
1363 if( fpid<=0 ){
1364 webpage_error("Missing or invalid fpid query parameter");
1365 }
1366 fClose = sqlite3_strglob("*_close*", g.zPath)==0;
1367 if( fClose ) zReason = PD("reason",0);
1368 forumpost_close(fpid, fClose, zReason);
 
 
1369 cgi_redirectf("%R/forumpost/%S",zFpid);
1370 return;
1371 }
1372
1373 /*
@@ -1612,11 +1622,10 @@
1622 }
1623 style_header("Edit %s", zTitle ? "Post" : "Reply");
1624 @ <h2>Original Post:</h2>
1625 forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki,
1626 "forumEdit", 1);
 
1627 if( bPreview ){
1628 @ <h2>Preview of Edited Post:</h2>
1629 forum_render(zTitle, zMimetype, zContent,"forumEdit", 1);
1630 }
1631 @ <h2>Revised Message:</h2>
@@ -1675,10 +1684,11 @@
1684 @ Show query parameters</label>
1685 @ </div>
1686 }
1687 @ </form>
1688 forum_emit_js();
1689 forumpost_emit_closed_state(fpid, iClosed);
1690 style_finish_page();
1691 }
1692
1693 /*
1694 ** WEBPAGE: forummain
1695

Keyboard Shortcuts

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