Fossil SCM

Cosmetic tweaks and docs in the forum attachments.

stephan 2026-05-24 13:05 UTC forum-attachments
Commit 129082a4850ccf9d81357ef6ad87b9bd641908dae403825e218148dacab63291
3 files changed +5 -6 +12 -2 +2 -2
+5 -6
--- src/attach.c
+++ src/attach.c
@@ -71,11 +71,12 @@
7171
** If none are given, all attachments are listed. If one is given, only
7272
** attachments for the designated technote, ticket or wiki page are shown.
7373
**
7474
** HASH may be just a prefix of the relevant technical note or ticket
7575
** artifact hash, in which case all attachments of all technical notes or
76
-** tickets with the prefix will be listed.
76
+** tickets with the prefix will be listed. Forum posts, on the other hand,
77
+** require a unique hash prefix.
7778
*/
7879
void attachlist_page(void){
7980
const char *zPage = P("page");
8081
const char *zTkt = P("tkt");
8182
const char *zTechNote = P("technote");
@@ -93,20 +94,18 @@
9394
" (SELECT uuid FROM blob WHERE rid=attachid), attachid"
9495
" FROM attachment"
9596
);
9697
if( zForumPost ){
9798
int fnid;
98
- char *zUuid;
9999
if( g.perm.RdForum==0 ){ login_needed(g.anon.RdForum); return; }
100
- style_header("Attachments To %h", zForumPost);
100
+ style_header("Attachments To Forum post %S", zForumPost);
101101
fnid = forumpost_head_rid2(zForumPost);
102102
if( fnid<=0 ){
103103
webpage_error("Invalid forum post ID: %h", zForumPost);
104104
}
105
- zUuid = rid_to_uuid(fnid);
106
- blob_append_sql(&sql, " WHERE target=%Q", zUuid);
107
- fossil_free(zUuid);
105
+ blob_append_sql(&sql, " WHERE target="
106
+ "(SELECT uuid FROM blob WHERE rid=%d)", fnid);
108107
}else if( zPage ){
109108
if( g.perm.RdWiki==0 ){ login_needed(g.anon.RdWiki); return; }
110109
style_header("Attachments To Wiki page %h", zPage);
111110
blob_append_sql(&sql, " WHERE target=%Q", zPage);
112111
}else if( zTkt ){
113112
--- src/attach.c
+++ src/attach.c
@@ -71,11 +71,12 @@
71 ** If none are given, all attachments are listed. If one is given, only
72 ** attachments for the designated technote, ticket or wiki page are shown.
73 **
74 ** HASH may be just a prefix of the relevant technical note or ticket
75 ** artifact hash, in which case all attachments of all technical notes or
76 ** tickets with the prefix will be listed.
 
77 */
78 void attachlist_page(void){
79 const char *zPage = P("page");
80 const char *zTkt = P("tkt");
81 const char *zTechNote = P("technote");
@@ -93,20 +94,18 @@
93 " (SELECT uuid FROM blob WHERE rid=attachid), attachid"
94 " FROM attachment"
95 );
96 if( zForumPost ){
97 int fnid;
98 char *zUuid;
99 if( g.perm.RdForum==0 ){ login_needed(g.anon.RdForum); return; }
100 style_header("Attachments To %h", zForumPost);
101 fnid = forumpost_head_rid2(zForumPost);
102 if( fnid<=0 ){
103 webpage_error("Invalid forum post ID: %h", zForumPost);
104 }
105 zUuid = rid_to_uuid(fnid);
106 blob_append_sql(&sql, " WHERE target=%Q", zUuid);
107 fossil_free(zUuid);
108 }else if( zPage ){
109 if( g.perm.RdWiki==0 ){ login_needed(g.anon.RdWiki); return; }
110 style_header("Attachments To Wiki page %h", zPage);
111 blob_append_sql(&sql, " WHERE target=%Q", zPage);
112 }else if( zTkt ){
113
--- src/attach.c
+++ src/attach.c
@@ -71,11 +71,12 @@
71 ** If none are given, all attachments are listed. If one is given, only
72 ** attachments for the designated technote, ticket or wiki page are shown.
73 **
74 ** HASH may be just a prefix of the relevant technical note or ticket
75 ** artifact hash, in which case all attachments of all technical notes or
76 ** tickets with the prefix will be listed. Forum posts, on the other hand,
77 ** require a unique hash prefix.
78 */
79 void attachlist_page(void){
80 const char *zPage = P("page");
81 const char *zTkt = P("tkt");
82 const char *zTechNote = P("technote");
@@ -93,20 +94,18 @@
94 " (SELECT uuid FROM blob WHERE rid=attachid), attachid"
95 " FROM attachment"
96 );
97 if( zForumPost ){
98 int fnid;
 
99 if( g.perm.RdForum==0 ){ login_needed(g.anon.RdForum); return; }
100 style_header("Attachments To Forum post %S", zForumPost);
101 fnid = forumpost_head_rid2(zForumPost);
102 if( fnid<=0 ){
103 webpage_error("Invalid forum post ID: %h", zForumPost);
104 }
105 blob_append_sql(&sql, " WHERE target="
106 "(SELECT uuid FROM blob WHERE rid=%d)", fnid);
 
107 }else if( zPage ){
108 if( g.perm.RdWiki==0 ){ login_needed(g.anon.RdWiki); return; }
109 style_header("Attachments To Wiki page %h", zPage);
110 blob_append_sql(&sql, " WHERE target=%Q", zPage);
111 }else if( zTkt ){
112
+12 -2
--- src/forum.c
+++ src/forum.c
@@ -836,14 +836,24 @@
836836
if( pToFree ) manifest_destroy(pToFree);
837837
if( p->zDisplayName==0 ) return "(unknown)";
838838
return p->zDisplayName;
839839
}
840840
841
+/*
842
+** Renders the attachment list for p or (if not NULL) pEditHead.
843
+** Emits no output if there are no attachments.
844
+*/
841845
static void forum_render_attachment_list(ForumPost *p){
846
+ char * zLbl;
842847
if( p->pEditHead ) p = p->pEditHead;
843
- attachment_list(p->zUuid, "Attachments:",
844
- ATTACHLIST_SIZE | ATTACHLIST_HIDE_UNAPPROVED);
848
+ zLbl = mprintf("<a href='%R/attachlist?forumpost=%s'>"
849
+ "Attachments:</a>", p->zUuid);
850
+ attachment_list(p->zUuid, zLbl,
851
+ ATTACHLIST_HRULE_ABOVE
852
+ | ATTACHLIST_SIZE
853
+ | ATTACHLIST_HIDE_UNAPPROVED);
854
+ fossil_free(zLbl);
845855
}
846856
847857
/*
848858
** Display a single post in a forum thread.
849859
*/
850860
--- src/forum.c
+++ src/forum.c
@@ -836,14 +836,24 @@
836 if( pToFree ) manifest_destroy(pToFree);
837 if( p->zDisplayName==0 ) return "(unknown)";
838 return p->zDisplayName;
839 }
840
 
 
 
 
841 static void forum_render_attachment_list(ForumPost *p){
 
842 if( p->pEditHead ) p = p->pEditHead;
843 attachment_list(p->zUuid, "Attachments:",
844 ATTACHLIST_SIZE | ATTACHLIST_HIDE_UNAPPROVED);
 
 
 
 
 
845 }
846
847 /*
848 ** Display a single post in a forum thread.
849 */
850
--- src/forum.c
+++ src/forum.c
@@ -836,14 +836,24 @@
836 if( pToFree ) manifest_destroy(pToFree);
837 if( p->zDisplayName==0 ) return "(unknown)";
838 return p->zDisplayName;
839 }
840
841 /*
842 ** Renders the attachment list for p or (if not NULL) pEditHead.
843 ** Emits no output if there are no attachments.
844 */
845 static void forum_render_attachment_list(ForumPost *p){
846 char * zLbl;
847 if( p->pEditHead ) p = p->pEditHead;
848 zLbl = mprintf("<a href='%R/attachlist?forumpost=%s'>"
849 "Attachments:</a>", p->zUuid);
850 attachment_list(p->zUuid, zLbl,
851 ATTACHLIST_HRULE_ABOVE
852 | ATTACHLIST_SIZE
853 | ATTACHLIST_HIDE_UNAPPROVED);
854 fossil_free(zLbl);
855 }
856
857 /*
858 ** Display a single post in a forum thread.
859 */
860
+2 -2
--- src/moderate.c
+++ src/moderate.c
@@ -278,12 +278,12 @@
278278
** not a moderator, may moderate it. i.e. a non-moderator owner can
279279
** reject their pending-moderation objects but they may not approve
280280
** them.
281281
**
282282
** - Returns 0 for all other artifact types except that it will always
283
-** return true for admins because that's that check skips looking at
284
-** the db.
283
+** return true for admins because that check skips looking at the
284
+** db.
285285
**
286286
*/
287287
int moderation_user_could(int rid, int bMayDeny, const char *zWho){
288288
static Stmt q;
289289
int rc = 0;
290290
--- src/moderate.c
+++ src/moderate.c
@@ -278,12 +278,12 @@
278 ** not a moderator, may moderate it. i.e. a non-moderator owner can
279 ** reject their pending-moderation objects but they may not approve
280 ** them.
281 **
282 ** - Returns 0 for all other artifact types except that it will always
283 ** return true for admins because that's that check skips looking at
284 ** the db.
285 **
286 */
287 int moderation_user_could(int rid, int bMayDeny, const char *zWho){
288 static Stmt q;
289 int rc = 0;
290
--- src/moderate.c
+++ src/moderate.c
@@ -278,12 +278,12 @@
278 ** not a moderator, may moderate it. i.e. a non-moderator owner can
279 ** reject their pending-moderation objects but they may not approve
280 ** them.
281 **
282 ** - Returns 0 for all other artifact types except that it will always
283 ** return true for admins because that check skips looking at the
284 ** db.
285 **
286 */
287 int moderation_user_could(int rid, int bMayDeny, const char *zWho){
288 static Stmt q;
289 int rc = 0;
290

Keyboard Shortcuts

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