Fossil SCM

Admin users have a link in /forumthread to show the hash of all artifacts associated with that thread.

drh 2023-06-01 18:02 trunk
Commit 83928d8a02d86bca9dc433cea9e874896545916f741a895fbef87a936584f3b1
1 file changed +56
+56
--- src/forum.c
+++ src/forum.c
@@ -318,10 +318,63 @@
318318
fossil_print("%d\n", p->fpid);
319319
}
320320
}
321321
forumthread_delete(pThread);
322322
}
323
+
324
+/*
325
+** WEBPAGE: forumthreadhashlist
326
+**
327
+** Usage: /forumthreadhashlist/HASH-OF-ROOT
328
+**
329
+** This page (accessibly only to admins) shows a list of all artifacts
330
+** associated with a single forum thread. An admin might copy/paste this
331
+** list into the /shun page in order to shun an entire thread.
332
+*/
333
+void forumthreadhashlist(void){
334
+ int fpid;
335
+ int froot;
336
+ const char *zName = P("name");
337
+ ForumThread *pThread;
338
+ ForumPost *p;
339
+ char *fuuid;
340
+
341
+ login_check_credentials();
342
+ if( !g.perm.Admin ){
343
+ return;
344
+ }
345
+ if( zName==0 ){
346
+ webpage_error("Missing \"name=\" query parameter");
347
+ }
348
+ fpid = symbolic_name_to_rid(zName, "f");
349
+ if( fpid<=0 ){
350
+ if( fpid==0 ){
351
+ webpage_notfound_error("Unknown forum id: \"%s\"", zName);
352
+ }else{
353
+ ambiguous_page();
354
+ }
355
+ return;
356
+ }
357
+ froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
358
+ if( froot==0 ){
359
+ webpage_notfound_error("Not a forum post: \"%s\"", zName);
360
+ }
361
+ fuuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", froot);
362
+ style_set_current_feature("forum");
363
+ style_header("Artifacts Of Forum Thread");
364
+ @ <h2>
365
+ @ Artifacts associated with the forum thread
366
+ @ <a href="%R/forumthread/%S(fuuid)">%S(fuuid)</a>:</h2>
367
+ @ <pre>
368
+ pThread = forumthread_create(froot, 1);
369
+ for(p=pThread->pFirst; p; p=p->pNext){
370
+ @ %h(p->zUuid)
371
+ }
372
+ forumthread_delete(pThread);
373
+ @ </pre>
374
+ style_finish_page();
375
+}
323376
324377
/*
325378
** Render a forum post for display
326379
*/
327380
void forum_render(
@@ -914,10 +967,13 @@
914967
style_submenu_element("Hierarchical", "%R/%s/%s?t=h%s%s", g.zPath, zName,
915968
bUnf ? "&unf" : "", bHist ? "&hist" : "");
916969
}
917970
style_submenu_checkbox("unf", "Unformatted", 0, 0);
918971
style_submenu_checkbox("hist", "History", 0, 0);
972
+ if( g.perm.Admin ){
973
+ style_submenu_element("Artifacts", "%R/forumthreadhashlist/%t", zName);
974
+ }
919975
920976
/* Display the thread. */
921977
if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
922978
forum_display_thread(froot, fpid, mode, autoMode, bUnf, bHist);
923979
924980
--- src/forum.c
+++ src/forum.c
@@ -318,10 +318,63 @@
318 fossil_print("%d\n", p->fpid);
319 }
320 }
321 forumthread_delete(pThread);
322 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
324 /*
325 ** Render a forum post for display
326 */
327 void forum_render(
@@ -914,10 +967,13 @@
914 style_submenu_element("Hierarchical", "%R/%s/%s?t=h%s%s", g.zPath, zName,
915 bUnf ? "&unf" : "", bHist ? "&hist" : "");
916 }
917 style_submenu_checkbox("unf", "Unformatted", 0, 0);
918 style_submenu_checkbox("hist", "History", 0, 0);
 
 
 
919
920 /* Display the thread. */
921 if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
922 forum_display_thread(froot, fpid, mode, autoMode, bUnf, bHist);
923
924
--- src/forum.c
+++ src/forum.c
@@ -318,10 +318,63 @@
318 fossil_print("%d\n", p->fpid);
319 }
320 }
321 forumthread_delete(pThread);
322 }
323
324 /*
325 ** WEBPAGE: forumthreadhashlist
326 **
327 ** Usage: /forumthreadhashlist/HASH-OF-ROOT
328 **
329 ** This page (accessibly only to admins) shows a list of all artifacts
330 ** associated with a single forum thread. An admin might copy/paste this
331 ** list into the /shun page in order to shun an entire thread.
332 */
333 void forumthreadhashlist(void){
334 int fpid;
335 int froot;
336 const char *zName = P("name");
337 ForumThread *pThread;
338 ForumPost *p;
339 char *fuuid;
340
341 login_check_credentials();
342 if( !g.perm.Admin ){
343 return;
344 }
345 if( zName==0 ){
346 webpage_error("Missing \"name=\" query parameter");
347 }
348 fpid = symbolic_name_to_rid(zName, "f");
349 if( fpid<=0 ){
350 if( fpid==0 ){
351 webpage_notfound_error("Unknown forum id: \"%s\"", zName);
352 }else{
353 ambiguous_page();
354 }
355 return;
356 }
357 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
358 if( froot==0 ){
359 webpage_notfound_error("Not a forum post: \"%s\"", zName);
360 }
361 fuuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", froot);
362 style_set_current_feature("forum");
363 style_header("Artifacts Of Forum Thread");
364 @ <h2>
365 @ Artifacts associated with the forum thread
366 @ <a href="%R/forumthread/%S(fuuid)">%S(fuuid)</a>:</h2>
367 @ <pre>
368 pThread = forumthread_create(froot, 1);
369 for(p=pThread->pFirst; p; p=p->pNext){
370 @ %h(p->zUuid)
371 }
372 forumthread_delete(pThread);
373 @ </pre>
374 style_finish_page();
375 }
376
377 /*
378 ** Render a forum post for display
379 */
380 void forum_render(
@@ -914,10 +967,13 @@
967 style_submenu_element("Hierarchical", "%R/%s/%s?t=h%s%s", g.zPath, zName,
968 bUnf ? "&unf" : "", bHist ? "&hist" : "");
969 }
970 style_submenu_checkbox("unf", "Unformatted", 0, 0);
971 style_submenu_checkbox("hist", "History", 0, 0);
972 if( g.perm.Admin ){
973 style_submenu_element("Artifacts", "%R/forumthreadhashlist/%t", zName);
974 }
975
976 /* Display the thread. */
977 if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
978 forum_display_thread(froot, fpid, mode, autoMode, bUnf, bHist);
979
980

Keyboard Shortcuts

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