Fossil

Check-in [ecc324b6af]
Login

Check-in [ecc324b6af]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | forumpost-locking
Files: files | file ages | folders
SHA3-256: ecc324b6af5d1e2142c558a42597246bfa7d1c36502bb69cee1a7967ffc9bdf8
User & Date: stephan 2023-02-24 23:39:25.115
Context
2023-03-02
17:13
Merge trunk into forumpost-locking branch. ... (check-in: 27c3423e89 user: stephan tags: forumpost-locking)
2023-02-24
23:39
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. ... (check-in: ecc324b6af user: stephan tags: forumpost-locking)
23:38
In /admin_log, add rowid DESC to the ORDER BY so that entries with the same timestamp predictably sort newest-first. ... (check-in: 914c6b5a0e user: stephan tags: forumpost-locking)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/default.css.
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925




926
927
928

929
930
931
932
933
934
935
}
div.forumClosed > .forumPostHdr::before {
  content: "[CLOSED] ";
}
/*div.forumClosed > div.forumPostBody {
  filter: blur(5px);
}*/
div.forumpost-closed-warning {
  margin-top: 1em;
  margin-bottom: 1em;
  border-style: solid;
  padding: 0.25em 0.5em;
  background: yellow;
  color: darkred;
  font-weight: bold;
}
div.forumpost-closed-warning input[type=submit] {
  padding: 0.25em;




}
.forum div > form {
  margin: 0.5em 0;

}
.forum-post-collapser {
  /* Common style for the bottom-of-post and right-of-post
     expand/collapse widgets. */
  font-size: 0.8em;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.2);







|




|
<
|

|

>
>
>
>



>







908
909
910
911
912
913
914
915
916
917
918
919
920

921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
}
div.forumClosed > .forumPostHdr::before {
  content: "[CLOSED] ";
}
/*div.forumClosed > div.forumPostBody {
  filter: blur(5px);
}*/
div.forumpost-closure-warning {
  margin-top: 1em;
  margin-bottom: 1em;
  border-style: solid;
  padding: 0.25em 0.5em;
  background: #f4f400bb;

  /*font-weight: bold;*/
}
div.forumpost-closure-warning input[type=submit] {
  padding: 0.25em;
}
div.forumpost-single-controls {
  /* UI controls along the bottom of a single post
  ** in the thread view. */
}
.forum div > form {
  margin: 0.5em 0;
  display: inline-block;
}
.forum-post-collapser {
  /* Common style for the bottom-of-post and right-of-post
     expand/collapse widgets. */
  font-size: 0.8em;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
Changes to src/forum.c.
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301

302
303
304
305

306
307
308
309
310
311
312
  int iHead = forumpost_head_rid(fpid);
  /*@ forumpost_emit_closed_state(%d(fpid), %d(iClosed))<br/>*/
  if( iHead != fpid ){
    iClosed = forum_rid_is_closed(iHead, 1);
    /*@ forumpost_emit_closed_state() %d(iHead), %d(iClosed)*/
  }
  if( iClosed<0 ){
    @ <div class="warning forumpost-closed-warning">\
    @ This post is CLOSED via a parent post. %s(zCommon)\
    @ </div>
    return;
  }
  else if( iClosed==0 ){
    if( g.perm.Admin==0 ) return;
    @ <div class="warning forumpost-closed-warning">
    @ <form method="post" action="%R/forumpost_close">
    @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
    @ <input type="submit" value="CLOSE this post and its responses" />
    @ %s(zCommon)
    @ </form></div>
    return;
  }
  assert( iClosed>0 );
  /* Only show the "unlock" checkbox on a post which is actually
  ** closed, not on a post which inherits that state. */
  @ <div class="warning forumpost-closed-warning">\
  @ This post is CLOSED. %s(zCommon)

  @ <form method="post" action="%R/forumpost_reopen">
  @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
  @ <input type="submit" value="Re-open this post and its responses" />
  @ </form>

  @ </div>
}

/*
** Emits a warning that the current forum post is CLOSED and can only
** be edited or responded to by an administrator. */
static void forumpost_error_closed(void){







|






|










|

>
|
|
|
|
>







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
  int iHead = forumpost_head_rid(fpid);
  /*@ forumpost_emit_closed_state(%d(fpid), %d(iClosed))<br/>*/
  if( iHead != fpid ){
    iClosed = forum_rid_is_closed(iHead, 1);
    /*@ forumpost_emit_closed_state() %d(iHead), %d(iClosed)*/
  }
  if( iClosed<0 ){
    @ <div class="warning forumpost-closure-warning">\
    @ This post is CLOSED via a parent post. %s(zCommon)\
    @ </div>
    return;
  }
  else if( iClosed==0 ){
    if( g.perm.Admin==0 ) return;
    @ <div class="warning forumpost-closure-warning">
    @ <form method="post" action="%R/forumpost_close">
    @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
    @ <input type="submit" value="CLOSE this post and its responses" />
    @ %s(zCommon)
    @ </form></div>
    return;
  }
  assert( iClosed>0 );
  /* Only show the "unlock" checkbox on a post which is actually
  ** closed, not on a post which inherits that state. */
  @ <div class="warning forumpost-closure-warning">\
  @ This post is CLOSED. %s(zCommon)
  if( g.perm.Admin ){
    @ <form method="post" action="%R/forumpost_reopen">
    @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
    @ <input type="submit" value="Re-open this post and its responses" />
    @ </form>
  }
  @ </div>
}

/*
** Emits a warning that the current forum post is CLOSED and can only
** be edited or responded to by an administrator. */
static void forumpost_error_closed(void){
821
822
823
824
825
826
827

828
829
830
831
832
833
834
835
  }

  /* When not in raw mode, finish creating the border around the post. */
  if( !bRaw ){
    /* If the user is able to write to the forum and if this post has not been
    ** edited, create a form with various interaction buttons. */
    if( g.perm.WrForum && !p->pEditTail ){

      @ <div><form action="%R/forumedit" method="POST">
      @ <input type="hidden" name="fpid" value="%s(p->zUuid)">
      if( !bPrivate ){
        /* Reply and Edit are only available if the post has been
        ** approved.  Closed threads can only be edited or replied to
        ** by an admin but a user may delete their own posts even if
        ** they are closed. */
        if( g.perm.Admin || !iClosed ){







>
|







823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
  }

  /* When not in raw mode, finish creating the border around the post. */
  if( !bRaw ){
    /* If the user is able to write to the forum and if this post has not been
    ** edited, create a form with various interaction buttons. */
    if( g.perm.WrForum && !p->pEditTail ){
      @ <div class="forumpost-single-controls">\
      @ <form action="%R/forumedit" method="POST">
      @ <input type="hidden" name="fpid" value="%s(p->zUuid)">
      if( !bPrivate ){
        /* Reply and Edit are only available if the post has been
        ** approved.  Closed threads can only be edited or replied to
        ** by an admin but a user may delete their own posts even if
        ** they are closed. */
        if( g.perm.Admin || !iClosed ){
854
855
856
857
858
859
860
861









862
863
864
865
866
867
868
          @ </label>
          @ <input type="hidden" name="trustuser" value="%h(pManifest->zUser)">
        }
      }else if( bSameUser ){
        /* Allow users to delete (reject) their own pending posts. */
        @ <input type="submit" name="reject" value="Delete">
      }
      @ </form></div>









    }
    @ </div>
  }

  /* Clean up. */
  manifest_destroy(pManifest);
}







|
>
>
>
>
>
>
>
>
>







857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
          @ </label>
          @ <input type="hidden" name="trustuser" value="%h(pManifest->zUser)">
        }
      }else if( bSameUser ){
        /* Allow users to delete (reject) their own pending posts. */
        @ <input type="submit" name="reject" value="Delete">
      }
      @ </form>
      if( bSelect && g.perm.Admin && iClosed>=0 ){
        int iHead = forumpost_head_rid(p->fpid);
        @ <form method="post" \
        @  action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'>
        @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
        @ <input type="submit" value='%s(iClosed ? "Re-open" : "Close")' />
        @ </form>
      }
      @ </div>
    }
    @ </div>
  }

  /* Clean up. */
  manifest_destroy(pManifest);
}
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
  }
  fpid = symbolic_name_to_rid(zFpid, "f");
  if( fpid<=0 ){
    webpage_error("Missing or invalid fpid query parameter");
  }
  fClose = sqlite3_strglob("*_close*", g.zPath)==0;
  if( fClose ) zReason = PD("reason",0);
  if( forumpost_close(fpid, fClose, zReason)!=0 ){
    admin_log("%s forum post %S", fClose ? "Close" : "Re-open", zFpid);
  }
  cgi_redirectf("%R/forumpost/%S",zFpid);
  return;
}

/*
** WEBPAGE: forumnew
** WEBPAGE: forumedit







|
<
<







1361
1362
1363
1364
1365
1366
1367
1368


1369
1370
1371
1372
1373
1374
1375
  }
  fpid = symbolic_name_to_rid(zFpid, "f");
  if( fpid<=0 ){
    webpage_error("Missing or invalid fpid query parameter");
  }
  fClose = sqlite3_strglob("*_close*", g.zPath)==0;
  if( fClose ) zReason = PD("reason",0);
  forumpost_close(fpid, fClose, zReason);


  cgi_redirectf("%R/forumpost/%S",zFpid);
  return;
}

/*
** WEBPAGE: forumnew
** WEBPAGE: forumedit
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
    if( zTitle==0 && pPost->zThreadTitle!=0 ){
      zTitle = fossil_strdup(pPost->zThreadTitle);
    }
    style_header("Edit %s", zTitle ? "Post" : "Reply");
    @ <h2>Original Post:</h2>
    forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki,
                 "forumEdit", 1);
    forumpost_emit_closed_state(fpid, iClosed);
    if( bPreview ){
      @ <h2>Preview of Edited Post:</h2>
      forum_render(zTitle, zMimetype, zContent,"forumEdit", 1);
    }
    @ <h2>Revised Message:</h2>
    @ <form action="%R/forume2" method="POST">
    @ <input type="hidden" name="fpid" value="%h(P("fpid"))">







<







1620
1621
1622
1623
1624
1625
1626

1627
1628
1629
1630
1631
1632
1633
    if( zTitle==0 && pPost->zThreadTitle!=0 ){
      zTitle = fossil_strdup(pPost->zThreadTitle);
    }
    style_header("Edit %s", zTitle ? "Post" : "Reply");
    @ <h2>Original Post:</h2>
    forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki,
                 "forumEdit", 1);

    if( bPreview ){
      @ <h2>Preview of Edited Post:</h2>
      forum_render(zTitle, zMimetype, zContent,"forumEdit", 1);
    }
    @ <h2>Revised Message:</h2>
    @ <form action="%R/forume2" method="POST">
    @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
1673
1674
1675
1676
1677
1678
1679

1680
1681
1682
1683
1684
1685
1686
    @ Require moderator approval</label>
    @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
    @ Show query parameters</label>
    @ </div>
  }
  @ </form>
  forum_emit_js();

  style_finish_page();
}

/*
** WEBPAGE: forummain
** WEBPAGE: forum
**







>







1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
    @ Require moderator approval</label>
    @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
    @ Show query parameters</label>
    @ </div>
  }
  @ </form>
  forum_emit_js();
  forumpost_emit_closed_state(fpid, iClosed);
  style_finish_page();
}

/*
** WEBPAGE: forummain
** WEBPAGE: forum
**