Fossil SCM

Simplifications to the Forum setup page.

drh 2024-11-19 13:08 trunk
Commit 25e4b54238f705983422159ccc8d8f5a0d0af18f42b4ec7e71620dd6f20efa80
1 file changed +13 -25
+13 -25
--- src/forum.c
+++ src/forum.c
@@ -1804,45 +1804,40 @@
18041804
@ <p><a href='%R/forum'>Forum posts</a>:
18051805
@ <a href='%R/timeline?y=f'>%d(nPosts)</a></p>
18061806
}
18071807
18081808
@ <h2>Supervisors</h2>
1809
- @ <p>Users with capabilities 's', 'a', or '6'.</p>
18101809
{
18111810
Stmt q = empty_Stmt;
1812
- int nRows = 0;
18131811
db_prepare(&q, "SELECT uid, login, cap FROM user "
18141812
"WHERE cap GLOB '*[as6]*' ORDER BY login");
18151813
@ <table class='bordered'>
18161814
@ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
18171815
@ <tbody>
18181816
while( SQLITE_ROW==db_step(&q) ){
18191817
const int iUid = db_column_int(&q, 0);
18201818
const char *zUser = db_column_text(&q, 1);
18211819
const char *zCap = db_column_text(&q, 2);
1822
- ++nRows;
18231820
@ <tr>
18241821
@ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
18251822
@ <td>(%h(zCap))</td>
18261823
@ </tr>
18271824
}
18281825
db_finalize(&q);
18291826
@</tbody></table>
1830
- if( 0==nRows ){
1831
- @ No supervisors
1832
- }else{
1833
- @ %d(nRows) supervisor(s)
1834
- }
18351827
}
18361828
18371829
@ <h2>Moderators</h2>
1838
- @ <p>Users with capability '5'.</p>
1839
- {
1830
+ if( db_int(0, "SELECT count(*) FROM user "
1831
+ " WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'")==0 ){
1832
+ @ <p>No non-supervisor moderators
1833
+ }else{
18401834
Stmt q = empty_Stmt;
18411835
int nRows = 0;
18421836
db_prepare(&q, "SELECT uid, login, cap FROM user "
1843
- "WHERE cap GLOB '*5*' ORDER BY login");
1837
+ "WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'"
1838
+ " ORDER BY login");
18441839
@ <table class='bordered'>
18451840
@ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
18461841
@ <tbody>
18471842
while( SQLITE_ROW==db_step(&q) ){
18481843
const int iUid = db_column_int(&q, 0);
@@ -1854,19 +1849,13 @@
18541849
@ <td>(%h(zCap))</td>
18551850
@ </tr>
18561851
}
18571852
db_finalize(&q);
18581853
@ </tbody></table>
1859
- if( 0==nRows ){
1860
- @ No non-supervisor moderators
1861
- }else{
1862
- @ %d(nRows) moderator(s)
1863
- }
18641854
}
18651855
18661856
@ <h2>Settings</h2>
1867
- @ <p>Configuration settings specific to the forum.</p>
18681857
if( P("submit") && cgi_csrf_safe(2) ){
18691858
int i = 0;
18701859
db_begin_transaction();
18711860
for(i=0; i<ArraySize(azForumSettings); i++){
18721861
char zQP[4];
@@ -1895,23 +1884,22 @@
18951884
zQP[0] = 'a'+i;
18961885
zQP[1] = zQP[0];
18971886
zQP[2] = 0;
18981887
if( pSetting->width==0 ){
18991888
/* Boolean setting */
1900
- @ <tr><td>&nbsp;<td width="5">
1901
- onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0);
1889
+ @ <tr><td align="right">
1890
+ @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>:
19021891
@ </td><td>
1903
- @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1904
- @ </td>
1905
- @ <td>&nbsp;</td></tr>
1892
+ onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0);
1893
+ @ </td></tr>
19061894
}else{
19071895
/* Text value setting */
1908
- @ <tr><td colspan="2">
1896
+ @ <tr><td align="right">
1897
+ @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>:
1898
+ @ </td><td>
19091899
entry_attribute("", 25, pSetting->name, zQP/*works-like:""*/,
19101900
pSetting->def, 0);
1911
- @ </td><td>
1912
- @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
19131901
@ </td></tr>
19141902
}
19151903
}
19161904
@ </tbody></table>
19171905
@ <input type='submit' name='submit' value='Apply changes'>
19181906
--- src/forum.c
+++ src/forum.c
@@ -1804,45 +1804,40 @@
1804 @ <p><a href='%R/forum'>Forum posts</a>:
1805 @ <a href='%R/timeline?y=f'>%d(nPosts)</a></p>
1806 }
1807
1808 @ <h2>Supervisors</h2>
1809 @ <p>Users with capabilities 's', 'a', or '6'.</p>
1810 {
1811 Stmt q = empty_Stmt;
1812 int nRows = 0;
1813 db_prepare(&q, "SELECT uid, login, cap FROM user "
1814 "WHERE cap GLOB '*[as6]*' ORDER BY login");
1815 @ <table class='bordered'>
1816 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1817 @ <tbody>
1818 while( SQLITE_ROW==db_step(&q) ){
1819 const int iUid = db_column_int(&q, 0);
1820 const char *zUser = db_column_text(&q, 1);
1821 const char *zCap = db_column_text(&q, 2);
1822 ++nRows;
1823 @ <tr>
1824 @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1825 @ <td>(%h(zCap))</td>
1826 @ </tr>
1827 }
1828 db_finalize(&q);
1829 @</tbody></table>
1830 if( 0==nRows ){
1831 @ No supervisors
1832 }else{
1833 @ %d(nRows) supervisor(s)
1834 }
1835 }
1836
1837 @ <h2>Moderators</h2>
1838 @ <p>Users with capability '5'.</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 '*5*' 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);
@@ -1854,19 +1849,13 @@
1854 @ <td>(%h(zCap))</td>
1855 @ </tr>
1856 }
1857 db_finalize(&q);
1858 @ </tbody></table>
1859 if( 0==nRows ){
1860 @ No non-supervisor moderators
1861 }else{
1862 @ %d(nRows) moderator(s)
1863 }
1864 }
1865
1866 @ <h2>Settings</h2>
1867 @ <p>Configuration settings specific to the forum.</p>
1868 if( P("submit") && cgi_csrf_safe(2) ){
1869 int i = 0;
1870 db_begin_transaction();
1871 for(i=0; i<ArraySize(azForumSettings); i++){
1872 char zQP[4];
@@ -1895,23 +1884,22 @@
1895 zQP[0] = 'a'+i;
1896 zQP[1] = zQP[0];
1897 zQP[2] = 0;
1898 if( pSetting->width==0 ){
1899 /* Boolean setting */
1900 @ <tr><td>&nbsp;<td width="5">
1901 onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0);
1902 @ </td><td>
1903 @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1904 @ </td>
1905 @ <td>&nbsp;</td></tr>
1906 }else{
1907 /* Text value setting */
1908 @ <tr><td colspan="2">
 
 
1909 entry_attribute("", 25, pSetting->name, zQP/*works-like:""*/,
1910 pSetting->def, 0);
1911 @ </td><td>
1912 @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1913 @ </td></tr>
1914 }
1915 }
1916 @ </tbody></table>
1917 @ <input type='submit' name='submit' value='Apply changes'>
1918
--- src/forum.c
+++ src/forum.c
@@ -1804,45 +1804,40 @@
1804 @ <p><a href='%R/forum'>Forum posts</a>:
1805 @ <a href='%R/timeline?y=f'>%d(nPosts)</a></p>
1806 }
1807
1808 @ <h2>Supervisors</h2>
 
1809 {
1810 Stmt q = empty_Stmt;
 
1811 db_prepare(&q, "SELECT uid, login, cap FROM user "
1812 "WHERE cap GLOB '*[as6]*' ORDER BY login");
1813 @ <table class='bordered'>
1814 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1815 @ <tbody>
1816 while( SQLITE_ROW==db_step(&q) ){
1817 const int iUid = db_column_int(&q, 0);
1818 const char *zUser = db_column_text(&q, 1);
1819 const char *zCap = db_column_text(&q, 2);
 
1820 @ <tr>
1821 @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1822 @ <td>(%h(zCap))</td>
1823 @ </tr>
1824 }
1825 db_finalize(&q);
1826 @</tbody></table>
 
 
 
 
 
1827 }
1828
1829 @ <h2>Moderators</h2>
1830 if( db_int(0, "SELECT count(*) FROM user "
1831 " WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'")==0 ){
1832 @ <p>No non-supervisor moderators
1833 }else{
1834 Stmt q = empty_Stmt;
1835 int nRows = 0;
1836 db_prepare(&q, "SELECT uid, login, cap FROM user "
1837 "WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'"
1838 " ORDER BY login");
1839 @ <table class='bordered'>
1840 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
1841 @ <tbody>
1842 while( SQLITE_ROW==db_step(&q) ){
1843 const int iUid = db_column_int(&q, 0);
@@ -1854,19 +1849,13 @@
1849 @ <td>(%h(zCap))</td>
1850 @ </tr>
1851 }
1852 db_finalize(&q);
1853 @ </tbody></table>
 
 
 
 
 
1854 }
1855
1856 @ <h2>Settings</h2>
 
1857 if( P("submit") && cgi_csrf_safe(2) ){
1858 int i = 0;
1859 db_begin_transaction();
1860 for(i=0; i<ArraySize(azForumSettings); i++){
1861 char zQP[4];
@@ -1895,23 +1884,22 @@
1884 zQP[0] = 'a'+i;
1885 zQP[1] = zQP[0];
1886 zQP[2] = 0;
1887 if( pSetting->width==0 ){
1888 /* Boolean setting */
1889 @ <tr><td align="right">
1890 @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>:
1891 @ </td><td>
1892 onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0);
1893 @ </td></tr>
 
1894 }else{
1895 /* Text value setting */
1896 @ <tr><td align="right">
1897 @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>:
1898 @ </td><td>
1899 entry_attribute("", 25, pSetting->name, zQP/*works-like:""*/,
1900 pSetting->def, 0);
 
 
1901 @ </td></tr>
1902 }
1903 }
1904 @ </tbody></table>
1905 @ <input type='submit' name='submit' value='Apply changes'>
1906

Keyboard Shortcuts

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