Fossil SCM

Show the attachment list at the bottom of the forum post edit page. Fix a missing void in a function signature.

stephan 2026-05-25 07:43 UTC forum-attachments
Commit 22bc6d7a2a2897af16454dbf0425c204bc1d53c2307b826019f474ce9d7f031a
1 file changed +19 -10
+19 -10
--- src/forum.c
+++ src/forum.c
@@ -842,24 +842,30 @@
842842
if( p->zDisplayName==0 ) return "(unknown)";
843843
return p->zDisplayName;
844844
}
845845
846846
/*
847
-** Renders the attachment list for p or (if not NULL) pEditHead.
847
+** Renders the attachment list for the given forum post.
848848
** Emits no output if there are no attachments.
849849
*/
850
-static void forum_render_attachment_list(ForumPost *p){
851
- char * zLbl;
852
- if( p->pEditHead ) p = p->pEditHead;
853
- zLbl = mprintf("<a href='%R/attachlist?forumpost=%s'>"
854
- "Attachments:</a>", p->zUuid);
855
- attachment_list(p->zUuid, zLbl,
850
+static void forum_render_attachment_list(const char *zUuid){
851
+ char * zLbl = mprintf("<a href='%R/attachlist?forumpost=%s'>"
852
+ "Attachments:</a>", zUuid);
853
+ attachment_list(zUuid, zLbl,
856854
ATTACHLIST_HRULE_ABOVE
857855
| ATTACHLIST_SIZE
858856
| ATTACHLIST_HIDE_UNAPPROVED);
859857
fossil_free(zLbl);
860858
}
859
+
860
+/*
861
+** Renders the attachment list for p or (if not NULL) pEditHead.
862
+*/
863
+static void forum_render_attachment_list2(ForumPost *p){
864
+ if( p->pEditHead ) p = p->pEditHead;
865
+ forum_render_attachment_list(p->zUuid);
866
+}
861867
862868
/*
863869
** Display a single post in a forum thread.
864870
*/
865871
static void forum_display_post(
@@ -1001,11 +1007,11 @@
10011007
zMimetype = "text/plain";
10021008
}else{
10031009
zMimetype = pManifest->zMimetype;
10041010
}
10051011
forum_render(0, zMimetype, pManifest->zWiki, 0, !bRaw);
1006
- forum_render_attachment_list(p);
1012
+ forum_render_attachment_list2(p);
10071013
}
10081014
10091015
/* When not in raw mode, finish creating the border around the post. */
10101016
if( !bRaw ){
10111017
/* If the user is able to write to the forum and if this post has not been
@@ -1696,11 +1702,11 @@
16961702
/*
16971703
** If the user has AttachForum permissions, emit a notice that
16981704
** attachments may be added after saving. If p is not NULL,
16991705
** also emit its list of attachments.
17001706
*/
1701
-static void forum_render_attachment_notice(){
1707
+static void forum_render_attachment_notice(void){
17021708
if( g.perm.AttachForum ){
17031709
@ <div>You will be able to attach files to this post after saving
17041710
@ it.</div>
17051711
}
17061712
}
@@ -1741,11 +1747,11 @@
17411747
@ <input type="submit" name="submit" value="Submit" disabled>
17421748
}
17431749
forum_render_debug_options();
17441750
login_insert_csrf_secret();
17451751
@ </form>
1746
- forum_render_attachment_notice(0);
1752
+ forum_render_attachment_notice();
17471753
forum_emit_js();
17481754
style_finish_page();
17491755
}
17501756
17511757
/*
@@ -1935,10 +1941,13 @@
19351941
}
19361942
}
19371943
forum_render_debug_options();
19381944
login_insert_csrf_secret();
19391945
@ </form>
1946
+ if( !bReply ){
1947
+ forum_render_attachment_list(rid_to_uuid(fpid));
1948
+ }
19401949
forum_render_attachment_notice();
19411950
forum_emit_js();
19421951
style_finish_page();
19431952
}
19441953
19451954
--- src/forum.c
+++ src/forum.c
@@ -842,24 +842,30 @@
842 if( p->zDisplayName==0 ) return "(unknown)";
843 return p->zDisplayName;
844 }
845
846 /*
847 ** Renders the attachment list for p or (if not NULL) pEditHead.
848 ** Emits no output if there are no attachments.
849 */
850 static void forum_render_attachment_list(ForumPost *p){
851 char * zLbl;
852 if( p->pEditHead ) p = p->pEditHead;
853 zLbl = mprintf("<a href='%R/attachlist?forumpost=%s'>"
854 "Attachments:</a>", p->zUuid);
855 attachment_list(p->zUuid, zLbl,
856 ATTACHLIST_HRULE_ABOVE
857 | ATTACHLIST_SIZE
858 | ATTACHLIST_HIDE_UNAPPROVED);
859 fossil_free(zLbl);
860 }
 
 
 
 
 
 
 
 
861
862 /*
863 ** Display a single post in a forum thread.
864 */
865 static void forum_display_post(
@@ -1001,11 +1007,11 @@
1001 zMimetype = "text/plain";
1002 }else{
1003 zMimetype = pManifest->zMimetype;
1004 }
1005 forum_render(0, zMimetype, pManifest->zWiki, 0, !bRaw);
1006 forum_render_attachment_list(p);
1007 }
1008
1009 /* When not in raw mode, finish creating the border around the post. */
1010 if( !bRaw ){
1011 /* If the user is able to write to the forum and if this post has not been
@@ -1696,11 +1702,11 @@
1696 /*
1697 ** If the user has AttachForum permissions, emit a notice that
1698 ** attachments may be added after saving. If p is not NULL,
1699 ** also emit its list of attachments.
1700 */
1701 static void forum_render_attachment_notice(){
1702 if( g.perm.AttachForum ){
1703 @ <div>You will be able to attach files to this post after saving
1704 @ it.</div>
1705 }
1706 }
@@ -1741,11 +1747,11 @@
1741 @ <input type="submit" name="submit" value="Submit" disabled>
1742 }
1743 forum_render_debug_options();
1744 login_insert_csrf_secret();
1745 @ </form>
1746 forum_render_attachment_notice(0);
1747 forum_emit_js();
1748 style_finish_page();
1749 }
1750
1751 /*
@@ -1935,10 +1941,13 @@
1935 }
1936 }
1937 forum_render_debug_options();
1938 login_insert_csrf_secret();
1939 @ </form>
 
 
 
1940 forum_render_attachment_notice();
1941 forum_emit_js();
1942 style_finish_page();
1943 }
1944
1945
--- src/forum.c
+++ src/forum.c
@@ -842,24 +842,30 @@
842 if( p->zDisplayName==0 ) return "(unknown)";
843 return p->zDisplayName;
844 }
845
846 /*
847 ** Renders the attachment list for the given forum post.
848 ** Emits no output if there are no attachments.
849 */
850 static void forum_render_attachment_list(const char *zUuid){
851 char * zLbl = mprintf("<a href='%R/attachlist?forumpost=%s'>"
852 "Attachments:</a>", zUuid);
853 attachment_list(zUuid, zLbl,
 
 
854 ATTACHLIST_HRULE_ABOVE
855 | ATTACHLIST_SIZE
856 | ATTACHLIST_HIDE_UNAPPROVED);
857 fossil_free(zLbl);
858 }
859
860 /*
861 ** Renders the attachment list for p or (if not NULL) pEditHead.
862 */
863 static void forum_render_attachment_list2(ForumPost *p){
864 if( p->pEditHead ) p = p->pEditHead;
865 forum_render_attachment_list(p->zUuid);
866 }
867
868 /*
869 ** Display a single post in a forum thread.
870 */
871 static void forum_display_post(
@@ -1001,11 +1007,11 @@
1007 zMimetype = "text/plain";
1008 }else{
1009 zMimetype = pManifest->zMimetype;
1010 }
1011 forum_render(0, zMimetype, pManifest->zWiki, 0, !bRaw);
1012 forum_render_attachment_list2(p);
1013 }
1014
1015 /* When not in raw mode, finish creating the border around the post. */
1016 if( !bRaw ){
1017 /* If the user is able to write to the forum and if this post has not been
@@ -1696,11 +1702,11 @@
1702 /*
1703 ** If the user has AttachForum permissions, emit a notice that
1704 ** attachments may be added after saving. If p is not NULL,
1705 ** also emit its list of attachments.
1706 */
1707 static void forum_render_attachment_notice(void){
1708 if( g.perm.AttachForum ){
1709 @ <div>You will be able to attach files to this post after saving
1710 @ it.</div>
1711 }
1712 }
@@ -1741,11 +1747,11 @@
1747 @ <input type="submit" name="submit" value="Submit" disabled>
1748 }
1749 forum_render_debug_options();
1750 login_insert_csrf_secret();
1751 @ </form>
1752 forum_render_attachment_notice();
1753 forum_emit_js();
1754 style_finish_page();
1755 }
1756
1757 /*
@@ -1935,10 +1941,13 @@
1941 }
1942 }
1943 forum_render_debug_options();
1944 login_insert_csrf_secret();
1945 @ </form>
1946 if( !bReply ){
1947 forum_render_attachment_list(rid_to_uuid(fpid));
1948 }
1949 forum_render_attachment_notice();
1950 forum_emit_js();
1951 style_finish_page();
1952 }
1953
1954

Keyboard Shortcuts

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