| | @@ -1802,10 +1802,131 @@ |
| 1802 | 1802 | } |
| 1803 | 1803 | forum_render_debug_options(); |
| 1804 | 1804 | @ </form> |
| 1805 | 1805 | forum_emit_js(); |
| 1806 | 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 | + |
| 1807 | 1928 | style_finish_page(); |
| 1808 | 1929 | } |
| 1809 | 1930 | |
| 1810 | 1931 | /* |
| 1811 | 1932 | ** WEBPAGE: forummain |
| 1812 | 1933 | |