Fossil SCM
Add an Attach button to the currently-selected forum post if the user is an admin or the owner of the post. Make some use of ForumPost::pEditHead to save a query.
Commit
b3c9af20921ee19b41ad6136108573c28884d4a8d4e1da80d886094edc66a3f2
Parent
c3bb903212a5fb6…
1 file changed
+22
-13
+22
-13
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -779,12 +779,12 @@ | ||
| 779 | 779 | if( p->zDisplayName==0 ) return "(unknown)"; |
| 780 | 780 | return p->zDisplayName; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | static void forum_render_attachment_list(ForumPost *p){ |
| 784 | - while( p->pEditPrev ) p = p->pEditPrev; | |
| 785 | - attachment_list(p->zUuid, "Attachments", 1); | |
| 784 | + if( p->pEditHead ) p = p->pEditHead; | |
| 785 | + attachment_list(p->zUuid, "Attachments:", 1); | |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | /* |
| 789 | 789 | ** Display a single post in a forum thread. |
| 790 | 790 | */ |
| @@ -971,21 +971,30 @@ | ||
| 971 | 971 | /* Allow users to delete (reject) their own pending posts. */ |
| 972 | 972 | @ <input type="submit" name="reject" value="Delete"> |
| 973 | 973 | } |
| 974 | 974 | login_insert_csrf_secret(); |
| 975 | 975 | @ </form> |
| 976 | - if( bSelect && forumpost_may_close() && iClosed>=0 ){ | |
| 977 | - int iHead = forumpost_head_rid(p->fpid); | |
| 978 | - @ <form method="post" \ | |
| 979 | - @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'> | |
| 980 | - login_insert_csrf_secret(); | |
| 981 | - @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" /> | |
| 982 | - if( moderation_pending(p->fpid)==0 ){ | |
| 983 | - @ <input type="button" value='%s(iClosed ? "Re-open" : "Close")' \ | |
| 984 | - @ class='%s(iClosed ? "action-reopen" : "action-close")'/> | |
| 985 | - } | |
| 986 | - @ </form> | |
| 976 | + | |
| 977 | + if( bSelect ){ | |
| 978 | + ForumPost *pHead = p->pEditHead ? p->pEditHead : p; | |
| 979 | + if( forumpost_may_close() && iClosed>=0 ){ | |
| 980 | + @ <form method="post" \ | |
| 981 | + @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'> | |
| 982 | + login_insert_csrf_secret(); | |
| 983 | + @ <input type="hidden" name="fpid" value="%s(pHead->zUuid)" /> | |
| 984 | + if( moderation_pending(p->fpid)==0 ){ | |
| 985 | + @ <input type="button" value='%s(iClosed ? "Re-open" : "Close")' \ | |
| 986 | + @ class='%s(iClosed ? "action-reopen" : "action-close")'/> | |
| 987 | + } | |
| 988 | + @ </form> | |
| 989 | + } | |
| 990 | + if( g.perm.Admin || forumpost_is_owner(p/*not pHead*/->fpid, 0) ){ | |
| 991 | + @ <form method="post" action="%R/attachadd">\ | |
| 992 | + @ <input type="hidden" name="forumpost" value="%T(pHead->zUuid)"> | |
| 993 | + @ <input type="submit" value="Attach..."> | |
| 994 | + @ </form> | |
| 995 | + } | |
| 987 | 996 | } |
| 988 | 997 | @ </div> |
| 989 | 998 | } |
| 990 | 999 | @ </div> |
| 991 | 1000 | } |
| 992 | 1001 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -779,12 +779,12 @@ | |
| 779 | if( p->zDisplayName==0 ) return "(unknown)"; |
| 780 | return p->zDisplayName; |
| 781 | } |
| 782 | |
| 783 | static void forum_render_attachment_list(ForumPost *p){ |
| 784 | while( p->pEditPrev ) p = p->pEditPrev; |
| 785 | attachment_list(p->zUuid, "Attachments", 1); |
| 786 | } |
| 787 | |
| 788 | /* |
| 789 | ** Display a single post in a forum thread. |
| 790 | */ |
| @@ -971,21 +971,30 @@ | |
| 971 | /* Allow users to delete (reject) their own pending posts. */ |
| 972 | @ <input type="submit" name="reject" value="Delete"> |
| 973 | } |
| 974 | login_insert_csrf_secret(); |
| 975 | @ </form> |
| 976 | if( bSelect && forumpost_may_close() && iClosed>=0 ){ |
| 977 | int iHead = forumpost_head_rid(p->fpid); |
| 978 | @ <form method="post" \ |
| 979 | @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'> |
| 980 | login_insert_csrf_secret(); |
| 981 | @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" /> |
| 982 | if( moderation_pending(p->fpid)==0 ){ |
| 983 | @ <input type="button" value='%s(iClosed ? "Re-open" : "Close")' \ |
| 984 | @ class='%s(iClosed ? "action-reopen" : "action-close")'/> |
| 985 | } |
| 986 | @ </form> |
| 987 | } |
| 988 | @ </div> |
| 989 | } |
| 990 | @ </div> |
| 991 | } |
| 992 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -779,12 +779,12 @@ | |
| 779 | if( p->zDisplayName==0 ) return "(unknown)"; |
| 780 | return p->zDisplayName; |
| 781 | } |
| 782 | |
| 783 | static void forum_render_attachment_list(ForumPost *p){ |
| 784 | if( p->pEditHead ) p = p->pEditHead; |
| 785 | attachment_list(p->zUuid, "Attachments:", 1); |
| 786 | } |
| 787 | |
| 788 | /* |
| 789 | ** Display a single post in a forum thread. |
| 790 | */ |
| @@ -971,21 +971,30 @@ | |
| 971 | /* Allow users to delete (reject) their own pending posts. */ |
| 972 | @ <input type="submit" name="reject" value="Delete"> |
| 973 | } |
| 974 | login_insert_csrf_secret(); |
| 975 | @ </form> |
| 976 | |
| 977 | if( bSelect ){ |
| 978 | ForumPost *pHead = p->pEditHead ? p->pEditHead : p; |
| 979 | if( forumpost_may_close() && iClosed>=0 ){ |
| 980 | @ <form method="post" \ |
| 981 | @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'> |
| 982 | login_insert_csrf_secret(); |
| 983 | @ <input type="hidden" name="fpid" value="%s(pHead->zUuid)" /> |
| 984 | if( moderation_pending(p->fpid)==0 ){ |
| 985 | @ <input type="button" value='%s(iClosed ? "Re-open" : "Close")' \ |
| 986 | @ class='%s(iClosed ? "action-reopen" : "action-close")'/> |
| 987 | } |
| 988 | @ </form> |
| 989 | } |
| 990 | if( g.perm.Admin || forumpost_is_owner(p/*not pHead*/->fpid, 0) ){ |
| 991 | @ <form method="post" action="%R/attachadd">\ |
| 992 | @ <input type="hidden" name="forumpost" value="%T(pHead->zUuid)"> |
| 993 | @ <input type="submit" value="Attach..."> |
| 994 | @ </form> |
| 995 | } |
| 996 | } |
| 997 | @ </div> |
| 998 | } |
| 999 | @ </div> |
| 1000 | } |
| 1001 |