Fossil SCM
Merge the forum-attach-moderated branch into small-fixes.
Commit
23b9245617761ab1812111eac1aaf68788c68555d1ceba3f8313f5f976b0926c
Parent
a0484ca03c56080…
9 files changed
+27
-11
+6
-1
+9
+3
+25
-23
-1
+12
-2
+1
-1
+51
+27
-11
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -177,11 +177,12 @@ | ||
| 177 | 177 | int attach_user_may(int rid, int eArtifactType){ |
| 178 | 178 | if( g.perm.Admin ) return 1; |
| 179 | 179 | if( !login_is_individual() ) return 0; |
| 180 | 180 | switch(eArtifactType){ |
| 181 | 181 | case CFTYPE_FORUM: |
| 182 | - return g.perm.AttachForum && forumpost_is_owner(rid, 0); | |
| 182 | + return (g.perm.AttachForum || g.perm.WrTForum) | |
| 183 | + && forumpost_is_owner(rid, 0); | |
| 183 | 184 | case CFTYPE_WIKI: |
| 184 | 185 | return g.perm.ApndWiki && g.perm.Attach; |
| 185 | 186 | case CFTYPE_TICKET: |
| 186 | 187 | return g.perm.ApndTkt && g.perm.Attach; |
| 187 | 188 | case CFTYPE_EVENT: |
| @@ -645,11 +646,11 @@ | ||
| 645 | 646 | char *zTargetType = 0; |
| 646 | 647 | char *zExtraFree = 0; |
| 647 | 648 | int szContent; |
| 648 | 649 | int goodCaptcha = 1; |
| 649 | 650 | int szLimit = 0; |
| 650 | - | |
| 651 | + int bNeedsModeration = -1; /* -1==don't yet know */ | |
| 651 | 652 | if( P("target")!=0 ){ |
| 652 | 653 | attachaddV2_page(); |
| 653 | 654 | return; |
| 654 | 655 | } |
| 655 | 656 | zPage = P("page"); |
| @@ -670,12 +671,16 @@ | ||
| 670 | 671 | } |
| 671 | 672 | login_check_credentials(); |
| 672 | 673 | if( zForumPost ){ |
| 673 | 674 | int fpid; |
| 674 | 675 | if( g.perm.AttachForum==0 ){ |
| 675 | - login_needed(g.anon.AttachForum); | |
| 676 | - return; | |
| 676 | + if( g.perm.WrTForum ){ | |
| 677 | + bNeedsModeration = 1; | |
| 678 | + }else{ | |
| 679 | + login_needed(g.anon.AttachForum); | |
| 680 | + return; | |
| 681 | + } | |
| 677 | 682 | } |
| 678 | 683 | fpid = forumpost_head_rid2(zForumPost); |
| 679 | 684 | if( fpid<=0 ){ |
| 680 | 685 | webpage_error("Invalid forum post ID: %h", zForumPost); |
| 681 | 686 | }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){ |
| @@ -737,14 +742,17 @@ | ||
| 737 | 742 | /* Fall through and render form. */ |
| 738 | 743 | }else if( P("ok") |
| 739 | 744 | && cgi_csrf_safe(2) |
| 740 | 745 | && szContent>0 |
| 741 | 746 | && (goodCaptcha = captcha_is_correct(0)) ){ |
| 742 | - int needModerator = (zForumPost!=0 && forum_need_moderation()) || | |
| 743 | - (zTkt!=0 && ticket_need_moderation(0)) || | |
| 744 | - (zPage!=0 && wiki_need_moderation(0)); | |
| 745 | - attach_commit(zName, zTarget, aContent, szContent, needModerator, zComment); | |
| 747 | + if( bNeedsModeration<0 ){ | |
| 748 | + bNeedsModeration = (zForumPost!=0 && forum_need_moderation()) || | |
| 749 | + (zTkt!=0 && ticket_need_moderation(0)) || | |
| 750 | + (zPage!=0 && wiki_need_moderation(0)); | |
| 751 | + } | |
| 752 | + attach_commit(zName, zTarget, aContent, szContent, | |
| 753 | + bNeedsModeration, zComment); | |
| 746 | 754 | cgi_redirect(zTo ? zTo : zFrom); |
| 747 | 755 | } |
| 748 | 756 | |
| 749 | 757 | style_set_current_feature("attach"); |
| 750 | 758 | style_header("Add Attachment"); |
| @@ -804,11 +812,17 @@ | ||
| 804 | 812 | db_rollback_transaction(); |
| 805 | 813 | return; |
| 806 | 814 | case CFTYPE_FORUM:{ |
| 807 | 815 | int fpid; |
| 808 | 816 | if( g.perm.AttachForum==0 ){ |
| 809 | - goto ajax_err_403; | |
| 817 | + if( g.perm.WrTForum ){ | |
| 818 | + bNeedsModeration = 1; | |
| 819 | + }else{ | |
| 820 | + goto ajax_err_403; | |
| 821 | + } | |
| 822 | + }else{ | |
| 823 | + bNeedsModeration = -1; | |
| 810 | 824 | } |
| 811 | 825 | fpid = forumpost_head_rid2(zTarget); |
| 812 | 826 | if( fpid<=0 ){ |
| 813 | 827 | goto ajax_err_404; |
| 814 | 828 | }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){ |
| @@ -816,11 +830,13 @@ | ||
| 816 | 830 | "other users' forum posts."); |
| 817 | 831 | db_rollback_transaction(); |
| 818 | 832 | return; |
| 819 | 833 | } |
| 820 | 834 | zTarget = zExtraFree = rid_to_uuid(fpid); |
| 821 | - bNeedsModeration = forum_need_moderation(); | |
| 835 | + if( bNeedsModeration < 0 ){ | |
| 836 | + bNeedsModeration = forum_need_moderation(); | |
| 837 | + } | |
| 822 | 838 | break; |
| 823 | 839 | } |
| 824 | 840 | case CFTYPE_EVENT:{ |
| 825 | 841 | if( g.perm.Write==0 || g.perm.ApndWiki==0 || g.perm.Attach==0 ){ |
| 826 | 842 | goto ajax_err_403; |
| @@ -1006,11 +1022,11 @@ | ||
| 1006 | 1022 | case 0: |
| 1007 | 1023 | webpage_error("Cannot resolve target=%h.", zTarget); |
| 1008 | 1024 | break; |
| 1009 | 1025 | case CFTYPE_FORUM:{ |
| 1010 | 1026 | int fpid; |
| 1011 | - if( g.perm.AttachForum==0 ){ | |
| 1027 | + if( 0==g.perm.AttachForum && 0==g.perm.WrTForum ){ | |
| 1012 | 1028 | login_needed(g.anon.AttachForum); |
| 1013 | 1029 | return; |
| 1014 | 1030 | } |
| 1015 | 1031 | fpid = forumpost_head_rid2(zTarget); |
| 1016 | 1032 | if( fpid<=0 ){ |
| 1017 | 1033 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -177,11 +177,12 @@ | |
| 177 | int attach_user_may(int rid, int eArtifactType){ |
| 178 | if( g.perm.Admin ) return 1; |
| 179 | if( !login_is_individual() ) return 0; |
| 180 | switch(eArtifactType){ |
| 181 | case CFTYPE_FORUM: |
| 182 | return g.perm.AttachForum && forumpost_is_owner(rid, 0); |
| 183 | case CFTYPE_WIKI: |
| 184 | return g.perm.ApndWiki && g.perm.Attach; |
| 185 | case CFTYPE_TICKET: |
| 186 | return g.perm.ApndTkt && g.perm.Attach; |
| 187 | case CFTYPE_EVENT: |
| @@ -645,11 +646,11 @@ | |
| 645 | char *zTargetType = 0; |
| 646 | char *zExtraFree = 0; |
| 647 | int szContent; |
| 648 | int goodCaptcha = 1; |
| 649 | int szLimit = 0; |
| 650 | |
| 651 | if( P("target")!=0 ){ |
| 652 | attachaddV2_page(); |
| 653 | return; |
| 654 | } |
| 655 | zPage = P("page"); |
| @@ -670,12 +671,16 @@ | |
| 670 | } |
| 671 | login_check_credentials(); |
| 672 | if( zForumPost ){ |
| 673 | int fpid; |
| 674 | if( g.perm.AttachForum==0 ){ |
| 675 | login_needed(g.anon.AttachForum); |
| 676 | return; |
| 677 | } |
| 678 | fpid = forumpost_head_rid2(zForumPost); |
| 679 | if( fpid<=0 ){ |
| 680 | webpage_error("Invalid forum post ID: %h", zForumPost); |
| 681 | }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){ |
| @@ -737,14 +742,17 @@ | |
| 737 | /* Fall through and render form. */ |
| 738 | }else if( P("ok") |
| 739 | && cgi_csrf_safe(2) |
| 740 | && szContent>0 |
| 741 | && (goodCaptcha = captcha_is_correct(0)) ){ |
| 742 | int needModerator = (zForumPost!=0 && forum_need_moderation()) || |
| 743 | (zTkt!=0 && ticket_need_moderation(0)) || |
| 744 | (zPage!=0 && wiki_need_moderation(0)); |
| 745 | attach_commit(zName, zTarget, aContent, szContent, needModerator, zComment); |
| 746 | cgi_redirect(zTo ? zTo : zFrom); |
| 747 | } |
| 748 | |
| 749 | style_set_current_feature("attach"); |
| 750 | style_header("Add Attachment"); |
| @@ -804,11 +812,17 @@ | |
| 804 | db_rollback_transaction(); |
| 805 | return; |
| 806 | case CFTYPE_FORUM:{ |
| 807 | int fpid; |
| 808 | if( g.perm.AttachForum==0 ){ |
| 809 | goto ajax_err_403; |
| 810 | } |
| 811 | fpid = forumpost_head_rid2(zTarget); |
| 812 | if( fpid<=0 ){ |
| 813 | goto ajax_err_404; |
| 814 | }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){ |
| @@ -816,11 +830,13 @@ | |
| 816 | "other users' forum posts."); |
| 817 | db_rollback_transaction(); |
| 818 | return; |
| 819 | } |
| 820 | zTarget = zExtraFree = rid_to_uuid(fpid); |
| 821 | bNeedsModeration = forum_need_moderation(); |
| 822 | break; |
| 823 | } |
| 824 | case CFTYPE_EVENT:{ |
| 825 | if( g.perm.Write==0 || g.perm.ApndWiki==0 || g.perm.Attach==0 ){ |
| 826 | goto ajax_err_403; |
| @@ -1006,11 +1022,11 @@ | |
| 1006 | case 0: |
| 1007 | webpage_error("Cannot resolve target=%h.", zTarget); |
| 1008 | break; |
| 1009 | case CFTYPE_FORUM:{ |
| 1010 | int fpid; |
| 1011 | if( g.perm.AttachForum==0 ){ |
| 1012 | login_needed(g.anon.AttachForum); |
| 1013 | return; |
| 1014 | } |
| 1015 | fpid = forumpost_head_rid2(zTarget); |
| 1016 | if( fpid<=0 ){ |
| 1017 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -177,11 +177,12 @@ | |
| 177 | int attach_user_may(int rid, int eArtifactType){ |
| 178 | if( g.perm.Admin ) return 1; |
| 179 | if( !login_is_individual() ) return 0; |
| 180 | switch(eArtifactType){ |
| 181 | case CFTYPE_FORUM: |
| 182 | return (g.perm.AttachForum || g.perm.WrTForum) |
| 183 | && forumpost_is_owner(rid, 0); |
| 184 | case CFTYPE_WIKI: |
| 185 | return g.perm.ApndWiki && g.perm.Attach; |
| 186 | case CFTYPE_TICKET: |
| 187 | return g.perm.ApndTkt && g.perm.Attach; |
| 188 | case CFTYPE_EVENT: |
| @@ -645,11 +646,11 @@ | |
| 646 | char *zTargetType = 0; |
| 647 | char *zExtraFree = 0; |
| 648 | int szContent; |
| 649 | int goodCaptcha = 1; |
| 650 | int szLimit = 0; |
| 651 | int bNeedsModeration = -1; /* -1==don't yet know */ |
| 652 | if( P("target")!=0 ){ |
| 653 | attachaddV2_page(); |
| 654 | return; |
| 655 | } |
| 656 | zPage = P("page"); |
| @@ -670,12 +671,16 @@ | |
| 671 | } |
| 672 | login_check_credentials(); |
| 673 | if( zForumPost ){ |
| 674 | int fpid; |
| 675 | if( g.perm.AttachForum==0 ){ |
| 676 | if( g.perm.WrTForum ){ |
| 677 | bNeedsModeration = 1; |
| 678 | }else{ |
| 679 | login_needed(g.anon.AttachForum); |
| 680 | return; |
| 681 | } |
| 682 | } |
| 683 | fpid = forumpost_head_rid2(zForumPost); |
| 684 | if( fpid<=0 ){ |
| 685 | webpage_error("Invalid forum post ID: %h", zForumPost); |
| 686 | }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){ |
| @@ -737,14 +742,17 @@ | |
| 742 | /* Fall through and render form. */ |
| 743 | }else if( P("ok") |
| 744 | && cgi_csrf_safe(2) |
| 745 | && szContent>0 |
| 746 | && (goodCaptcha = captcha_is_correct(0)) ){ |
| 747 | if( bNeedsModeration<0 ){ |
| 748 | bNeedsModeration = (zForumPost!=0 && forum_need_moderation()) || |
| 749 | (zTkt!=0 && ticket_need_moderation(0)) || |
| 750 | (zPage!=0 && wiki_need_moderation(0)); |
| 751 | } |
| 752 | attach_commit(zName, zTarget, aContent, szContent, |
| 753 | bNeedsModeration, zComment); |
| 754 | cgi_redirect(zTo ? zTo : zFrom); |
| 755 | } |
| 756 | |
| 757 | style_set_current_feature("attach"); |
| 758 | style_header("Add Attachment"); |
| @@ -804,11 +812,17 @@ | |
| 812 | db_rollback_transaction(); |
| 813 | return; |
| 814 | case CFTYPE_FORUM:{ |
| 815 | int fpid; |
| 816 | if( g.perm.AttachForum==0 ){ |
| 817 | if( g.perm.WrTForum ){ |
| 818 | bNeedsModeration = 1; |
| 819 | }else{ |
| 820 | goto ajax_err_403; |
| 821 | } |
| 822 | }else{ |
| 823 | bNeedsModeration = -1; |
| 824 | } |
| 825 | fpid = forumpost_head_rid2(zTarget); |
| 826 | if( fpid<=0 ){ |
| 827 | goto ajax_err_404; |
| 828 | }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){ |
| @@ -816,11 +830,13 @@ | |
| 830 | "other users' forum posts."); |
| 831 | db_rollback_transaction(); |
| 832 | return; |
| 833 | } |
| 834 | zTarget = zExtraFree = rid_to_uuid(fpid); |
| 835 | if( bNeedsModeration < 0 ){ |
| 836 | bNeedsModeration = forum_need_moderation(); |
| 837 | } |
| 838 | break; |
| 839 | } |
| 840 | case CFTYPE_EVENT:{ |
| 841 | if( g.perm.Write==0 || g.perm.ApndWiki==0 || g.perm.Attach==0 ){ |
| 842 | goto ajax_err_403; |
| @@ -1006,11 +1022,11 @@ | |
| 1022 | case 0: |
| 1023 | webpage_error("Cannot resolve target=%h.", zTarget); |
| 1024 | break; |
| 1025 | case CFTYPE_FORUM:{ |
| 1026 | int fpid; |
| 1027 | if( 0==g.perm.AttachForum && 0==g.perm.WrTForum ){ |
| 1028 | login_needed(g.anon.AttachForum); |
| 1029 | return; |
| 1030 | } |
| 1031 | fpid = forumpost_head_rid2(zTarget); |
| 1032 | if( fpid<=0 ){ |
| 1033 |
+6
-1
| --- src/builtin.c | ||
| +++ src/builtin.c | ||
| @@ -697,11 +697,16 @@ | ||
| 697 | 697 | CX("};\n"/*window.fossil.config.forum*/); |
| 698 | 698 | #define JBOOL(COND) ((COND) ? "true" : "false") |
| 699 | 699 | CX("window.fossil.user = {"); |
| 700 | 700 | CX("name: %!j,", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest"); |
| 701 | 701 | CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup)); |
| 702 | - CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum)); | |
| 702 | + CX("mayAttachForum: %d,", g.perm.AttachForum | |
| 703 | + ? 1 : (g.perm.WrTForum | |
| 704 | + ? -1 : 0)) | |
| 705 | + /* 0 = no, 1 = 'B' permissions, | |
| 706 | + ** -1 = moderated attachments. Potential TODO is a setting | |
| 707 | + ** to enable this. */; | |
| 703 | 708 | CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin)); |
| 704 | 709 | CX("isIndividual: %s", JBOOL(login_is_individual())); |
| 705 | 710 | CX("};\n"/*fossil.user*/); |
| 706 | 711 | { /* Workaround for cases like: |
| 707 | 712 | ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8 |
| 708 | 713 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -697,11 +697,16 @@ | |
| 697 | CX("};\n"/*window.fossil.config.forum*/); |
| 698 | #define JBOOL(COND) ((COND) ? "true" : "false") |
| 699 | CX("window.fossil.user = {"); |
| 700 | CX("name: %!j,", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest"); |
| 701 | CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup)); |
| 702 | CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum)); |
| 703 | CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin)); |
| 704 | CX("isIndividual: %s", JBOOL(login_is_individual())); |
| 705 | CX("};\n"/*fossil.user*/); |
| 706 | { /* Workaround for cases like: |
| 707 | ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8 |
| 708 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -697,11 +697,16 @@ | |
| 697 | CX("};\n"/*window.fossil.config.forum*/); |
| 698 | #define JBOOL(COND) ((COND) ? "true" : "false") |
| 699 | CX("window.fossil.user = {"); |
| 700 | CX("name: %!j,", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest"); |
| 701 | CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup)); |
| 702 | CX("mayAttachForum: %d,", g.perm.AttachForum |
| 703 | ? 1 : (g.perm.WrTForum |
| 704 | ? -1 : 0)) |
| 705 | /* 0 = no, 1 = 'B' permissions, |
| 706 | ** -1 = moderated attachments. Potential TODO is a setting |
| 707 | ** to enable this. */; |
| 708 | CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin)); |
| 709 | CX("isIndividual: %s", JBOOL(login_is_individual())); |
| 710 | CX("};\n"/*fossil.user*/); |
| 711 | { /* Workaround for cases like: |
| 712 | ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8 |
| 713 |
M
src/db.c
+9
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -4927,10 +4927,19 @@ | ||
| 4927 | 4927 | /* |
| 4928 | 4928 | ** SETTING: http-port width=16 default=8080 |
| 4929 | 4929 | ** The default TCP/IP port number to use by the "server" |
| 4930 | 4930 | ** and "ui" commands. |
| 4931 | 4931 | */ |
| 4932 | +/* | |
| 4933 | +** SETTING: hide-by-user width=40 block-text | |
| 4934 | +** The VALUE of this setting is a list of GLOB patterns. On the /timeline | |
| 4935 | +** page, any check-in whose user login name matches one of these patterns | |
| 4936 | +** is treated as if it carried the "hidden" tag, and is omitted unless the | |
| 4937 | +** "unhide=on" query parameter is used. Example: bot-*,*-robot | |
| 4938 | +** The parsing rules are complex; see | |
| 4939 | +** https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax | |
| 4940 | +*/ | |
| 4932 | 4941 | /* |
| 4933 | 4942 | ** SETTING: https-login boolean default=off |
| 4934 | 4943 | ** If true, then the Fossil web server will redirect unencrypted |
| 4935 | 4944 | ** login screen requests to HTTPS. |
| 4936 | 4945 | */ |
| 4937 | 4946 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -4927,10 +4927,19 @@ | |
| 4927 | /* |
| 4928 | ** SETTING: http-port width=16 default=8080 |
| 4929 | ** The default TCP/IP port number to use by the "server" |
| 4930 | ** and "ui" commands. |
| 4931 | */ |
| 4932 | /* |
| 4933 | ** SETTING: https-login boolean default=off |
| 4934 | ** If true, then the Fossil web server will redirect unencrypted |
| 4935 | ** login screen requests to HTTPS. |
| 4936 | */ |
| 4937 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -4927,10 +4927,19 @@ | |
| 4927 | /* |
| 4928 | ** SETTING: http-port width=16 default=8080 |
| 4929 | ** The default TCP/IP port number to use by the "server" |
| 4930 | ** and "ui" commands. |
| 4931 | */ |
| 4932 | /* |
| 4933 | ** SETTING: hide-by-user width=40 block-text |
| 4934 | ** The VALUE of this setting is a list of GLOB patterns. On the /timeline |
| 4935 | ** page, any check-in whose user login name matches one of these patterns |
| 4936 | ** is treated as if it carried the "hidden" tag, and is omitted unless the |
| 4937 | ** "unhide=on" query parameter is used. Example: bot-*,*-robot |
| 4938 | ** The parsing rules are complex; see |
| 4939 | ** https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax |
| 4940 | */ |
| 4941 | /* |
| 4942 | ** SETTING: https-login boolean default=off |
| 4943 | ** If true, then the Fossil web server will redirect unencrypted |
| 4944 | ** login screen requests to HTTPS. |
| 4945 | */ |
| 4946 |
+3
| --- src/default.css | ||
| +++ src/default.css | ||
| @@ -2016,10 +2016,13 @@ | ||
| 2016 | 2016 | /* .attach* = styles for file attachments */ |
| 2017 | 2017 | section.attachlist {} |
| 2018 | 2018 | details.attachlist > summary { |
| 2019 | 2019 | cursor: pointer; |
| 2020 | 2020 | } |
| 2021 | +div.forumpost > details.attachlist { | |
| 2022 | + margin-bottom: 0.5em/*else too cramped with the buttons*/; | |
| 2023 | +} | |
| 2021 | 2024 | /* .Attacher is the top container element used by the JS Attacher |
| 2022 | 2025 | class in fossil.attach.js. */ |
| 2023 | 2026 | .Attacher { |
| 2024 | 2027 | margin-bottom: 1em; |
| 2025 | 2028 | display: flex; |
| 2026 | 2029 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -2016,10 +2016,13 @@ | |
| 2016 | /* .attach* = styles for file attachments */ |
| 2017 | section.attachlist {} |
| 2018 | details.attachlist > summary { |
| 2019 | cursor: pointer; |
| 2020 | } |
| 2021 | /* .Attacher is the top container element used by the JS Attacher |
| 2022 | class in fossil.attach.js. */ |
| 2023 | .Attacher { |
| 2024 | margin-bottom: 1em; |
| 2025 | display: flex; |
| 2026 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -2016,10 +2016,13 @@ | |
| 2016 | /* .attach* = styles for file attachments */ |
| 2017 | section.attachlist {} |
| 2018 | details.attachlist > summary { |
| 2019 | cursor: pointer; |
| 2020 | } |
| 2021 | div.forumpost > details.attachlist { |
| 2022 | margin-bottom: 0.5em/*else too cramped with the buttons*/; |
| 2023 | } |
| 2024 | /* .Attacher is the top container element used by the JS Attacher |
| 2025 | class in fossil.attach.js. */ |
| 2026 | .Attacher { |
| 2027 | margin-bottom: 1em; |
| 2028 | display: flex; |
| 2029 |
+25
-23
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -2191,11 +2191,11 @@ | ||
| 2191 | 2191 | ** its list of attachments. We only emit this for No-JS environments, |
| 2192 | 2192 | ** as in JS environments the interactive forum editor includes |
| 2193 | 2193 | ** attachment support. |
| 2194 | 2194 | */ |
| 2195 | 2195 | static void forum_render_attachment_notice(void){ |
| 2196 | - if( g.perm.AttachForum ){ | |
| 2196 | + if( g.perm.AttachForum || g.perm.WrTForum ){ | |
| 2197 | 2197 | @ <noscript><div>You will be able to attach files to this post |
| 2198 | 2198 | @ after saving it.</div></noscript> |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
| 2201 | 2201 | |
| @@ -2238,12 +2238,12 @@ | ||
| 2238 | 2238 | } |
| 2239 | 2239 | forum_render_debug_options(); |
| 2240 | 2240 | login_insert_csrf_secret(); |
| 2241 | 2241 | @ </form> |
| 2242 | 2242 | /* When JS is disabled the block above will work. When it's |
| 2243 | - enabled, the above will be removed and JS will render the editor | |
| 2244 | - form in the next element. */ | |
| 2243 | + ** enabled, the above will be removed and JS will render the editor | |
| 2244 | + ** form in the next element. */ | |
| 2245 | 2245 | @ <div hidden id='forumnew-placeholder'> |
| 2246 | 2246 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2247 | 2247 | login_insert_csrf_secret(); |
| 2248 | 2248 | @ </div> |
| 2249 | 2249 | forum_render_attachment_notice(); |
| @@ -3044,14 +3044,14 @@ | ||
| 3044 | 3044 | ** The caller must have started a transaction and must roll it back if |
| 3045 | 3045 | ** this call returns <=0, noting that only the negative-value case is |
| 3046 | 3046 | ** an error. |
| 3047 | 3047 | ** |
| 3048 | 3048 | ** This function does some work to try to ensure that duplicate |
| 3049 | -** entries are not save (this can happen as a side effect of the forum | |
| 3050 | -** post editor added in 2026-06). If the given post will not have been | |
| 3051 | -** materially edited by these changes, they are not applied and the | |
| 3052 | -** rid of the existing entry is used. | |
| 3049 | +** entries are not saved (this can happen as a side effect of the | |
| 3050 | +** forum post editor added in 2026-06). If the given post will not | |
| 3051 | +** have been materially edited by these changes, they are not applied | |
| 3052 | +** and the rid of the existing entry is used. | |
| 3053 | 3053 | ** |
| 3054 | 3054 | ** Maintenance reminders: |
| 3055 | 3055 | ** |
| 3056 | 3056 | ** - iInReplyTo==0 && iEdit==0: new thread |
| 3057 | 3057 | ** - iInReplyTo==0 && iEdit>0 : edit top post or response |
| @@ -3243,15 +3243,15 @@ | ||
| 3243 | 3243 | return rc; |
| 3244 | 3244 | } |
| 3245 | 3245 | /* |
| 3246 | 3246 | ** WEBPAGE: forumajax_save hidden |
| 3247 | 3247 | ** |
| 3248 | -** WIP | |
| 3248 | +** Used by the forum JS pages to save a post. | |
| 3249 | 3249 | ** |
| 3250 | 3250 | ** Response JSON: |
| 3251 | 3251 | ** |
| 3252 | -** { uuid: hash, ...tbd } | |
| 3252 | +** { uuid: hash, ...TO DOCUMENT } | |
| 3253 | 3253 | */ |
| 3254 | 3254 | void forum_ajax_save_page(void){ |
| 3255 | 3255 | const char *zFpid; |
| 3256 | 3256 | const char *zTitle; |
| 3257 | 3257 | const char *zIrt; |
| @@ -3267,15 +3267,17 @@ | ||
| 3267 | 3267 | int nrid = 0; /* New artifact rid. */ |
| 3268 | 3268 | int iPostFlags; /* forum_post_flags() (after perms check) */ |
| 3269 | 3269 | int bRollback; /* True = roll back. */ |
| 3270 | 3270 | int nAttach = 0; /* Number of attachments added */ |
| 3271 | 3271 | int bStatusSet = 0; /* True if status tag set. */ |
| 3272 | + int bModPost = 0; /* Moderate post? */ | |
| 3273 | + int bModAttach; /* Moderate attachment? */ | |
| 3272 | 3274 | |
| 3273 | 3275 | if( !ajax_route_bootstrap(0, 1) ){ |
| 3274 | 3276 | return; |
| 3275 | - }else if( !g.perm.WrForum | |
| 3276 | - || (bHasAttachment && !g.perm.AttachForum) ){ | |
| 3277 | + }else if( !g.perm.WrForum || | |
| 3278 | + (bHasAttachment && !g.perm.WrTForum) ){ | |
| 3277 | 3279 | ajax_route_error_forbidden(); |
| 3278 | 3280 | return; |
| 3279 | 3281 | }else if( !ajax_check_csrf(2) ){ |
| 3280 | 3282 | ajax_route_error_csrf(); |
| 3281 | 3283 | return; |
| @@ -3322,17 +3324,18 @@ | ||
| 3322 | 3324 | rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID."); |
| 3323 | 3325 | goto ajax_save_end; |
| 3324 | 3326 | } |
| 3325 | 3327 | } |
| 3326 | 3328 | |
| 3327 | - if( 0 ){ | |
| 3328 | - rc = -ajax_route_error(400, "Save is TODO. " | |
| 3329 | - "iPostFlags=%d debug=%d", | |
| 3330 | - iPostFlags, g.perm.Debug); | |
| 3331 | - goto ajax_save_end; | |
| 3329 | + bModPost = forum_need_moderation(); | |
| 3330 | + if( bHasAttachment && !g.perm.AttachForum && g.perm.WrTForum ){ | |
| 3331 | + /* A user with WrTForum but not AttachForum may attach but | |
| 3332 | + ** the attachments will be moderated. */ | |
| 3333 | + bModAttach = 1; | |
| 3334 | + }else{ | |
| 3335 | + bModAttach = bModPost; | |
| 3332 | 3336 | } |
| 3333 | - | |
| 3334 | 3337 | zTitle = firt ? 0 : P("title"); |
| 3335 | 3338 | nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype, |
| 3336 | 3339 | zContent, iPostFlags); |
| 3337 | 3340 | if( nrid<0 ){ |
| 3338 | 3341 | rc = nrid; |
| @@ -3345,24 +3348,23 @@ | ||
| 3345 | 3348 | CX("{\"message\": \"Rolled back for dry-run.\"," |
| 3346 | 3349 | "\"iPostFlags\":%d}\n", iPostFlags); |
| 3347 | 3350 | } |
| 3348 | 3351 | goto ajax_save_end; |
| 3349 | 3352 | }else{ |
| 3350 | - const int bNeedsModeration = forum_need_moderation(); | |
| 3351 | 3353 | const int fpHead = forumpost_head_rid(nrid); |
| 3352 | 3354 | assert( nrid>0 ); |
| 3353 | 3355 | assert( fpHead>0 ); |
| 3354 | 3356 | zNewUuid = rid_to_uuid(nrid); |
| 3355 | - if( 0!=P("file1") ){ | |
| 3357 | + if( bHasAttachment ){ | |
| 3356 | 3358 | /* Attachments */ |
| 3357 | - if( !g.perm.Admin && !g.perm.AttachForum ){ | |
| 3358 | - rc = -ajax_route_error(403, "No permission no attach files."); | |
| 3359 | + if( !g.perm.Admin && !(g.perm.AttachForum ||g.perm.WrTForum) ){ | |
| 3360 | + rc = -ajax_route_error(403, "No permission to attach files."); | |
| 3359 | 3361 | goto ajax_save_end; |
| 3360 | 3362 | }else{ |
| 3361 | 3363 | char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead); |
| 3362 | 3364 | nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid, |
| 3363 | - bNeedsModeration); | |
| 3365 | + bModAttach); | |
| 3364 | 3366 | fossil_free(zRoot); |
| 3365 | 3367 | if( nAttach<0 ){ |
| 3366 | 3368 | rc = nAttach; |
| 3367 | 3369 | goto ajax_save_end; |
| 3368 | 3370 | } |
| @@ -3385,11 +3387,11 @@ | ||
| 3385 | 3387 | fpHead, fpHead |
| 3386 | 3388 | ); |
| 3387 | 3389 | } |
| 3388 | 3390 | } |
| 3389 | 3391 | } |
| 3390 | - if( 0==bNeedsModeration | |
| 3392 | + if( 0==bModPost | |
| 3391 | 3393 | /* ^^^ Do not allow a status tag on a pending-moderation post |
| 3392 | 3394 | ** because it will introduce a reference to an artifact which |
| 3393 | 3395 | ** will become a phantom if it is rejected by a moderator. */ |
| 3394 | 3396 | && zStatus!=0 && zStatus[0]!=0 |
| 3395 | 3397 | && forum_may_set_status(nrid) |
| 3396 | 3398 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -2191,11 +2191,11 @@ | |
| 2191 | ** its list of attachments. We only emit this for No-JS environments, |
| 2192 | ** as in JS environments the interactive forum editor includes |
| 2193 | ** attachment support. |
| 2194 | */ |
| 2195 | static void forum_render_attachment_notice(void){ |
| 2196 | if( g.perm.AttachForum ){ |
| 2197 | @ <noscript><div>You will be able to attach files to this post |
| 2198 | @ after saving it.</div></noscript> |
| 2199 | } |
| 2200 | } |
| 2201 | |
| @@ -2238,12 +2238,12 @@ | |
| 2238 | } |
| 2239 | forum_render_debug_options(); |
| 2240 | login_insert_csrf_secret(); |
| 2241 | @ </form> |
| 2242 | /* When JS is disabled the block above will work. When it's |
| 2243 | enabled, the above will be removed and JS will render the editor |
| 2244 | form in the next element. */ |
| 2245 | @ <div hidden id='forumnew-placeholder'> |
| 2246 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2247 | login_insert_csrf_secret(); |
| 2248 | @ </div> |
| 2249 | forum_render_attachment_notice(); |
| @@ -3044,14 +3044,14 @@ | |
| 3044 | ** The caller must have started a transaction and must roll it back if |
| 3045 | ** this call returns <=0, noting that only the negative-value case is |
| 3046 | ** an error. |
| 3047 | ** |
| 3048 | ** This function does some work to try to ensure that duplicate |
| 3049 | ** entries are not save (this can happen as a side effect of the forum |
| 3050 | ** post editor added in 2026-06). If the given post will not have been |
| 3051 | ** materially edited by these changes, they are not applied and the |
| 3052 | ** rid of the existing entry is used. |
| 3053 | ** |
| 3054 | ** Maintenance reminders: |
| 3055 | ** |
| 3056 | ** - iInReplyTo==0 && iEdit==0: new thread |
| 3057 | ** - iInReplyTo==0 && iEdit>0 : edit top post or response |
| @@ -3243,15 +3243,15 @@ | |
| 3243 | return rc; |
| 3244 | } |
| 3245 | /* |
| 3246 | ** WEBPAGE: forumajax_save hidden |
| 3247 | ** |
| 3248 | ** WIP |
| 3249 | ** |
| 3250 | ** Response JSON: |
| 3251 | ** |
| 3252 | ** { uuid: hash, ...tbd } |
| 3253 | */ |
| 3254 | void forum_ajax_save_page(void){ |
| 3255 | const char *zFpid; |
| 3256 | const char *zTitle; |
| 3257 | const char *zIrt; |
| @@ -3267,15 +3267,17 @@ | |
| 3267 | int nrid = 0; /* New artifact rid. */ |
| 3268 | int iPostFlags; /* forum_post_flags() (after perms check) */ |
| 3269 | int bRollback; /* True = roll back. */ |
| 3270 | int nAttach = 0; /* Number of attachments added */ |
| 3271 | int bStatusSet = 0; /* True if status tag set. */ |
| 3272 | |
| 3273 | if( !ajax_route_bootstrap(0, 1) ){ |
| 3274 | return; |
| 3275 | }else if( !g.perm.WrForum |
| 3276 | || (bHasAttachment && !g.perm.AttachForum) ){ |
| 3277 | ajax_route_error_forbidden(); |
| 3278 | return; |
| 3279 | }else if( !ajax_check_csrf(2) ){ |
| 3280 | ajax_route_error_csrf(); |
| 3281 | return; |
| @@ -3322,17 +3324,18 @@ | |
| 3322 | rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID."); |
| 3323 | goto ajax_save_end; |
| 3324 | } |
| 3325 | } |
| 3326 | |
| 3327 | if( 0 ){ |
| 3328 | rc = -ajax_route_error(400, "Save is TODO. " |
| 3329 | "iPostFlags=%d debug=%d", |
| 3330 | iPostFlags, g.perm.Debug); |
| 3331 | goto ajax_save_end; |
| 3332 | } |
| 3333 | |
| 3334 | zTitle = firt ? 0 : P("title"); |
| 3335 | nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype, |
| 3336 | zContent, iPostFlags); |
| 3337 | if( nrid<0 ){ |
| 3338 | rc = nrid; |
| @@ -3345,24 +3348,23 @@ | |
| 3345 | CX("{\"message\": \"Rolled back for dry-run.\"," |
| 3346 | "\"iPostFlags\":%d}\n", iPostFlags); |
| 3347 | } |
| 3348 | goto ajax_save_end; |
| 3349 | }else{ |
| 3350 | const int bNeedsModeration = forum_need_moderation(); |
| 3351 | const int fpHead = forumpost_head_rid(nrid); |
| 3352 | assert( nrid>0 ); |
| 3353 | assert( fpHead>0 ); |
| 3354 | zNewUuid = rid_to_uuid(nrid); |
| 3355 | if( 0!=P("file1") ){ |
| 3356 | /* Attachments */ |
| 3357 | if( !g.perm.Admin && !g.perm.AttachForum ){ |
| 3358 | rc = -ajax_route_error(403, "No permission no attach files."); |
| 3359 | goto ajax_save_end; |
| 3360 | }else{ |
| 3361 | char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead); |
| 3362 | nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid, |
| 3363 | bNeedsModeration); |
| 3364 | fossil_free(zRoot); |
| 3365 | if( nAttach<0 ){ |
| 3366 | rc = nAttach; |
| 3367 | goto ajax_save_end; |
| 3368 | } |
| @@ -3385,11 +3387,11 @@ | |
| 3385 | fpHead, fpHead |
| 3386 | ); |
| 3387 | } |
| 3388 | } |
| 3389 | } |
| 3390 | if( 0==bNeedsModeration |
| 3391 | /* ^^^ Do not allow a status tag on a pending-moderation post |
| 3392 | ** because it will introduce a reference to an artifact which |
| 3393 | ** will become a phantom if it is rejected by a moderator. */ |
| 3394 | && zStatus!=0 && zStatus[0]!=0 |
| 3395 | && forum_may_set_status(nrid) |
| 3396 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -2191,11 +2191,11 @@ | |
| 2191 | ** its list of attachments. We only emit this for No-JS environments, |
| 2192 | ** as in JS environments the interactive forum editor includes |
| 2193 | ** attachment support. |
| 2194 | */ |
| 2195 | static void forum_render_attachment_notice(void){ |
| 2196 | if( g.perm.AttachForum || g.perm.WrTForum ){ |
| 2197 | @ <noscript><div>You will be able to attach files to this post |
| 2198 | @ after saving it.</div></noscript> |
| 2199 | } |
| 2200 | } |
| 2201 | |
| @@ -2238,12 +2238,12 @@ | |
| 2238 | } |
| 2239 | forum_render_debug_options(); |
| 2240 | login_insert_csrf_secret(); |
| 2241 | @ </form> |
| 2242 | /* When JS is disabled the block above will work. When it's |
| 2243 | ** enabled, the above will be removed and JS will render the editor |
| 2244 | ** form in the next element. */ |
| 2245 | @ <div hidden id='forumnew-placeholder'> |
| 2246 | @ <input type='hidden' name='title' value='%h(zTitle)'> |
| 2247 | login_insert_csrf_secret(); |
| 2248 | @ </div> |
| 2249 | forum_render_attachment_notice(); |
| @@ -3044,14 +3044,14 @@ | |
| 3044 | ** The caller must have started a transaction and must roll it back if |
| 3045 | ** this call returns <=0, noting that only the negative-value case is |
| 3046 | ** an error. |
| 3047 | ** |
| 3048 | ** This function does some work to try to ensure that duplicate |
| 3049 | ** entries are not saved (this can happen as a side effect of the |
| 3050 | ** forum post editor added in 2026-06). If the given post will not |
| 3051 | ** have been materially edited by these changes, they are not applied |
| 3052 | ** and the rid of the existing entry is used. |
| 3053 | ** |
| 3054 | ** Maintenance reminders: |
| 3055 | ** |
| 3056 | ** - iInReplyTo==0 && iEdit==0: new thread |
| 3057 | ** - iInReplyTo==0 && iEdit>0 : edit top post or response |
| @@ -3243,15 +3243,15 @@ | |
| 3243 | return rc; |
| 3244 | } |
| 3245 | /* |
| 3246 | ** WEBPAGE: forumajax_save hidden |
| 3247 | ** |
| 3248 | ** Used by the forum JS pages to save a post. |
| 3249 | ** |
| 3250 | ** Response JSON: |
| 3251 | ** |
| 3252 | ** { uuid: hash, ...TO DOCUMENT } |
| 3253 | */ |
| 3254 | void forum_ajax_save_page(void){ |
| 3255 | const char *zFpid; |
| 3256 | const char *zTitle; |
| 3257 | const char *zIrt; |
| @@ -3267,15 +3267,17 @@ | |
| 3267 | int nrid = 0; /* New artifact rid. */ |
| 3268 | int iPostFlags; /* forum_post_flags() (after perms check) */ |
| 3269 | int bRollback; /* True = roll back. */ |
| 3270 | int nAttach = 0; /* Number of attachments added */ |
| 3271 | int bStatusSet = 0; /* True if status tag set. */ |
| 3272 | int bModPost = 0; /* Moderate post? */ |
| 3273 | int bModAttach; /* Moderate attachment? */ |
| 3274 | |
| 3275 | if( !ajax_route_bootstrap(0, 1) ){ |
| 3276 | return; |
| 3277 | }else if( !g.perm.WrForum || |
| 3278 | (bHasAttachment && !g.perm.WrTForum) ){ |
| 3279 | ajax_route_error_forbidden(); |
| 3280 | return; |
| 3281 | }else if( !ajax_check_csrf(2) ){ |
| 3282 | ajax_route_error_csrf(); |
| 3283 | return; |
| @@ -3322,17 +3324,18 @@ | |
| 3324 | rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID."); |
| 3325 | goto ajax_save_end; |
| 3326 | } |
| 3327 | } |
| 3328 | |
| 3329 | bModPost = forum_need_moderation(); |
| 3330 | if( bHasAttachment && !g.perm.AttachForum && g.perm.WrTForum ){ |
| 3331 | /* A user with WrTForum but not AttachForum may attach but |
| 3332 | ** the attachments will be moderated. */ |
| 3333 | bModAttach = 1; |
| 3334 | }else{ |
| 3335 | bModAttach = bModPost; |
| 3336 | } |
| 3337 | zTitle = firt ? 0 : P("title"); |
| 3338 | nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype, |
| 3339 | zContent, iPostFlags); |
| 3340 | if( nrid<0 ){ |
| 3341 | rc = nrid; |
| @@ -3345,24 +3348,23 @@ | |
| 3348 | CX("{\"message\": \"Rolled back for dry-run.\"," |
| 3349 | "\"iPostFlags\":%d}\n", iPostFlags); |
| 3350 | } |
| 3351 | goto ajax_save_end; |
| 3352 | }else{ |
| 3353 | const int fpHead = forumpost_head_rid(nrid); |
| 3354 | assert( nrid>0 ); |
| 3355 | assert( fpHead>0 ); |
| 3356 | zNewUuid = rid_to_uuid(nrid); |
| 3357 | if( bHasAttachment ){ |
| 3358 | /* Attachments */ |
| 3359 | if( !g.perm.Admin && !(g.perm.AttachForum ||g.perm.WrTForum) ){ |
| 3360 | rc = -ajax_route_error(403, "No permission to attach files."); |
| 3361 | goto ajax_save_end; |
| 3362 | }else{ |
| 3363 | char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead); |
| 3364 | nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid, |
| 3365 | bModAttach); |
| 3366 | fossil_free(zRoot); |
| 3367 | if( nAttach<0 ){ |
| 3368 | rc = nAttach; |
| 3369 | goto ajax_save_end; |
| 3370 | } |
| @@ -3385,11 +3387,11 @@ | |
| 3387 | fpHead, fpHead |
| 3388 | ); |
| 3389 | } |
| 3390 | } |
| 3391 | } |
| 3392 | if( 0==bModPost |
| 3393 | /* ^^^ Do not allow a status tag on a pending-moderation post |
| 3394 | ** because it will introduce a reference to an artifact which |
| 3395 | ** will become a phantom if it is rejected by a moderator. */ |
| 3396 | && zStatus!=0 && zStatus[0]!=0 |
| 3397 | && forum_may_set_status(nrid) |
| 3398 |
-1
| --- src/fossil.attach.js | ||
| +++ src/fossil.attach.js | ||
| @@ -138,11 +138,10 @@ | ||
| 138 | 138 | } |
| 139 | 139 | }else{ |
| 140 | 140 | this.#updateControls(); |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | - | |
| 144 | 143 | |
| 145 | 144 | get widget(){ |
| 146 | 145 | return this.#e.body; |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | 148 |
| --- src/fossil.attach.js | |
| +++ src/fossil.attach.js | |
| @@ -138,11 +138,10 @@ | |
| 138 | } |
| 139 | }else{ |
| 140 | this.#updateControls(); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | |
| 145 | get widget(){ |
| 146 | return this.#e.body; |
| 147 | } |
| 148 | |
| 149 |
| --- src/fossil.attach.js | |
| +++ src/fossil.attach.js | |
| @@ -138,11 +138,10 @@ | |
| 138 | } |
| 139 | }else{ |
| 140 | this.#updateControls(); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | get widget(){ |
| 145 | return this.#e.body; |
| 146 | } |
| 147 | |
| 148 |
+12
-2
| --- src/fossil.page.forumpost.js | ||
| +++ src/fossil.page.forumpost.js | ||
| @@ -337,11 +337,11 @@ | ||
| 337 | 337 | } |
| 338 | 338 | }); |
| 339 | 339 | } |
| 340 | 340 | }/*e.status*/ |
| 341 | 341 | |
| 342 | - if( F.user.mayAttachForum ){ | |
| 342 | + if( 0!==F.user.mayAttachForum ){ | |
| 343 | 343 | //e.buttons.append( e.button.addAttach = this.#att.takeAddButton() ); |
| 344 | 344 | e.tabAttach = D.div(); |
| 345 | 345 | e.tabAttach.setAttribute('id', idPrefix+'-attach'); |
| 346 | 346 | e.tabAttach.dataset.tabLabel = 'Attachments'; |
| 347 | 347 | this.#tabs.addTab(e.tabAttach); |
| @@ -598,13 +598,23 @@ | ||
| 598 | 598 | D.attr( |
| 599 | 599 | D.a(F.repoUrl('attachadd?target='+this.#opt.edit.uuid), '/attachadd'), |
| 600 | 600 | 'target', |
| 601 | 601 | '_new' |
| 602 | 602 | ), |
| 603 | - ".", | |
| 603 | + "." | |
| 604 | 604 | ); |
| 605 | 605 | this.#e.tabAttach.append(eNote); |
| 606 | + } | |
| 607 | + if( F.user.mayAttachForum < 0 ){ | |
| 608 | + /* Users with permission '4' (forum unmoderated) but not 'B' | |
| 609 | + ** (forum-attach) may attach files but they will undergo | |
| 610 | + ** moderation. */ | |
| 611 | + const w = D.div(); | |
| 612 | + w.append("Your attachments will be held "+ | |
| 613 | + "for moderation."); | |
| 614 | + w.classList.add('warning'); | |
| 615 | + this.#e.tabAttach.append(w); | |
| 606 | 616 | } |
| 607 | 617 | this.#e.tabAttach.append(this.#att.widget); |
| 608 | 618 | } |
| 609 | 619 | |
| 610 | 620 | #newFormData(addThisContent){ |
| 611 | 621 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -337,11 +337,11 @@ | |
| 337 | } |
| 338 | }); |
| 339 | } |
| 340 | }/*e.status*/ |
| 341 | |
| 342 | if( F.user.mayAttachForum ){ |
| 343 | //e.buttons.append( e.button.addAttach = this.#att.takeAddButton() ); |
| 344 | e.tabAttach = D.div(); |
| 345 | e.tabAttach.setAttribute('id', idPrefix+'-attach'); |
| 346 | e.tabAttach.dataset.tabLabel = 'Attachments'; |
| 347 | this.#tabs.addTab(e.tabAttach); |
| @@ -598,13 +598,23 @@ | |
| 598 | D.attr( |
| 599 | D.a(F.repoUrl('attachadd?target='+this.#opt.edit.uuid), '/attachadd'), |
| 600 | 'target', |
| 601 | '_new' |
| 602 | ), |
| 603 | ".", |
| 604 | ); |
| 605 | this.#e.tabAttach.append(eNote); |
| 606 | } |
| 607 | this.#e.tabAttach.append(this.#att.widget); |
| 608 | } |
| 609 | |
| 610 | #newFormData(addThisContent){ |
| 611 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -337,11 +337,11 @@ | |
| 337 | } |
| 338 | }); |
| 339 | } |
| 340 | }/*e.status*/ |
| 341 | |
| 342 | if( 0!==F.user.mayAttachForum ){ |
| 343 | //e.buttons.append( e.button.addAttach = this.#att.takeAddButton() ); |
| 344 | e.tabAttach = D.div(); |
| 345 | e.tabAttach.setAttribute('id', idPrefix+'-attach'); |
| 346 | e.tabAttach.dataset.tabLabel = 'Attachments'; |
| 347 | this.#tabs.addTab(e.tabAttach); |
| @@ -598,13 +598,23 @@ | |
| 598 | D.attr( |
| 599 | D.a(F.repoUrl('attachadd?target='+this.#opt.edit.uuid), '/attachadd'), |
| 600 | 'target', |
| 601 | '_new' |
| 602 | ), |
| 603 | "." |
| 604 | ); |
| 605 | this.#e.tabAttach.append(eNote); |
| 606 | } |
| 607 | if( F.user.mayAttachForum < 0 ){ |
| 608 | /* Users with permission '4' (forum unmoderated) but not 'B' |
| 609 | ** (forum-attach) may attach files but they will undergo |
| 610 | ** moderation. */ |
| 611 | const w = D.div(); |
| 612 | w.append("Your attachments will be held "+ |
| 613 | "for moderation."); |
| 614 | w.classList.add('warning'); |
| 615 | this.#e.tabAttach.append(w); |
| 616 | } |
| 617 | this.#e.tabAttach.append(this.#att.widget); |
| 618 | } |
| 619 | |
| 620 | #newFormData(addThisContent){ |
| 621 |
+1
-1
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -505,11 +505,11 @@ | ||
| 505 | 505 | ** the ID of the <span> that surrounds the display text and the ID |
| 506 | 506 | ** of the <button> becomes "copy-%s" where %s is filled in by zTargetId. |
| 507 | 507 | ** If zTargetId is NULL (the usual case) then IDs are selected automatically. |
| 508 | 508 | ** |
| 509 | 509 | ** The bOutputCGI parameter is usually true, meaning that the output |
| 510 | -** is appended to the CGI result under construction. However, if | |
| 510 | +** is appended to the CGI result under construction. However, if | |
| 511 | 511 | ** bOutputCGI is false, the generated HTML is written into memory |
| 512 | 512 | ** obtained from fossil_malloc() and returned. |
| 513 | 513 | ** |
| 514 | 514 | ** If the bAfter argument is non-zero, the copy button is displayed |
| 515 | 515 | ** after the text. Normally the copy button comes before the text. |
| 516 | 516 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -505,11 +505,11 @@ | |
| 505 | ** the ID of the <span> that surrounds the display text and the ID |
| 506 | ** of the <button> becomes "copy-%s" where %s is filled in by zTargetId. |
| 507 | ** If zTargetId is NULL (the usual case) then IDs are selected automatically. |
| 508 | ** |
| 509 | ** The bOutputCGI parameter is usually true, meaning that the output |
| 510 | ** is appended to the CGI result under construction. However, if |
| 511 | ** bOutputCGI is false, the generated HTML is written into memory |
| 512 | ** obtained from fossil_malloc() and returned. |
| 513 | ** |
| 514 | ** If the bAfter argument is non-zero, the copy button is displayed |
| 515 | ** after the text. Normally the copy button comes before the text. |
| 516 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -505,11 +505,11 @@ | |
| 505 | ** the ID of the <span> that surrounds the display text and the ID |
| 506 | ** of the <button> becomes "copy-%s" where %s is filled in by zTargetId. |
| 507 | ** If zTargetId is NULL (the usual case) then IDs are selected automatically. |
| 508 | ** |
| 509 | ** The bOutputCGI parameter is usually true, meaning that the output |
| 510 | ** is appended to the CGI result under construction. However, if |
| 511 | ** bOutputCGI is false, the generated HTML is written into memory |
| 512 | ** obtained from fossil_malloc() and returned. |
| 513 | ** |
| 514 | ** If the bAfter argument is non-zero, the copy button is displayed |
| 515 | ** after the text. Normally the copy button comes before the text. |
| 516 |
+51
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1237,10 +1237,46 @@ | ||
| 1237 | 1237 | @ FROM event CROSS JOIN blob |
| 1238 | 1238 | @ WHERE blob.rid=event.objid |
| 1239 | 1239 | ; |
| 1240 | 1240 | return zBase; |
| 1241 | 1241 | } |
| 1242 | + | |
| 1243 | +/* | |
| 1244 | +** SQL function: hidden_by_user(X) | |
| 1245 | +** | |
| 1246 | +** Return true if X matches one of the GLOB patterns in the "hide-by-user" | |
| 1247 | +** setting. | |
| 1248 | +*/ | |
| 1249 | +static void timeline_hidden_by_user_func( | |
| 1250 | + sqlite3_context *context, | |
| 1251 | + int argc, | |
| 1252 | + sqlite3_value **argv | |
| 1253 | +){ | |
| 1254 | + static Glob *pGlob = 0; | |
| 1255 | + static int isInit = 0; | |
| 1256 | + const char *zUser; | |
| 1257 | + if( !isInit ){ | |
| 1258 | + const char *zPat = db_get("hide-by-user", 0); | |
| 1259 | + pGlob = zPat ? glob_create(zPat) : 0; | |
| 1260 | + isInit = 1; | |
| 1261 | + } | |
| 1262 | + zUser = (const char*)sqlite3_value_text(argv[0]); | |
| 1263 | + sqlite3_result_int(context, | |
| 1264 | + pGlob!=0 && zUser!=0 && glob_match(pGlob, zUser)!=0); | |
| 1265 | +} | |
| 1266 | + | |
| 1267 | +/* | |
| 1268 | +** Register hidden_by_user() and return true if the "hide-by-user" | |
| 1269 | +** setting is non-empty. | |
| 1270 | +*/ | |
| 1271 | +static int timeline_enable_hide_by_user(void){ | |
| 1272 | + const char *zPat = db_get("hide-by-user", 0); | |
| 1273 | + if( zPat==0 || zPat[0]==0 ) return 0; | |
| 1274 | + sqlite3_create_function(g.db, "hidden_by_user", 1, SQLITE_UTF8, 0, | |
| 1275 | + timeline_hidden_by_user_func, 0, 0); | |
| 1276 | + return 1; | |
| 1277 | +} | |
| 1242 | 1278 | |
| 1243 | 1279 | /* |
| 1244 | 1280 | ** zDate is a localtime date. Insert records into the |
| 1245 | 1281 | ** "timeline" table to cause <hr> to be inserted on zDate. |
| 1246 | 1282 | */ |
| @@ -2261,10 +2297,15 @@ | ||
| 2261 | 2297 | blob_append_sql(&sql, |
| 2262 | 2298 | " AND NOT EXISTS(SELECT 1 FROM tagxref" |
| 2263 | 2299 | " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)\n", |
| 2264 | 2300 | TAG_HIDDEN |
| 2265 | 2301 | ); |
| 2302 | + if( timeline_enable_hide_by_user() ){ | |
| 2303 | + blob_append_sql(&sql, | |
| 2304 | + " AND NOT (event.type='ci' AND hidden_by_user(coalesce(euser,user)))\n" | |
| 2305 | + ); | |
| 2306 | + } | |
| 2266 | 2307 | } |
| 2267 | 2308 | if( from_rid && !to_rid && (P("ft")!=0 || P("bt")!=0) ){ |
| 2268 | 2309 | const char *zTo = P("ft"); |
| 2269 | 2310 | if( zTo ){ |
| 2270 | 2311 | from_to_mode = 1; |
| @@ -3049,10 +3090,20 @@ | ||
| 3049 | 3090 | " FROM related_nodes, tagxref\n" |
| 3050 | 3091 | " WHERE tagid=%d AND tagtype>0\n" |
| 3051 | 3092 | " AND tagxref.rid=related_nodes.rid)", |
| 3052 | 3093 | TAG_HIDDEN |
| 3053 | 3094 | ); |
| 3095 | + if( timeline_enable_hide_by_user() ){ | |
| 3096 | + db_multi_exec( | |
| 3097 | + "DELETE FROM related_nodes\n" | |
| 3098 | + " WHERE rid IN (SELECT related_nodes.rid\n" | |
| 3099 | + " FROM related_nodes, event\n" | |
| 3100 | + " WHERE event.objid=related_nodes.rid\n" | |
| 3101 | + " AND event.type='ci'\n" | |
| 3102 | + " AND hidden_by_user(coalesce(euser,user)))" | |
| 3103 | + ); | |
| 3104 | + } | |
| 3054 | 3105 | } |
| 3055 | 3106 | } |
| 3056 | 3107 | } |
| 3057 | 3108 | if( (zType[0]=='w' && !g.perm.RdWiki) |
| 3058 | 3109 | || (zType[0]=='t' && !g.perm.RdTkt) |
| 3059 | 3110 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1237,10 +1237,46 @@ | |
| 1237 | @ FROM event CROSS JOIN blob |
| 1238 | @ WHERE blob.rid=event.objid |
| 1239 | ; |
| 1240 | return zBase; |
| 1241 | } |
| 1242 | |
| 1243 | /* |
| 1244 | ** zDate is a localtime date. Insert records into the |
| 1245 | ** "timeline" table to cause <hr> to be inserted on zDate. |
| 1246 | */ |
| @@ -2261,10 +2297,15 @@ | |
| 2261 | blob_append_sql(&sql, |
| 2262 | " AND NOT EXISTS(SELECT 1 FROM tagxref" |
| 2263 | " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)\n", |
| 2264 | TAG_HIDDEN |
| 2265 | ); |
| 2266 | } |
| 2267 | if( from_rid && !to_rid && (P("ft")!=0 || P("bt")!=0) ){ |
| 2268 | const char *zTo = P("ft"); |
| 2269 | if( zTo ){ |
| 2270 | from_to_mode = 1; |
| @@ -3049,10 +3090,20 @@ | |
| 3049 | " FROM related_nodes, tagxref\n" |
| 3050 | " WHERE tagid=%d AND tagtype>0\n" |
| 3051 | " AND tagxref.rid=related_nodes.rid)", |
| 3052 | TAG_HIDDEN |
| 3053 | ); |
| 3054 | } |
| 3055 | } |
| 3056 | } |
| 3057 | if( (zType[0]=='w' && !g.perm.RdWiki) |
| 3058 | || (zType[0]=='t' && !g.perm.RdTkt) |
| 3059 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1237,10 +1237,46 @@ | |
| 1237 | @ FROM event CROSS JOIN blob |
| 1238 | @ WHERE blob.rid=event.objid |
| 1239 | ; |
| 1240 | return zBase; |
| 1241 | } |
| 1242 | |
| 1243 | /* |
| 1244 | ** SQL function: hidden_by_user(X) |
| 1245 | ** |
| 1246 | ** Return true if X matches one of the GLOB patterns in the "hide-by-user" |
| 1247 | ** setting. |
| 1248 | */ |
| 1249 | static void timeline_hidden_by_user_func( |
| 1250 | sqlite3_context *context, |
| 1251 | int argc, |
| 1252 | sqlite3_value **argv |
| 1253 | ){ |
| 1254 | static Glob *pGlob = 0; |
| 1255 | static int isInit = 0; |
| 1256 | const char *zUser; |
| 1257 | if( !isInit ){ |
| 1258 | const char *zPat = db_get("hide-by-user", 0); |
| 1259 | pGlob = zPat ? glob_create(zPat) : 0; |
| 1260 | isInit = 1; |
| 1261 | } |
| 1262 | zUser = (const char*)sqlite3_value_text(argv[0]); |
| 1263 | sqlite3_result_int(context, |
| 1264 | pGlob!=0 && zUser!=0 && glob_match(pGlob, zUser)!=0); |
| 1265 | } |
| 1266 | |
| 1267 | /* |
| 1268 | ** Register hidden_by_user() and return true if the "hide-by-user" |
| 1269 | ** setting is non-empty. |
| 1270 | */ |
| 1271 | static int timeline_enable_hide_by_user(void){ |
| 1272 | const char *zPat = db_get("hide-by-user", 0); |
| 1273 | if( zPat==0 || zPat[0]==0 ) return 0; |
| 1274 | sqlite3_create_function(g.db, "hidden_by_user", 1, SQLITE_UTF8, 0, |
| 1275 | timeline_hidden_by_user_func, 0, 0); |
| 1276 | return 1; |
| 1277 | } |
| 1278 | |
| 1279 | /* |
| 1280 | ** zDate is a localtime date. Insert records into the |
| 1281 | ** "timeline" table to cause <hr> to be inserted on zDate. |
| 1282 | */ |
| @@ -2261,10 +2297,15 @@ | |
| 2297 | blob_append_sql(&sql, |
| 2298 | " AND NOT EXISTS(SELECT 1 FROM tagxref" |
| 2299 | " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)\n", |
| 2300 | TAG_HIDDEN |
| 2301 | ); |
| 2302 | if( timeline_enable_hide_by_user() ){ |
| 2303 | blob_append_sql(&sql, |
| 2304 | " AND NOT (event.type='ci' AND hidden_by_user(coalesce(euser,user)))\n" |
| 2305 | ); |
| 2306 | } |
| 2307 | } |
| 2308 | if( from_rid && !to_rid && (P("ft")!=0 || P("bt")!=0) ){ |
| 2309 | const char *zTo = P("ft"); |
| 2310 | if( zTo ){ |
| 2311 | from_to_mode = 1; |
| @@ -3049,10 +3090,20 @@ | |
| 3090 | " FROM related_nodes, tagxref\n" |
| 3091 | " WHERE tagid=%d AND tagtype>0\n" |
| 3092 | " AND tagxref.rid=related_nodes.rid)", |
| 3093 | TAG_HIDDEN |
| 3094 | ); |
| 3095 | if( timeline_enable_hide_by_user() ){ |
| 3096 | db_multi_exec( |
| 3097 | "DELETE FROM related_nodes\n" |
| 3098 | " WHERE rid IN (SELECT related_nodes.rid\n" |
| 3099 | " FROM related_nodes, event\n" |
| 3100 | " WHERE event.objid=related_nodes.rid\n" |
| 3101 | " AND event.type='ci'\n" |
| 3102 | " AND hidden_by_user(coalesce(euser,user)))" |
| 3103 | ); |
| 3104 | } |
| 3105 | } |
| 3106 | } |
| 3107 | } |
| 3108 | if( (zType[0]=='w' && !g.perm.RdWiki) |
| 3109 | || (zType[0]=='t' && !g.perm.RdTkt) |
| 3110 |