Fossil SCM

Fix the redirect that occurs after a forum post is rejected by the moderator.

drh 2018-07-31 15:49 forum-v2
Commit 6a667edb0964140c1be60ef1d6bbcfff32a2d4258d98ff9c1be66e878234f082
1 file changed +12 -3
+12 -3
--- src/forum.c
+++ src/forum.c
@@ -373,11 +373,11 @@
373373
zUuid = p->zUuid;
374374
pPost = pOPost;
375375
}
376376
zSel = p->fpid==target ? " forumSel" : "";
377377
if( p->nIndent==1 ){
378
- @ <div id='forum(%d(fpid)' class='forumHierRoot%s(zSel)'>
378
+ @ <div id='forum%d(fpid)' class='forumHierRoot%s(zSel)'>
379379
}else{
380380
@ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \
381381
@ style='margin-left: %d((p->nIndent-1)*3)ex;'>
382382
}
383383
pPost = manifest_get(fpid, CFTYPE_FORUM, 0);
@@ -783,12 +783,22 @@
783783
moderation_approve(fpid);
784784
cgi_redirectf("%R/forumpost/%S",P("fpid"));
785785
return;
786786
}
787787
if( P("reject") ){
788
+ char *zParent =
789
+ db_text(0,
790
+ "SELECT uuid FROM forumpost, blob"
791
+ " WHERE forumpost.fpid=%d AND blob.rid=forumpost.firt",
792
+ fpid
793
+ );
788794
moderation_disapprove(fpid);
789
- cgi_redirectf("%R/forumpost/%S",P("fpid"));
795
+ if( zParent ){
796
+ cgi_redirectf("%R/forumpost/%S",zParent);
797
+ }else{
798
+ cgi_redirectf("%R/forum");
799
+ }
790800
return;
791801
}
792802
}
793803
isDelete = P("nullout")!=0;
794804
if( P("submit") && isCsrfSafe ){
@@ -895,11 +905,10 @@
895905
*/
896906
void forum_main_page(void){
897907
Stmt q;
898908
int iLimit, iOfst;
899909
login_check_credentials();
900
- sqlite3_int64 iNow = time(NULL);
901910
if( !g.perm.RdForum ){
902911
login_needed(g.anon.RdForum);
903912
return;
904913
}
905914
style_header("Forum");
906915
--- src/forum.c
+++ src/forum.c
@@ -373,11 +373,11 @@
373 zUuid = p->zUuid;
374 pPost = pOPost;
375 }
376 zSel = p->fpid==target ? " forumSel" : "";
377 if( p->nIndent==1 ){
378 @ <div id='forum(%d(fpid)' class='forumHierRoot%s(zSel)'>
379 }else{
380 @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \
381 @ style='margin-left: %d((p->nIndent-1)*3)ex;'>
382 }
383 pPost = manifest_get(fpid, CFTYPE_FORUM, 0);
@@ -783,12 +783,22 @@
783 moderation_approve(fpid);
784 cgi_redirectf("%R/forumpost/%S",P("fpid"));
785 return;
786 }
787 if( P("reject") ){
 
 
 
 
 
 
788 moderation_disapprove(fpid);
789 cgi_redirectf("%R/forumpost/%S",P("fpid"));
 
 
 
 
790 return;
791 }
792 }
793 isDelete = P("nullout")!=0;
794 if( P("submit") && isCsrfSafe ){
@@ -895,11 +905,10 @@
895 */
896 void forum_main_page(void){
897 Stmt q;
898 int iLimit, iOfst;
899 login_check_credentials();
900 sqlite3_int64 iNow = time(NULL);
901 if( !g.perm.RdForum ){
902 login_needed(g.anon.RdForum);
903 return;
904 }
905 style_header("Forum");
906
--- src/forum.c
+++ src/forum.c
@@ -373,11 +373,11 @@
373 zUuid = p->zUuid;
374 pPost = pOPost;
375 }
376 zSel = p->fpid==target ? " forumSel" : "";
377 if( p->nIndent==1 ){
378 @ <div id='forum%d(fpid)' class='forumHierRoot%s(zSel)'>
379 }else{
380 @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \
381 @ style='margin-left: %d((p->nIndent-1)*3)ex;'>
382 }
383 pPost = manifest_get(fpid, CFTYPE_FORUM, 0);
@@ -783,12 +783,22 @@
783 moderation_approve(fpid);
784 cgi_redirectf("%R/forumpost/%S",P("fpid"));
785 return;
786 }
787 if( P("reject") ){
788 char *zParent =
789 db_text(0,
790 "SELECT uuid FROM forumpost, blob"
791 " WHERE forumpost.fpid=%d AND blob.rid=forumpost.firt",
792 fpid
793 );
794 moderation_disapprove(fpid);
795 if( zParent ){
796 cgi_redirectf("%R/forumpost/%S",zParent);
797 }else{
798 cgi_redirectf("%R/forum");
799 }
800 return;
801 }
802 }
803 isDelete = P("nullout")!=0;
804 if( P("submit") && isCsrfSafe ){
@@ -895,11 +905,10 @@
905 */
906 void forum_main_page(void){
907 Stmt q;
908 int iLimit, iOfst;
909 login_check_credentials();
 
910 if( !g.perm.RdForum ){
911 login_needed(g.anon.RdForum);
912 return;
913 }
914 style_header("Forum");
915

Keyboard Shortcuts

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