Fossil SCM

Initial version of the /setup_forum page.

stephan 2023-06-07 12:07 forumpost-locking
Commit b370c189bcad53d60649309c576c39d68329376f340655aa94210be39eed92df
+4 -4
--- src/db.c
+++ src/db.c
@@ -4652,14 +4652,14 @@
46524652
** which will cause the client to avoid generating a delta
46534653
** manifest.
46544654
*/
46554655
/*
46564656
** SETTING: forum-close-policy boolean default=off
4657
-** If true, forum moderators may close forum posts, else only
4658
-** administrators may do so. Note that this only affects the forum web
4659
-** UI, not post-closing tags which arrive via the command-line or from
4660
-** synchronization with a remote.
4657
+** If true, forum moderators may close/re-open forum posts, and reply
4658
+** to closed posts. If false, only administrators may do so. Note that
4659
+** this only affects the forum web UI, not post-closing tags which
4660
+** arrive via the command-line or from synchronization with a remote.
46614661
*/
46624662
/*
46634663
** SETTING: gdiff-command width=40 default=gdiff sensitive
46644664
** The value is an external command to run when performing a graphical
46654665
** diff. If undefined, text diff will be used.
46664666
--- src/db.c
+++ src/db.c
@@ -4652,14 +4652,14 @@
4652 ** which will cause the client to avoid generating a delta
4653 ** manifest.
4654 */
4655 /*
4656 ** SETTING: forum-close-policy boolean default=off
4657 ** If true, forum moderators may close forum posts, else only
4658 ** administrators may do so. Note that this only affects the forum web
4659 ** UI, not post-closing tags which arrive via the command-line or from
4660 ** synchronization with a remote.
4661 */
4662 /*
4663 ** SETTING: gdiff-command width=40 default=gdiff sensitive
4664 ** The value is an external command to run when performing a graphical
4665 ** diff. If undefined, text diff will be used.
4666
--- src/db.c
+++ src/db.c
@@ -4652,14 +4652,14 @@
4652 ** which will cause the client to avoid generating a delta
4653 ** manifest.
4654 */
4655 /*
4656 ** SETTING: forum-close-policy boolean default=off
4657 ** If true, forum moderators may close/re-open forum posts, and reply
4658 ** to closed posts. If false, only administrators may do so. Note that
4659 ** this only affects the forum web UI, not post-closing tags which
4660 ** arrive via the command-line or from synchronization with a remote.
4661 */
4662 /*
4663 ** SETTING: gdiff-command width=40 default=gdiff sensitive
4664 ** The value is an external command to run when performing a graphical
4665 ** diff. If undefined, text diff will be used.
4666
--- src/default.css
+++ src/default.css
@@ -1028,10 +1028,30 @@
10281028
background-color: #cef;
10291029
}
10301030
div.forumObs {
10311031
color: #bbb;
10321032
}
1033
+
1034
+div.setup_forum-column {
1035
+ display: flex;
1036
+ flex-direction: column;
1037
+}
1038
+
1039
+body.cpage-setup_forum > .content table {
1040
+ margin-bottom: 1em;
1041
+}
1042
+body.cpage-setup_forum > .content table.bordered {
1043
+ border: 1px solid;
1044
+ border-radius: 0.25em;
1045
+}
1046
+body.cpage-setup_forum > .content table td,
1047
+body.cpage-setup_forum > .content table th {
1048
+ text-align: left;
1049
+}
1050
+body.cpage-setup_forum table.forum-settings-list > tbody > tr > td {
1051
+ min-width: 2em;
1052
+}
10331053
10341054
#capabilitySummary {
10351055
text-align: center;
10361056
}
10371057
#capabilitySummary td {
10381058
--- src/default.css
+++ src/default.css
@@ -1028,10 +1028,30 @@
1028 background-color: #cef;
1029 }
1030 div.forumObs {
1031 color: #bbb;
1032 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1033
1034 #capabilitySummary {
1035 text-align: center;
1036 }
1037 #capabilitySummary td {
1038
--- src/default.css
+++ src/default.css
@@ -1028,10 +1028,30 @@
1028 background-color: #cef;
1029 }
1030 div.forumObs {
1031 color: #bbb;
1032 }
1033
1034 div.setup_forum-column {
1035 display: flex;
1036 flex-direction: column;
1037 }
1038
1039 body.cpage-setup_forum > .content table {
1040 margin-bottom: 1em;
1041 }
1042 body.cpage-setup_forum > .content table.bordered {
1043 border: 1px solid;
1044 border-radius: 0.25em;
1045 }
1046 body.cpage-setup_forum > .content table td,
1047 body.cpage-setup_forum > .content table th {
1048 text-align: left;
1049 }
1050 body.cpage-setup_forum table.forum-settings-list > tbody > tr > td {
1051 min-width: 2em;
1052 }
1053
1054 #capabilitySummary {
1055 text-align: center;
1056 }
1057 #capabilitySummary td {
1058
+121
--- src/forum.c
+++ src/forum.c
@@ -1802,10 +1802,131 @@
18021802
}
18031803
forum_render_debug_options();
18041804
@ </form>
18051805
forum_emit_js();
18061806
forumpost_emit_closed_state(fpid, iClosed);
1807
+ style_finish_page();
1808
+}
1809
+
1810
+/*
1811
+** WEBPAGE: setup_forum
1812
+**
1813
+** Forum configuration and metrics.
1814
+*/
1815
+void forum_setup(void){
1816
+ /* boolean config settings specific to the forum. */
1817
+ const char * zSettingsBool[] = {
1818
+ "forum-close-policy",
1819
+ NULL /* sentinel entry */
1820
+ };
1821
+
1822
+ login_check_credentials();
1823
+ if( !g.perm.Setup ){
1824
+ login_needed(g.anon.Setup);
1825
+ return;
1826
+ }
1827
+ style_set_current_feature("forum");
1828
+ style_header("Forum Setup");
1829
+
1830
+ @ <h2>Metrics</h2>
1831
+ {
1832
+ int nPosts = db_int(0, "SELECT COUNT(*) FROM event WHERE type='f'");
1833
+ @ <p><a href='%R/forum'>Forum posts</a>:
1834
+ @ <a href='%R/timeline?y=f'>%d(nPosts)</a></p>
1835
+ }
1836
+
1837
+ @ <h2>Supervisors</h2>
1838
+ @ <p>Users with capabilities 's', 'a', or '6'.</p>
1839
+ {
1840
+ Stmt q = empty_Stmt;
1841
+ int nRows = 0;
1842
+ db_prepare(&q, "SELECT uid, login, cap FROM user "
1843
+ "WHERE cap GLOB '*[as6]*' ORDER BY login");
1844
+ @ <table class='bordered'>
1845
+ @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1846
+ @ <tbody>
1847
+ while( SQLITE_ROW==db_step(&q) ){
1848
+ const int iUid = db_column_int(&q, 0);
1849
+ const char *zUser = db_column_text(&q, 1);
1850
+ const char *zCap = db_column_text(&q, 2);
1851
+ ++nRows;
1852
+ @ <tr>
1853
+ @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1854
+ @ <td>(%h(zCap))</td>
1855
+ @ </tr>
1856
+ }
1857
+ db_finalize(&q);
1858
+ @</tbody></table>
1859
+ if( 0==nRows ){
1860
+ @ No supervisors
1861
+ }else{
1862
+ @ %d(nRows) supervisor(s)
1863
+ }
1864
+ }
1865
+
1866
+ @ <h2>Moderators</h2>
1867
+ @ <p>Users with capability '5'.</p>
1868
+ {
1869
+ Stmt q = empty_Stmt;
1870
+ int nRows = 0;
1871
+ db_prepare(&q, "SELECT uid, login, cap FROM user "
1872
+ "WHERE cap GLOB '*5*' ORDER BY login");
1873
+ @ <table class='bordered'>
1874
+ @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1875
+ @ <tbody>
1876
+ while( SQLITE_ROW==db_step(&q) ){
1877
+ const int iUid = db_column_int(&q, 0);
1878
+ const char *zUser = db_column_text(&q, 1);
1879
+ const char *zCap = db_column_text(&q, 2);
1880
+ ++nRows;
1881
+ @ <tr>
1882
+ @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1883
+ @ <td>(%h(zCap))</td>
1884
+ @ </tr>
1885
+ }
1886
+ db_finalize(&q);
1887
+ @ </tbody></table>
1888
+ if( 0==nRows ){
1889
+ @ No non-supervisor moderators
1890
+ }else{
1891
+ @ %d(nRows) moderator(s)
1892
+ }
1893
+ }
1894
+
1895
+ @ <h2>Settings</h2>
1896
+ @ <p>Configuration settings specific to the forum.</p>
1897
+ if( P("submit") && cgi_csrf_safe(1) ){
1898
+ int i = 0;
1899
+ const char *zSetting;
1900
+ login_verify_csrf_secret();
1901
+ db_begin_transaction();
1902
+ while( (zSetting = zSettingsBool[i++]) ){
1903
+ const char *z = P(zSetting);
1904
+ if( !z || !z[0] ) z = "off";
1905
+ db_set(zSetting/*works-like:"x"*/, z, 0);
1906
+ }
1907
+ db_end_transaction(0);
1908
+ @ <p><em>Settings saved.</em></p>
1909
+ }
1910
+ {
1911
+ int i = 0;
1912
+ const char *zSetting;
1913
+ @ <form action="%R/setup_forum" method="post">
1914
+ login_insert_csrf_secret();
1915
+ @ <table class='forum-settings-list'><tbody>
1916
+ while( (zSetting = zSettingsBool[i++]) ){
1917
+ @ <tr><td>
1918
+ onoff_attribute("", zSetting, zSetting/*works-like:"x"*/, 0, 0);
1919
+ @ </td><td>
1920
+ @ <a href='%R/help?cmd=%h(zSetting)'>%h(zSetting)</a>
1921
+ @ </td></tr>
1922
+ }
1923
+ @ </tbody></table>
1924
+ @ <input type='submit' name='submit' value='Apply changes'>
1925
+ @ </form>
1926
+ }
1927
+
18071928
style_finish_page();
18081929
}
18091930
18101931
/*
18111932
** WEBPAGE: forummain
18121933
--- src/forum.c
+++ src/forum.c
@@ -1802,10 +1802,131 @@
1802 }
1803 forum_render_debug_options();
1804 @ </form>
1805 forum_emit_js();
1806 forumpost_emit_closed_state(fpid, iClosed);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1807 style_finish_page();
1808 }
1809
1810 /*
1811 ** WEBPAGE: forummain
1812
--- src/forum.c
+++ src/forum.c
@@ -1802,10 +1802,131 @@
1802 }
1803 forum_render_debug_options();
1804 @ </form>
1805 forum_emit_js();
1806 forumpost_emit_closed_state(fpid, iClosed);
1807 style_finish_page();
1808 }
1809
1810 /*
1811 ** WEBPAGE: setup_forum
1812 **
1813 ** Forum configuration and metrics.
1814 */
1815 void forum_setup(void){
1816 /* boolean config settings specific to the forum. */
1817 const char * zSettingsBool[] = {
1818 "forum-close-policy",
1819 NULL /* sentinel entry */
1820 };
1821
1822 login_check_credentials();
1823 if( !g.perm.Setup ){
1824 login_needed(g.anon.Setup);
1825 return;
1826 }
1827 style_set_current_feature("forum");
1828 style_header("Forum Setup");
1829
1830 @ <h2>Metrics</h2>
1831 {
1832 int nPosts = db_int(0, "SELECT COUNT(*) FROM event WHERE type='f'");
1833 @ <p><a href='%R/forum'>Forum posts</a>:
1834 @ <a href='%R/timeline?y=f'>%d(nPosts)</a></p>
1835 }
1836
1837 @ <h2>Supervisors</h2>
1838 @ <p>Users with capabilities 's', 'a', or '6'.</p>
1839 {
1840 Stmt q = empty_Stmt;
1841 int nRows = 0;
1842 db_prepare(&q, "SELECT uid, login, cap FROM user "
1843 "WHERE cap GLOB '*[as6]*' ORDER BY login");
1844 @ <table class='bordered'>
1845 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1846 @ <tbody>
1847 while( SQLITE_ROW==db_step(&q) ){
1848 const int iUid = db_column_int(&q, 0);
1849 const char *zUser = db_column_text(&q, 1);
1850 const char *zCap = db_column_text(&q, 2);
1851 ++nRows;
1852 @ <tr>
1853 @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1854 @ <td>(%h(zCap))</td>
1855 @ </tr>
1856 }
1857 db_finalize(&q);
1858 @</tbody></table>
1859 if( 0==nRows ){
1860 @ No supervisors
1861 }else{
1862 @ %d(nRows) supervisor(s)
1863 }
1864 }
1865
1866 @ <h2>Moderators</h2>
1867 @ <p>Users with capability '5'.</p>
1868 {
1869 Stmt q = empty_Stmt;
1870 int nRows = 0;
1871 db_prepare(&q, "SELECT uid, login, cap FROM user "
1872 "WHERE cap GLOB '*5*' ORDER BY login");
1873 @ <table class='bordered'>
1874 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1875 @ <tbody>
1876 while( SQLITE_ROW==db_step(&q) ){
1877 const int iUid = db_column_int(&q, 0);
1878 const char *zUser = db_column_text(&q, 1);
1879 const char *zCap = db_column_text(&q, 2);
1880 ++nRows;
1881 @ <tr>
1882 @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1883 @ <td>(%h(zCap))</td>
1884 @ </tr>
1885 }
1886 db_finalize(&q);
1887 @ </tbody></table>
1888 if( 0==nRows ){
1889 @ No non-supervisor moderators
1890 }else{
1891 @ %d(nRows) moderator(s)
1892 }
1893 }
1894
1895 @ <h2>Settings</h2>
1896 @ <p>Configuration settings specific to the forum.</p>
1897 if( P("submit") && cgi_csrf_safe(1) ){
1898 int i = 0;
1899 const char *zSetting;
1900 login_verify_csrf_secret();
1901 db_begin_transaction();
1902 while( (zSetting = zSettingsBool[i++]) ){
1903 const char *z = P(zSetting);
1904 if( !z || !z[0] ) z = "off";
1905 db_set(zSetting/*works-like:"x"*/, z, 0);
1906 }
1907 db_end_transaction(0);
1908 @ <p><em>Settings saved.</em></p>
1909 }
1910 {
1911 int i = 0;
1912 const char *zSetting;
1913 @ <form action="%R/setup_forum" method="post">
1914 login_insert_csrf_secret();
1915 @ <table class='forum-settings-list'><tbody>
1916 while( (zSetting = zSettingsBool[i++]) ){
1917 @ <tr><td>
1918 onoff_attribute("", zSetting, zSetting/*works-like:"x"*/, 0, 0);
1919 @ </td><td>
1920 @ <a href='%R/help?cmd=%h(zSetting)'>%h(zSetting)</a>
1921 @ </td></tr>
1922 }
1923 @ </tbody></table>
1924 @ <input type='submit' name='submit' value='Apply changes'>
1925 @ </form>
1926 }
1927
1928 style_finish_page();
1929 }
1930
1931 /*
1932 ** WEBPAGE: forummain
1933
--- src/setup.c
+++ src/setup.c
@@ -130,10 +130,12 @@
130130
"Configure the wiki for this repository");
131131
setup_menu_entry("Interwiki Map", "intermap",
132132
"Mapping keywords for interwiki links");
133133
setup_menu_entry("Chat", "setup_chat",
134134
"Configure the chatroom");
135
+ setup_menu_entry("Forum", "setup_forum",
136
+ "Forum config and metrics");
135137
}
136138
setup_menu_entry("Search","srchsetup",
137139
"Configure the built-in search engine");
138140
setup_menu_entry("URL Aliases", "waliassetup",
139141
"Configure URL aliases");
140142
--- src/setup.c
+++ src/setup.c
@@ -130,10 +130,12 @@
130 "Configure the wiki for this repository");
131 setup_menu_entry("Interwiki Map", "intermap",
132 "Mapping keywords for interwiki links");
133 setup_menu_entry("Chat", "setup_chat",
134 "Configure the chatroom");
 
 
135 }
136 setup_menu_entry("Search","srchsetup",
137 "Configure the built-in search engine");
138 setup_menu_entry("URL Aliases", "waliassetup",
139 "Configure URL aliases");
140
--- src/setup.c
+++ src/setup.c
@@ -130,10 +130,12 @@
130 "Configure the wiki for this repository");
131 setup_menu_entry("Interwiki Map", "intermap",
132 "Mapping keywords for interwiki links");
133 setup_menu_entry("Chat", "setup_chat",
134 "Configure the chatroom");
135 setup_menu_entry("Forum", "setup_forum",
136 "Forum config and metrics");
137 }
138 setup_menu_entry("Search","srchsetup",
139 "Configure the built-in search engine");
140 setup_menu_entry("URL Aliases", "waliassetup",
141 "Configure URL aliases");
142

Keyboard Shortcuts

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