Fossil SCM
Simplifications to the Forum setup page.
Commit
25e4b54238f705983422159ccc8d8f5a0d0af18f42b4ec7e71620dd6f20efa80
Parent
f646537cb626f11…
1 file changed
+13
-25
+13
-25
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -1804,45 +1804,40 @@ | ||
| 1804 | 1804 | @ <p><a href='%R/forum'>Forum posts</a>: |
| 1805 | 1805 | @ <a href='%R/timeline?y=f'>%d(nPosts)</a></p> |
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | @ <h2>Supervisors</h2> |
| 1809 | - @ <p>Users with capabilities 's', 'a', or '6'.</p> | |
| 1810 | 1809 | { |
| 1811 | 1810 | Stmt q = empty_Stmt; |
| 1812 | - int nRows = 0; | |
| 1813 | 1811 | db_prepare(&q, "SELECT uid, login, cap FROM user " |
| 1814 | 1812 | "WHERE cap GLOB '*[as6]*' ORDER BY login"); |
| 1815 | 1813 | @ <table class='bordered'> |
| 1816 | 1814 | @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead> |
| 1817 | 1815 | @ <tbody> |
| 1818 | 1816 | while( SQLITE_ROW==db_step(&q) ){ |
| 1819 | 1817 | const int iUid = db_column_int(&q, 0); |
| 1820 | 1818 | const char *zUser = db_column_text(&q, 1); |
| 1821 | 1819 | const char *zCap = db_column_text(&q, 2); |
| 1822 | - ++nRows; | |
| 1823 | 1820 | @ <tr> |
| 1824 | 1821 | @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td> |
| 1825 | 1822 | @ <td>(%h(zCap))</td> |
| 1826 | 1823 | @ </tr> |
| 1827 | 1824 | } |
| 1828 | 1825 | db_finalize(&q); |
| 1829 | 1826 | @</tbody></table> |
| 1830 | - if( 0==nRows ){ | |
| 1831 | - @ No supervisors | |
| 1832 | - }else{ | |
| 1833 | - @ %d(nRows) supervisor(s) | |
| 1834 | - } | |
| 1835 | 1827 | } |
| 1836 | 1828 | |
| 1837 | 1829 | @ <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{ | |
| 1840 | 1834 | Stmt q = empty_Stmt; |
| 1841 | 1835 | int nRows = 0; |
| 1842 | 1836 | 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"); | |
| 1844 | 1839 | @ <table class='bordered'> |
| 1845 | 1840 | @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead> |
| 1846 | 1841 | @ <tbody> |
| 1847 | 1842 | while( SQLITE_ROW==db_step(&q) ){ |
| 1848 | 1843 | const int iUid = db_column_int(&q, 0); |
| @@ -1854,19 +1849,13 @@ | ||
| 1854 | 1849 | @ <td>(%h(zCap))</td> |
| 1855 | 1850 | @ </tr> |
| 1856 | 1851 | } |
| 1857 | 1852 | db_finalize(&q); |
| 1858 | 1853 | @ </tbody></table> |
| 1859 | - if( 0==nRows ){ | |
| 1860 | - @ No non-supervisor moderators | |
| 1861 | - }else{ | |
| 1862 | - @ %d(nRows) moderator(s) | |
| 1863 | - } | |
| 1864 | 1854 | } |
| 1865 | 1855 | |
| 1866 | 1856 | @ <h2>Settings</h2> |
| 1867 | - @ <p>Configuration settings specific to the forum.</p> | |
| 1868 | 1857 | if( P("submit") && cgi_csrf_safe(2) ){ |
| 1869 | 1858 | int i = 0; |
| 1870 | 1859 | db_begin_transaction(); |
| 1871 | 1860 | for(i=0; i<ArraySize(azForumSettings); i++){ |
| 1872 | 1861 | char zQP[4]; |
| @@ -1895,23 +1884,22 @@ | ||
| 1895 | 1884 | zQP[0] = 'a'+i; |
| 1896 | 1885 | zQP[1] = zQP[0]; |
| 1897 | 1886 | zQP[2] = 0; |
| 1898 | 1887 | if( pSetting->width==0 ){ |
| 1899 | 1888 | /* Boolean setting */ |
| 1900 | - @ <tr><td> <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>: | |
| 1902 | 1891 | @ </td><td> |
| 1903 | - @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a> | |
| 1904 | - @ </td> | |
| 1905 | - @ <td> </td></tr> | |
| 1892 | + onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0); | |
| 1893 | + @ </td></tr> | |
| 1906 | 1894 | }else{ |
| 1907 | 1895 | /* 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> | |
| 1909 | 1899 | entry_attribute("", 25, pSetting->name, zQP/*works-like:""*/, |
| 1910 | 1900 | pSetting->def, 0); |
| 1911 | - @ </td><td> | |
| 1912 | - @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a> | |
| 1913 | 1901 | @ </td></tr> |
| 1914 | 1902 | } |
| 1915 | 1903 | } |
| 1916 | 1904 | @ </tbody></table> |
| 1917 | 1905 | @ <input type='submit' name='submit' value='Apply changes'> |
| 1918 | 1906 |
| --- 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> <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> </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 |