File Annotation
Not logged in
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Copyright (c) 2007 D. Richard Hipp
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is free software; you can redistribute it and/or
dbda8d6ce9 2007-07-21       drh: ** modify it under the terms of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License as published by the Free Software Foundation; either
dbda8d6ce9 2007-07-21       drh: ** version 2 of the License, or (at your option) any later version.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is distributed in the hope that it will be useful,
dbda8d6ce9 2007-07-21       drh: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
dbda8d6ce9 2007-07-21       drh: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dbda8d6ce9 2007-07-21       drh: ** General Public License for more details.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** You should have received a copy of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License along with this library; if not, write to the
dbda8d6ce9 2007-07-21       drh: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dbda8d6ce9 2007-07-21       drh: ** Boston, MA  02111-1307, USA.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Author contact information:
dbda8d6ce9 2007-07-21       drh: **   drh@hwaci.com
dbda8d6ce9 2007-07-21       drh: **   http://www.hwaci.com/drh/
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: *******************************************************************************
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Implementation of the Setup page
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: #include <assert.h>
dbda8d6ce9 2007-07-21       drh: #include "config.h"
dbda8d6ce9 2007-07-21       drh: #include "setup.h"
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Output a single entry for a menu generated using an HTML table.
dbda8d6ce9 2007-07-21       drh: ** If zLink is not NULL or an empty string, then it is the page that
dbda8d6ce9 2007-07-21       drh: ** the menu entry will hyperlink to.  If zLink is NULL or "", then
dbda8d6ce9 2007-07-21       drh: ** the menu entry has no hyperlink - it is disabled.
dbda8d6ce9 2007-07-21       drh: */
0edee97370 2007-10-03       drh: void setup_menu_entry(
dbda8d6ce9 2007-07-21       drh:   const char *zTitle,
dbda8d6ce9 2007-07-21       drh:   const char *zLink,
dbda8d6ce9 2007-07-21       drh:   const char *zDesc
dbda8d6ce9 2007-07-21       drh: ){
5f3ddcc1b8 2007-11-25       drh:   @ <tr><td valign="top" align="right">
dbda8d6ce9 2007-07-21       drh:   if( zLink && zLink[0] ){
dbda8d6ce9 2007-07-21       drh:     @ <a href="%s(zLink)">%h(zTitle)</a>
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     @ %h(zTitle)
dbda8d6ce9 2007-07-21       drh:   }
5f3ddcc1b8 2007-11-25       drh:   @ </td><td valign="top">%h(zDesc)</td></tr>
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: /setup
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void setup_page(void){
dbda8d6ce9 2007-07-21       drh:   login_check_credentials();
dbda8d6ce9 2007-07-21       drh:   if( !g.okSetup ){
dbda8d6ce9 2007-07-21       drh:     login_needed();
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh: 
66f4caa379 2007-07-23       drh:   style_header("Setup");
5f3ddcc1b8 2007-11-25       drh:   @ <table border="0" cellspacing="20">
0edee97370 2007-10-03       drh:   setup_menu_entry("Users", "setup_ulist",
dbda8d6ce9 2007-07-21       drh:     "Grant privileges to individual users.");
0edee97370 2007-10-03       drh:   setup_menu_entry("Access", "setup_access",
dbda8d6ce9 2007-07-21       drh:     "Control access settings.");
0edee97370 2007-10-03       drh:   setup_menu_entry("Configuration", "setup_config",
c4ec179bbc 2007-07-22       drh:     "Configure the WWW components of the repository");
ebb2765954 2007-12-04       drh:   setup_menu_entry("Timeline", "setup_timeline",
ebb2765954 2007-12-04       drh:     "Timeline display preferences");
5f3ddcc1b8 2007-11-25       drh:   setup_menu_entry("Tickets", "setup_ticket",
0edee97370 2007-10-03       drh:     "Configure the trouble-ticketing system for this repository");
555911dff5 2007-11-21       drh:   setup_menu_entry("CSS", "setup_editcss",
8ffd32c2b7 2007-10-28       drh:     "Edit the Cascading Style Sheet used by all pages of this repository");
555911dff5 2007-11-21       drh:   setup_menu_entry("Header", "setup_header",
555911dff5 2007-11-21       drh:     "Edit HTML text inserted at the top of every page");
34af72801d 2007-11-23       drh:   setup_menu_entry("Footer", "setup_footer",
34af72801d 2007-11-23       drh:     "Edit HTML text inserted at the bottom of every page");
5f3ddcc1b8 2007-11-25       drh:   @ </table>
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   style_footer();
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: setup_ulist
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Show a list of users.  Clicking on any user jumps to the edit
dbda8d6ce9 2007-07-21       drh: ** screen for that user.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void setup_ulist(void){
dbda8d6ce9 2007-07-21       drh:   Stmt s;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   login_check_credentials();
dbda8d6ce9 2007-07-21       drh:   if( !g.okSetup ){
dbda8d6ce9 2007-07-21       drh:     login_needed();
916b6e4b3b 2007-07-21       drh:     return;
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   style_submenu_element("Add", "Add User", "setup_uedit");
66f4caa379 2007-07-23       drh:   style_header("User List");
39fa010b7f 2007-08-24       drh:   @ <table border="0" cellpadding="0" cellspacing="25">
39fa010b7f 2007-08-24       drh:   @ <tr><td valign="top">
39fa010b7f 2007-08-24       drh:   @ <b>Users:</b>
39fa010b7f 2007-08-24       drh:   @ <table border="1" cellpadding="10"><tr><td>
916b6e4b3b 2007-07-21       drh:   @ <table cellspacing=0 cellpadding=0 border=0>
916b6e4b3b 2007-07-21       drh:   @ <tr>
39fa010b7f 2007-08-24       drh:   @   <th align="right">User&nbsp;ID</th><th width="15"></td>
39fa010b7f 2007-08-24       drh:   @   <th>Capabilities</th><th width="15"></td>
c4ec179bbc 2007-07-22       drh:   @   <th>Contact&nbsp;Info</th>
916b6e4b3b 2007-07-21       drh:   @ </tr>
916b6e4b3b 2007-07-21       drh:   db_prepare(&s, "SELECT uid, login, cap, info FROM user ORDER BY login");
916b6e4b3b 2007-07-21       drh:   while( db_step(&s)==SQLITE_ROW ){
916b6e4b3b 2007-07-21       drh:     @ <tr>
916b6e4b3b 2007-07-21       drh:     @ <td align="right">
916b6e4b3b 2007-07-21       drh:     if( g.okAdmin ){
916b6e4b3b 2007-07-21       drh:       @ <a href="setup_uedit?id=%d(db_column_int(&s,0))">
916b6e4b3b 2007-07-21       drh:     }
916b6e4b3b 2007-07-21       drh:     @ <nobr>%h(db_column_text(&s,1))</nobr>
916b6e4b3b 2007-07-21       drh:     if( g.okAdmin ){
916b6e4b3b 2007-07-21       drh:       @ </a>
916b6e4b3b 2007-07-21       drh:     }
39fa010b7f 2007-08-24       drh:     @ </td><td></td>
39fa010b7f 2007-08-24       drh:     @ <td align="center">%s(db_column_text(&s,2))</td><td></td>
c4ec179bbc 2007-07-22       drh:     @ <td align="left">%s(db_column_text(&s,3))</td>
916b6e4b3b 2007-07-21       drh:     @ </tr>
916b6e4b3b 2007-07-21       drh:   }
c4ec179bbc 2007-07-22       drh:   @ </table></td></tr></table>
39fa010b7f 2007-08-24       drh:   @ <td valign="top">
916b6e4b3b 2007-07-21       drh:   @ <b>Notes:</b>
916b6e4b3b 2007-07-21       drh:   @ <ol>
916b6e4b3b 2007-07-21       drh:   @ <li><p>The permission flags are as follows:</p>
39fa010b7f 2007-08-24       drh:   @ <ol type="a">
39fa010b7f 2007-08-24       drh:   @ <li value="1"><b>Admin</b>: Create and delete users</li>
39fa010b7f 2007-08-24       drh:   @ <li value="3"><b>Append-Tkt</b>: Append to tickets</li>
39fa010b7f 2007-08-24       drh:   @ <li value="4"><b>Delete</b>: Delete wiki and tickets</li>
929d28e358 2007-11-05       drh:   @ <li value="5"><b>Email</b>: View EMail addresses on tickets</li>
39fa010b7f 2007-08-24       drh:   @ <li value="6"><b>New-Wiki</b>: Create new wiki pages</li>
39fa010b7f 2007-08-24       drh:   @ <li value="7"><b>Clone</b>: Clone the repository</li>
39fa010b7f 2007-08-24       drh:   @ <li value="8"><b>History</b>: View detail repository history</li>
39fa010b7f 2007-08-24       drh:   @ <li value="9"><b>Check-In</b>: Commit new versions in the repository</li>
39fa010b7f 2007-08-24       drh:   @ <li value="10"><b>Read-Wiki</b>: View wiki pages</li>
39fa010b7f 2007-08-24       drh:   @ <li value="11"><b>Write-Wiki</b>: Edit wiki pages</li>
39fa010b7f 2007-08-24       drh:   @ <li value="13"><b>Append-Wiki</b>: Append to wiki pages</li>
39fa010b7f 2007-08-24       drh:   @ <li value="14"><b>New-Tkt</b>: Create new tickets</li>
39fa010b7f 2007-08-24       drh:   @ <li value="15"><b>Check-Out</b>: Check out versions</li>
39fa010b7f 2007-08-24       drh:   @ <li value="16"><b>Password</b>: Change your own password</li>
39fa010b7f 2007-08-24       drh:   @ <li value="17"><b>Query</b>: Create new queries against tickets</li>
39fa010b7f 2007-08-24       drh:   @ <li value="18"><b>Read-Tkt</b>: View tickets</li>
39fa010b7f 2007-08-24       drh:   @ <li value="19"><b>Setup:</b> Setup and configure this website</li>
39fa010b7f 2007-08-24       drh:   @ <li value="23"><b>Write-Tkt</b>: Edit tickets</li>
39fa010b7f 2007-08-24       drh:   @ </ol>
916b6e4b3b 2007-07-21       drh:   @ </p></li>
916b6e4b3b 2007-07-21       drh:   @
916b6e4b3b 2007-07-21       drh:   @ <li><p>
22c1ac41d4 2007-08-23       drh:   @ Every user, logged in or not, has the privileges of <b>nobody</b>.
22c1ac41d4 2007-08-23       drh:   @ Any human can login as <b>anonymous</b> since the password is
22c1ac41d4 2007-08-23       drh:   @ clearly displayed on the login page for them to type.  The purpose
22c1ac41d4 2007-08-23       drh:   @ of requiring anonymous to log in is to prevent access by spiders.
916b6e4b3b 2007-07-21       drh:   @ </p></li>
916b6e4b3b 2007-07-21       drh:   @
916b6e4b3b 2007-07-21       drh:   @ </ol>
39fa010b7f 2007-08-24       drh:   @ </td></tr></table>
916b6e4b3b 2007-07-21       drh:   style_footer();
916b6e4b3b 2007-07-21       drh: }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh: /*
916b6e4b3b 2007-07-21       drh: ** WEBPAGE: /setup_uedit
916b6e4b3b 2007-07-21       drh: */
916b6e4b3b 2007-07-21       drh: void user_edit(void){
916b6e4b3b 2007-07-21       drh:   const char *zId, *zLogin, *zInfo, *zCap;
929d28e358 2007-11-05       drh:   char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap;
929d28e358 2007-11-05       drh:   char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag, *oae;
916b6e4b3b 2007-07-21       drh:   int doWrite;
916b6e4b3b 2007-07-21       drh:   int uid;
916b6e4b3b 2007-07-21       drh:   int higherUser = 0;  /* True if user being edited is SETUP and the */
916b6e4b3b 2007-07-21       drh:                        /* user doing the editing is ADMIN.  Disallow editing */
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   /* Must have ADMIN privleges to access this page
916b6e4b3b 2007-07-21       drh:   */
916b6e4b3b 2007-07-21       drh:   login_check_credentials();
916b6e4b3b 2007-07-21       drh:   if( !g.okAdmin ){ login_needed(); return; }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   /* Check to see if an ADMIN user is trying to edit a SETUP account.
916b6e4b3b 2007-07-21       drh:   ** Don't allow that.
916b6e4b3b 2007-07-21       drh:   */
916b6e4b3b 2007-07-21       drh:   zId = PD("id", "0");
916b6e4b3b 2007-07-21       drh:   uid = atoi(zId);
916b6e4b3b 2007-07-21       drh:   if( zId && !g.okSetup && uid>0 ){
916b6e4b3b 2007-07-21       drh:     char *zOldCaps;
916b6e4b3b 2007-07-21       drh:     zOldCaps = db_text(0, "SELECT caps FROM user WHERE uid=%d",uid);
916b6e4b3b 2007-07-21       drh:     higherUser = zOldCaps && strchr(zOldCaps,'s');
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   if( P("can") ){
916b6e4b3b 2007-07-21       drh:     cgi_redirect("setup_ulist");
916b6e4b3b 2007-07-21       drh:     return;
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   /* If we have all the necessary information, write the new or
916b6e4b3b 2007-07-21       drh:   ** modified user record.  After writing the user record, redirect
916b6e4b3b 2007-07-21       drh:   ** to the page that displays a list of users.
916b6e4b3b 2007-07-21       drh:   */
916b6e4b3b 2007-07-21       drh:   doWrite = cgi_all("login","info","pw") && !higherUser;
916b6e4b3b 2007-07-21       drh:   if( doWrite ){
916b6e4b3b 2007-07-21       drh:     const char *zPw;
916b6e4b3b 2007-07-21       drh:     const char *zLogin;
fd36718ad9 2007-07-31       drh:     char zCap[30];
916b6e4b3b 2007-07-21       drh:     int i = 0;
916b6e4b3b 2007-07-21       drh:     int aa = P("aa")!=0;
916b6e4b3b 2007-07-21       drh:     int ad = P("ad")!=0;
929d28e358 2007-11-05       drh:     int ae = P("ae")!=0;
916b6e4b3b 2007-07-21       drh:     int ai = P("ai")!=0;
916b6e4b3b 2007-07-21       drh:     int aj = P("aj")!=0;
916b6e4b3b 2007-07-21       drh:     int ak = P("ak")!=0;
916b6e4b3b 2007-07-21       drh:     int an = P("an")!=0;
916b6e4b3b 2007-07-21       drh:     int ao = P("ao")!=0;
916b6e4b3b 2007-07-21       drh:     int ap = P("ap")!=0;
916b6e4b3b 2007-07-21       drh:     int aq = P("aq")!=0;
916b6e4b3b 2007-07-21       drh:     int ar = P("ar")!=0;
916b6e4b3b 2007-07-21       drh:     int as = g.okSetup && P("as")!=0;
916b6e4b3b 2007-07-21       drh:     int aw = P("aw")!=0;
66f4caa379 2007-07-23       drh:     int ac = P("ac")!=0;
66f4caa379 2007-07-23       drh:     int af = P("af")!=0;
66f4caa379 2007-07-23       drh:     int am = P("am")!=0;
fd36718ad9 2007-07-31       drh:     int ah = P("ah")!=0;
22c1ac41d4 2007-08-23       drh:     int ag = P("ag")!=0;
916b6e4b3b 2007-07-21       drh:     if( aa ){ zCap[i++] = 'a'; }
66f4caa379 2007-07-23       drh:     if( ac ){ zCap[i++] = 'c'; }
916b6e4b3b 2007-07-21       drh:     if( ad ){ zCap[i++] = 'd'; }
929d28e358 2007-11-05       drh:     if( ae ){ zCap[i++] = 'e'; }
66f4caa379 2007-07-23       drh:     if( af ){ zCap[i++] = 'f'; }
fd36718ad9 2007-07-31       drh:     if( ah ){ zCap[i++] = 'h'; }
22c1ac41d4 2007-08-23       drh:     if( ag ){ zCap[i++] = 'g'; }
916b6e4b3b 2007-07-21       drh:     if( ai ){ zCap[i++] = 'i'; }
916b6e4b3b 2007-07-21       drh:     if( aj ){ zCap[i++] = 'j'; }
916b6e4b3b 2007-07-21       drh:     if( ak ){ zCap[i++] = 'k'; }
66f4caa379 2007-07-23       drh:     if( am ){ zCap[i++] = 'm'; }
916b6e4b3b 2007-07-21       drh:     if( an ){ zCap[i++] = 'n'; }
916b6e4b3b 2007-07-21       drh:     if( ao ){ zCap[i++] = 'o'; }
916b6e4b3b 2007-07-21       drh:     if( ap ){ zCap[i++] = 'p'; }
916b6e4b3b 2007-07-21       drh:     if( aq ){ zCap[i++] = 'q'; }
916b6e4b3b 2007-07-21       drh:     if( ar ){ zCap[i++] = 'r'; }
916b6e4b3b 2007-07-21       drh:     if( as ){ zCap[i++] = 's'; }
916b6e4b3b 2007-07-21       drh:     if( aw ){ zCap[i++] = 'w'; }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:     zCap[i] = 0;
916b6e4b3b 2007-07-21       drh:     zPw = P("pw");
916b6e4b3b 2007-07-21       drh:     if( zPw==0 || zPw[0]==0 ){
916b6e4b3b 2007-07-21       drh:       zPw = db_text(0, "SELECT pw FROM user WHERE uid=%d", uid);
916b6e4b3b 2007-07-21       drh:     }
916b6e4b3b 2007-07-21       drh:     zLogin = P("login");
916b6e4b3b 2007-07-21       drh:     if( uid>0 &&
916b6e4b3b 2007-07-21       drh:         db_exists("SELECT 1 FROM user WHERE login=%Q AND uid!=%d", zLogin, uid)
916b6e4b3b 2007-07-21       drh:     ){
66f4caa379 2007-07-23       drh:       style_header("User Creation Error");
916b6e4b3b 2007-07-21       drh:       @ <font color="red">Login "%h(zLogin)" is already used by a different
916b6e4b3b 2007-07-21       drh:       @ user.</font>
916b6e4b3b 2007-07-21       drh:       @
916b6e4b3b 2007-07-21       drh:       @ <p><a href="setup_uedit?id=%d(uid))>[Bummer]</a></p>
916b6e4b3b 2007-07-21       drh:       style_footer();
916b6e4b3b 2007-07-21       drh:       return;
916b6e4b3b 2007-07-21       drh:     }
916b6e4b3b 2007-07-21       drh:     db_multi_exec(
916b6e4b3b 2007-07-21       drh:        "REPLACE INTO user(uid,login,info,pw,cap) "
916b6e4b3b 2007-07-21       drh:        "VALUES(nullif(%d,0),%Q,%Q,%Q,'%s')",
916b6e4b3b 2007-07-21       drh:       uid, P("login"), P("info"), zPw, zCap
916b6e4b3b 2007-07-21       drh:     );
dbda8d6ce9 2007-07-21       drh:     cgi_redirect("setup_ulist");
916b6e4b3b 2007-07-21       drh:     return;
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   /* Load the existing information about the user, if any
916b6e4b3b 2007-07-21       drh:   */
916b6e4b3b 2007-07-21       drh:   zLogin = "";
916b6e4b3b 2007-07-21       drh:   zInfo = "";
916b6e4b3b 2007-07-21       drh:   zCap = "";
929d28e358 2007-11-05       drh:   oaa = oac = oad = oae = oaf = oag = oah = oai = oaj = oak = oam =
66f4caa379 2007-07-23       drh:         oan = oao = oap = oaq = oar = oas = oaw = "";
916b6e4b3b 2007-07-21       drh:   if( uid ){
916b6e4b3b 2007-07-21       drh:     zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid);
916b6e4b3b 2007-07-21       drh:     zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid);
916b6e4b3b 2007-07-21       drh:     zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid);
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'a') ) oaa = " checked";
66f4caa379 2007-07-23       drh:     if( strchr(zCap, 'c') ) oac = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'd') ) oad = " checked";
929d28e358 2007-11-05       drh:     if( strchr(zCap, 'e') ) oae = " checked";
66f4caa379 2007-07-23       drh:     if( strchr(zCap, 'f') ) oaf = " checked";
22c1ac41d4 2007-08-23       drh:     if( strchr(zCap, 'g') ) oag = " checked";
fd36718ad9 2007-07-31       drh:     if( strchr(zCap, 'h') ) oah = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'i') ) oai = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'j') ) oaj = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'k') ) oak = " checked";
66f4caa379 2007-07-23       drh:     if( strchr(zCap, 'm') ) oam = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'n') ) oan = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'o') ) oao = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'p') ) oap = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'q') ) oaq = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'r') ) oar = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 's') ) oas = " checked";
916b6e4b3b 2007-07-21       drh:     if( strchr(zCap, 'w') ) oaw = " checked";
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh: 
916b6e4b3b 2007-07-21       drh:   /* Begin generating the page
916b6e4b3b 2007-07-21       drh:   */
916b6e4b3b 2007-07-21       drh:   style_submenu_element("Cancel", "Cancel", "setup_ulist");
916b6e4b3b 2007-07-21       drh:   if( uid ){
66f4caa379 2007-07-23       drh:     style_header(mprintf("Edit User %h", zLogin));
916b6e4b3b 2007-07-21       drh:   }else{
66f4caa379 2007-07-23       drh:     style_header("Add A New User");
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh:   @ <table align="left" hspace="20" vspace="10"><tr><td>
916b6e4b3b 2007-07-21       drh:   @ <form action="%s(g.zPath)" method="POST">
916b6e4b3b 2007-07-21       drh:   @ <table>
916b6e4b3b 2007-07-21       drh:   @ <tr>
916b6e4b3b 2007-07-21       drh:   @   <td align="right"><nobr>User ID:</nobr></td>
916b6e4b3b 2007-07-21       drh:   if( uid ){
916b6e4b3b 2007-07-21       drh:     @   <td>%d(uid) <input type="hidden" name="id" value="%d(uid)"></td>
916b6e4b3b 2007-07-21       drh:   }else{
916b6e4b3b 2007-07-21       drh:     @   <td>(new user)<input type="hidden" name="id" value=0></td>
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh:   @ </tr>
916b6e4b3b 2007-07-21       drh:   @ <tr>
916b6e4b3b 2007-07-21       drh:   @   <td align="right"><nobr>Login:</nobr></td>
916b6e4b3b 2007-07-21       drh:   @   <td><input type="text" name="login" value="%h(zLogin)"></td>
916b6e4b3b 2007-07-21       drh:   @ </tr>
916b6e4b3b 2007-07-21       drh:   @ <tr>
916b6e4b3b 2007-07-21       drh:   @   <td align="right"><nobr>Contact&nbsp;Info:</nobr></td>
916b6e4b3b 2007-07-21       drh:   @   <td><input type="text" name="info" size=40 value="%h(zInfo)"></td>
916b6e4b3b 2007-07-21       drh:   @ </tr>
916b6e4b3b 2007-07-21       drh:   @ <tr>
916b6e4b3b 2007-07-21       drh:   @   <td align="right" valign="top">Capabilities:</td>
916b6e4b3b 2007-07-21       drh:   @   <td>
916b6e4b3b 2007-07-21       drh:   if( g.okSetup ){
916b6e4b3b 2007-07-21       drh:     @     <input type="checkbox" name="as"%s(oas)>Setup</input><br>
916b6e4b3b 2007-07-21       drh:   }
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="aa"%s(oaa)>Admin</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ad"%s(oad)>Delete</input><br>
929d28e358 2007-11-05       drh:   @     <input type="checkbox" name="ae"%s(oad)>Email</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ap"%s(oap)>Password</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="aq"%s(oaq)>Query</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ai"%s(oai)>Check-In</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ao"%s(oao)>Check-Out</input><br>
fd36718ad9 2007-07-31       drh:   @     <input type="checkbox" name="ah"%s(oah)>History</input><br>
22c1ac41d4 2007-08-23       drh:   @     <input type="checkbox" name="ag"%s(oag)>Clone</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="aj"%s(oaj)>Read Wiki</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="af"%s(oaf)>New Wiki</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="am"%s(oam)>Append Wiki</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ak"%s(oak)>Write Wiki</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ar"%s(oar)>Read Tkt</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="an"%s(oan)>New Tkt</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="ac"%s(oac)>Append Tkt</input><br>
66f4caa379 2007-07-23       drh:   @     <input type="checkbox" name="aw"%s(oaw)>Write Tkt</input>
916b6e4b3b 2007-07-21       drh:   @   </td>
916b6e4b3b 2007-07-21       drh:   @ </tr>
916b6e4b3b 2007-07-21       drh:   @ <tr>
916b6e4b3b 2007-07-21       drh:   @   <td align="right">Password:</td>
916b6e4b3b 2007-07-21       drh:   @   <td><input type="password" name="pw" value=""></td>
916b6e4b3b 2007-07-21       drh:   @ </tr>
916b6e4b3b 2007-07-21       drh:   if( !higherUser ){
916b6e4b3b 2007-07-21       drh:     @ <tr>
916b6e4b3b 2007-07-21       drh:     @   <td>&nbsp</td>
916b6e4b3b 2007-07-21       drh:     @   <td><input type="submit" name="submit" value="Apply Changes">
916b6e4b3b 2007-07-21       drh:     @ </tr>
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh:   @ </table></td></tr></table>
916b6e4b3b 2007-07-21       drh:   @ <p><b>Notes:</b></p>
916b6e4b3b 2007-07-21       drh:   @ <ol>
916b6e4b3b 2007-07-21       drh:   if( higherUser ){
916b6e4b3b 2007-07-21       drh:     @ <li><p>
916b6e4b3b 2007-07-21       drh:     @ User %h(zId) has Setup privileges and you only have Admin privileges
916b6e4b3b 2007-07-21       drh:     @ so you are not permitted to make changes to %h(zId).
916b6e4b3b 2007-07-21       drh:     @ </p></li>
916b6e4b3b 2007-07-21       drh:     @
916b6e4b3b 2007-07-21       drh:   }
916b6e4b3b 2007-07-21       drh:   @
916b6e4b3b 2007-07-21       drh:   @ <li><p>
916b6e4b3b 2007-07-21       drh:   @ The <b>Delete</b> privilege give the user the ability to erase
916b6e4b3b 2007-07-21       drh:   @ wiki, tickets, and atttachments that have been added by anonymous
50a58adb76 2007-10-10       drh:   @ users.  This capability is intended for deletion of spam.  The
50a58adb76 2007-10-10       drh:   @ delete capability is only in effect for 24 hours after the item
50a58adb76 2007-10-10       drh:   @ is first posted.  The Setup user can delete anything at any time.
916b6e4b3b 2007-07-21       drh:   @ </p></li>
916b6e4b3b 2007-07-21       drh:   @
916b6e4b3b 2007-07-21       drh:   @ <li><p>
916b6e4b3b 2007-07-21       drh:   @ The <b>Query</b> privilege allows the user to create or edit
916b6e4b3b 2007-07-21       drh:   @ report formats by specifying appropriate SQL.  Users can run
916b6e4b3b 2007-07-21       drh:   @ existing reports without the Query privilege.
916b6e4b3b 2007-07-21       drh:   @ </p></li>
916b6e4b3b 2007-07-21       drh:   @
916b6e4b3b 2007-07-21       drh:   @ <li><p>
916b6e4b3b 2007-07-21       drh:   @ An <b>Admin</b> user can add other users, create new ticket report
916b6e4b3b 2007-07-21       drh:   @ formats, and change system defaults.  But only the <b>Setup</b> user
916b6e4b3b 2007-07-21       drh:   @ is able to change the repository to
916b6e4b3b 2007-07-21       drh:   @ which this program is linked.
916b6e4b3b 2007-07-21       drh:   @ </p></li>
916b6e4b3b 2007-07-21       drh:   @
9c952d247e 2007-07-31       drh:   @ <li><p>
13b7ac16e4 2007-08-09       drh:   @ The <b>History</b> privilege allows a user to see a timeline
13b7ac16e4 2007-08-09       drh:   @ with hyperlinks to version information, to download ZIP archives
22c1ac41d4 2007-08-23       drh:   @ of individual versions.
fd36718ad9 2007-07-31       drh:   @ </p></li>
fd36718ad9 2007-07-31       drh:   @
fd36718ad9 2007-07-31       drh:   @ <li><p>
9c952d247e 2007-07-31       drh:   @ No login is required for user "<b>nobody</b>".  The capabilities
9c952d247e 2007-07-31       drh:   @ of this user are available to anyone without supplying a username or
9c952d247e 2007-07-31       drh:   @ password.  To disable nobody access, make sure there is no user
9c952d247e 2007-07-31       drh:   @ with an ID of <b>nobody</b> or that the nobody user has no
fd36718ad9 2007-07-31       drh:   @ capabilities enabled.  The password for nobody is ignore.  To
fd36718ad9 2007-07-31       drh:   @ avoid problems with spiders overloading the server, it is suggested
fd36718ad9 2007-07-31       drh:   @ that the 'h' (History) capability be turned off for user nobody.
9c952d247e 2007-07-31       drh:   @ </p></li>
9c952d247e 2007-07-31       drh:   @
9c952d247e 2007-07-31       drh:   @ <li><p>
9c952d247e 2007-07-31       drh:   @ Login is required for user "<b>anonymous</b>" but the password
9c952d247e 2007-07-31       drh:   @ is displayed on the login screen beside the password entry box
9c952d247e 2007-07-31       drh:   @ so anybody who can read should be able to login as anonymous.
9c952d247e 2007-07-31       drh:   @ On the other hand, spiders and web-crawlers will typically not
9c952d247e 2007-07-31       drh:   @ be able to login.  Set the capabilities of the anonymous user
9c952d247e 2007-07-31       drh:   @ to things that you want any human to be able to do, but no any
9c952d247e 2007-07-31       drh:   @ spider.
9c952d247e 2007-07-31       drh:   @ </p></li>
916b6e4b3b 2007-07-21       drh:   @ </form>
dbda8d6ce9 2007-07-21       drh:   style_footer();
dbda8d6ce9 2007-07-21       drh: }
916b6e4b3b 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Generate a checkbox for an attribute.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: static void onoff_attribute(
dbda8d6ce9 2007-07-21       drh:   const char *zLabel,   /* The text label on the checkbox */
dbda8d6ce9 2007-07-21       drh:   const char *zVar,     /* The corresponding row in the VAR table */
dbda8d6ce9 2007-07-21       drh:   const char *zQParm,   /* The query parameter */
dbda8d6ce9 2007-07-21       drh:   int dfltVal           /* Default value if VAR table entry does not exist */
dbda8d6ce9 2007-07-21       drh: ){
dbda8d6ce9 2007-07-21       drh:   const char *zVal = db_get(zVar, 0);
dbda8d6ce9 2007-07-21       drh:   const char *zQ = P(zQParm);
dbda8d6ce9 2007-07-21       drh:   int iVal;
dbda8d6ce9 2007-07-21       drh:   if( zVal ){
dbda8d6ce9 2007-07-21       drh:     iVal = atoi(zVal);
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     iVal = dfltVal;
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( zQ==0 && P("submit") ){
dbda8d6ce9 2007-07-21       drh:     zQ = "off";
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( zQ ){
dbda8d6ce9 2007-07-21       drh:     int iQ = strcmp(zQ,"on")==0 || atoi(zQ);
dbda8d6ce9 2007-07-21       drh:     if( iQ!=iVal ){
134e2aeccc 2007-09-28       drh:       db_set(zVar, iQ ? "1" : "0", 0);
dbda8d6ce9 2007-07-21       drh:       iVal = iQ;
dbda8d6ce9 2007-07-21       drh:     }
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( iVal ){
dbda8d6ce9 2007-07-21       drh:     @ <input type="checkbox" name="%s(zQParm)" checked>%s(zLabel)</input>
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     @ <input type="checkbox" name="%s(zQParm)">%s(zLabel)</input>
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Generate an entry box for an attribute.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: static void entry_attribute(
dbda8d6ce9 2007-07-21       drh:   const char *zLabel,   /* The text label on the entry box */
dbda8d6ce9 2007-07-21       drh:   int width,            /* Width of the entry box */
dbda8d6ce9 2007-07-21       drh:   const char *zVar,     /* The corresponding row in the VAR table */
dbda8d6ce9 2007-07-21       drh:   const char *zQParm,   /* The query parameter */
1e9c0e287e 2007-10-03       drh:   char *zDflt     /* Default value if VAR table entry does not exist */
dbda8d6ce9 2007-07-21       drh: ){
dbda8d6ce9 2007-07-21       drh:   const char *zVal = db_get(zVar, zDflt);
dbda8d6ce9 2007-07-21       drh:   const char *zQ = P(zQParm);
dbda8d6ce9 2007-07-21       drh:   if( zQ && strcmp(zQ,zVal)!=0 ){
134e2aeccc 2007-09-28       drh:     db_set(zVar, zQ, 0);
dbda8d6ce9 2007-07-21       drh:     zVal = zQ;
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   @ <input type="text" name="%s(zQParm)" value="%h(zVal)" size="%d(width)">
dbda8d6ce9 2007-07-21       drh:   @ %s(zLabel)
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
07eaead5dc 2007-09-23       jnc: /*
07eaead5dc 2007-09-23       jnc: ** Generate a text box for an attribute.
07eaead5dc 2007-09-23       jnc: */
07eaead5dc 2007-09-23       jnc: static void textarea_attribute(
07eaead5dc 2007-09-23       jnc:   const char *zLabel,   /* The text label on the textarea */
07eaead5dc 2007-09-23       jnc:   int rows,             /* Rows in the textarea */
07eaead5dc 2007-09-23       jnc:   int cols,             /* Columns in the textarea */
07eaead5dc 2007-09-23       jnc:   const char *zVar,     /* The corresponding row in the VAR table */
555911dff5 2007-11-21       drh:   const char *zQP,      /* The query parameter */
07eaead5dc 2007-09-23       jnc:   const char *zDflt     /* Default value if VAR table entry does not exist */
07eaead5dc 2007-09-23       jnc: ){
2a707334c9 2007-11-22       drh:   const char *z = db_get(zVar, (char*)zDflt);
555911dff5 2007-11-21       drh:   const char *zQ = P(zQP);
555911dff5 2007-11-21       drh:   if( zQ && strcmp(zQ,z)!=0 ){
134e2aeccc 2007-09-28       drh:     db_set(zVar, zQ, 0);
555911dff5 2007-11-21       drh:     z = zQ;
555911dff5 2007-11-21       drh:   }
555911dff5 2007-11-21       drh:   if( rows>0 && cols>0 ){
555911dff5 2007-11-21       drh:     @ <textarea name="%s(zQP)" rows="%d(rows)" cols="%d(cols)">%h(z)</textarea>
555911dff5 2007-11-21       drh:     @ %s(zLabel)
555911dff5 2007-11-21       drh:   }
07eaead5dc 2007-09-23       jnc: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: setup_access
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void setup_access(void){
dbda8d6ce9 2007-07-21       drh:   login_check_credentials();
dbda8d6ce9 2007-07-21       drh:   if( !g.okSetup ){
dbda8d6ce9 2007-07-21       drh:     login_needed();
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh: 
66f4caa379 2007-07-23       drh:   style_header("Access Control Settings");
dbda8d6ce9 2007-07-21       drh:   db_begin_transaction();
c4ec179bbc 2007-07-22       drh:   @ <form action="%s(g.zBaseURL)/setup_access" method="POST">
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   @ <hr>
dbda8d6ce9 2007-07-21       drh:   onoff_attribute("Require password for local access",
097479f99a 2007-09-26       drh:      "localauth", "localauth", 1);
dbda8d6ce9 2007-07-21       drh:   @ <p>When enabled, the password sign-in is required for
dbda8d6ce9 2007-07-21       drh:   @ web access coming from 127.0.0.1.  When disabled, web access
dbda8d6ce9 2007-07-21       drh:   @ from 127.0.0.1 is allows without any login - the user id is selected
dbda8d6ce9 2007-07-21       drh:   @ from the ~/.fossil database. Password login is always required
dbda8d6ce9 2007-07-21       drh:   @ for incoming web connections on internet addresses other than
dbda8d6ce9 2007-07-21       drh:   @ 127.0.0.1.</p></li>
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   @ <hr>
dbda8d6ce9 2007-07-21       drh:   entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
dbda8d6ce9 2007-07-21       drh:   @ <p>The number of hours for which a login is valid.  This must be a
dbda8d6ce9 2007-07-21       drh:   @ positive number.  The default is 8760 hours which is approximately equal
dbda8d6ce9 2007-07-21       drh:   @ to a year.</p>
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   @ <hr>
ebb2765954 2007-12-04       drh:   @ <p><input type="submit"  name="submit" value="Apply Changes"></p>
ebb2765954 2007-12-04       drh:   @ </form>
ebb2765954 2007-12-04       drh:   db_end_transaction(0);
ebb2765954 2007-12-04       drh:   style_footer();
ebb2765954 2007-12-04       drh: }
ebb2765954 2007-12-04       drh: 
ebb2765954 2007-12-04       drh: /*
ebb2765954 2007-12-04       drh: ** WEBPAGE: setup_timeline
ebb2765954 2007-12-04       drh: */
ebb2765954 2007-12-04       drh: void setup_timeline(void){
ebb2765954 2007-12-04       drh:   login_check_credentials();
ebb2765954 2007-12-04       drh:   if( !g.okSetup ){
ebb2765954 2007-12-04       drh:     login_needed();
ebb2765954 2007-12-04       drh:   }
ebb2765954 2007-12-04       drh: 
ebb2765954 2007-12-04       drh:   style_header("Timeline Display Preferences");
ebb2765954 2007-12-04       drh:   db_begin_transaction();
ebb2765954 2007-12-04       drh:   @ <form action="%s(g.zBaseURL)/setup_timeline" method="POST">
ebb2765954 2007-12-04       drh: 
ebb2765954 2007-12-04       drh:   @ <hr>
ebb2765954 2007-12-04       drh:   onoff_attribute("Block markup in timeline",
ebb2765954 2007-12-04       drh:                   "timeline-block-markup", "tbm", 0);
ebb2765954 2007-12-04       drh:   @ <p>In timeline displays, check-in comments can be displayed with or
ebb2765954 2007-12-04       drh:   @ without block markup (paragraphs, tables, etc.)</p>
ebb2765954 2007-12-04       drh: 
ebb2765954 2007-12-04       drh:   @ <hr>
ebb2765954 2007-12-04       drh:   entry_attribute("Max timeline comment length", 6,
ebb2765954 2007-12-04       drh:                   "timeline-max-comment", "tmc", "0");
ebb2765954 2007-12-04       drh:   @ <p>The maximum length of a comment to be displayed in a timeline.
ebb2765954 2007-12-04       drh:   @ "0" there is no length limit.</p>
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   @ <hr>
c4ec179bbc 2007-07-22       drh:   @ <p><input type="submit"  name="submit" value="Apply Changes"></p>
c4ec179bbc 2007-07-22       drh:   @ </form>
c4ec179bbc 2007-07-22       drh:   db_end_transaction(0);
c4ec179bbc 2007-07-22       drh:   style_footer();
c4ec179bbc 2007-07-22       drh: }
c4ec179bbc 2007-07-22       drh: 
c4ec179bbc 2007-07-22       drh: /*
c4ec179bbc 2007-07-22       drh: ** WEBPAGE: setup_config
c4ec179bbc 2007-07-22       drh: */
c4ec179bbc 2007-07-22       drh: void setup_config(void){
c4ec179bbc 2007-07-22       drh:   login_check_credentials();
c4ec179bbc 2007-07-22       drh:   if( !g.okSetup ){
c4ec179bbc 2007-07-22       drh:     login_needed();
c4ec179bbc 2007-07-22       drh:   }
c4ec179bbc 2007-07-22       drh: 
66f4caa379 2007-07-23       drh:   style_header("WWW Configuration");
66f4caa379 2007-07-23       drh:   db_begin_transaction();
c4ec179bbc 2007-07-22       drh:   @ <form action="%s(g.zBaseURL)/setup_config" method="POST">
8ffd32c2b7 2007-10-28       drh:   @ <hr />
f3807dbd88 2007-10-10       jnc:   entry_attribute("Project Name", 60, "project-name", "pn", "");
f3807dbd88 2007-10-10       jnc:   @ <p>Give your project a name so visitors know what this site is about.
f3807dbd88 2007-10-10       jnc:   @ The project name will also be used as the RSS feed title.</p>
f3807dbd88 2007-10-10       jnc:   @ <hr />
555911dff5 2007-11-21       drh:   textarea_attribute("Project Description", 5, 60,
555911dff5 2007-11-21       drh:                      "project-description", "pd", "");
f3807dbd88 2007-10-10       jnc:   @ <p>Describe your project. This will be used in page headers for search
f3807dbd88 2007-10-10       jnc:   @ engines as well as a short RSS description.</p>
f3807dbd88 2007-10-10       jnc:   @ <hr />
dbda8d6ce9 2007-07-21       drh:   @ <p><input type="submit"  name="submit" value="Apply Changes"></p>
dbda8d6ce9 2007-07-21       drh:   @ </form>
dbda8d6ce9 2007-07-21       drh:   db_end_transaction(0);
dbda8d6ce9 2007-07-21       drh:   style_footer();
8ffd32c2b7 2007-10-28       drh: }
8ffd32c2b7 2007-10-28       drh: 
8ffd32c2b7 2007-10-28       drh: /*
555911dff5 2007-11-21       drh: ** WEBPAGE: setup_editcss
8ffd32c2b7 2007-10-28       drh: */
8ffd32c2b7 2007-10-28       drh: void setup_editcss(void){
8ffd32c2b7 2007-10-28       drh:   login_check_credentials();
8ffd32c2b7 2007-10-28       drh:   if( !g.okSetup ){
8ffd32c2b7 2007-10-28       drh:     login_needed();
8ffd32c2b7 2007-10-28       drh:   }
8ffd32c2b7 2007-10-28       drh:   style_header("Edit CSS");
555911dff5 2007-11-21       drh:   @ <form action="%s(g.zBaseURL)/setup_editcss" method="POST">
8ffd32c2b7 2007-10-28       drh:   @ Edit the CSS:<br />
8ffd32c2b7 2007-10-28       drh:   textarea_attribute("", 40, 80, "css", "css", zDefaultCSS);
8ffd32c2b7 2007-10-28       drh:   @ <br />
8ffd32c2b7 2007-10-28       drh:   @ <input type="submit" name="submit" value="Apply Changes">
8ffd32c2b7 2007-10-28       drh:   @ </form>
555911dff5 2007-11-21       drh:   @ <hr>
555911dff5 2007-11-21       drh:   @ Here is the default CSS:
555911dff5 2007-11-21       drh:   @ <blockquote><pre>
555911dff5 2007-11-21       drh:   @ %h(zDefaultCSS)
555911dff5 2007-11-21       drh:   @ </pre></blockquote>
8ffd32c2b7 2007-10-28       drh:   style_footer();
555911dff5 2007-11-21       drh: }
555911dff5 2007-11-21       drh: 
555911dff5 2007-11-21       drh: /*
555911dff5 2007-11-21       drh: ** WEBPAGE: setup_header
555911dff5 2007-11-21       drh: */
555911dff5 2007-11-21       drh: void setup_header(void){
555911dff5 2007-11-21       drh:   login_check_credentials();
555911dff5 2007-11-21       drh:   if( !g.okSetup ){
555911dff5 2007-11-21       drh:     login_needed();
555911dff5 2007-11-21       drh:   }
555911dff5 2007-11-21       drh:   db_begin_transaction();
555911dff5 2007-11-21       drh:   if( P("clear")!=0 ){
555911dff5 2007-11-21       drh:     db_multi_exec("DELETE FROM config WHERE name='header'");
555911dff5 2007-11-21       drh:     cgi_replace_parameter("header", zDefaultHeader);
555911dff5 2007-11-21       drh:   }else{
555911dff5 2007-11-21       drh:     textarea_attribute(0, 0, 0, "header", "header", zDefaultHeader);
555911dff5 2007-11-21       drh:   }
555911dff5 2007-11-21       drh:   style_header("Edit Page Header");
555911dff5 2007-11-21       drh:   @ <form action="%s(g.zBaseURL)/setup_header" method="POST">
555911dff5 2007-11-21       drh:   @ <p>Edit HTML text with embedded subscript that will be used to
555911dff5 2007-11-21       drh:   @ generate the beginning of every page through start of the main
555911dff5 2007-11-21       drh:   @ menu.</p>
555911dff5 2007-11-21       drh:   textarea_attribute("", 40, 80, "header", "header", zDefaultHeader);
555911dff5 2007-11-21       drh:   @ <br />
555911dff5 2007-11-21       drh:   @ <input type="submit" name="submit" value="Apply Changes">
555911dff5 2007-11-21       drh:   @ <input type="submit" name="clear" value="Revert To Default">
555911dff5 2007-11-21       drh:   @ </form>
555911dff5 2007-11-21       drh:   @ <hr>
555911dff5 2007-11-21       drh:   @ Here is the default page header:
555911dff5 2007-11-21       drh:   @ <blockquote><pre>
555911dff5 2007-11-21       drh:   @ %h(zDefaultHeader)
34af72801d 2007-11-23       drh:   @ </pre></blockquote>
34af72801d 2007-11-23       drh:   db_end_transaction(0);
34af72801d 2007-11-23       drh: }
34af72801d 2007-11-23       drh: 
34af72801d 2007-11-23       drh: /*
34af72801d 2007-11-23       drh: ** WEBPAGE: setup_footer
34af72801d 2007-11-23       drh: */
34af72801d 2007-11-23       drh: void setup_footer(void){
34af72801d 2007-11-23       drh:   login_check_credentials();
34af72801d 2007-11-23       drh:   if( !g.okSetup ){
34af72801d 2007-11-23       drh:     login_needed();
34af72801d 2007-11-23       drh:   }
34af72801d 2007-11-23       drh:   db_begin_transaction();
34af72801d 2007-11-23       drh:   if( P("clear")!=0 ){
34af72801d 2007-11-23       drh:     db_multi_exec("DELETE FROM config WHERE name='footer'");
34af72801d 2007-11-23       drh:     cgi_replace_parameter("footer", zDefaultFooter);
34af72801d 2007-11-23       drh:   }else{
34af72801d 2007-11-23       drh:     textarea_attribute(0, 0, 0, "footer", "footer", zDefaultFooter);
34af72801d 2007-11-23       drh:   }
34af72801d 2007-11-23       drh:   style_header("Edit Page Footer");
34af72801d 2007-11-23       drh:   @ <form action="%s(g.zBaseURL)/setup_footer" method="POST">
34af72801d 2007-11-23       drh:   @ <p>Edit HTML text with embedded subscript that will be used to
34af72801d 2007-11-23       drh:   @ generate the end of every page.</p>
34af72801d 2007-11-23       drh:   textarea_attribute("", 20, 80, "footer", "footer", zDefaultFooter);
34af72801d 2007-11-23       drh:   @ <br />
34af72801d 2007-11-23       drh:   @ <input type="submit" name="submit" value="Apply Changes">
34af72801d 2007-11-23       drh:   @ <input type="submit" name="clear" value="Revert To Default">
34af72801d 2007-11-23       drh:   @ </form>
34af72801d 2007-11-23       drh:   @ <hr>
34af72801d 2007-11-23       drh:   @ Here is the default page footer:
34af72801d 2007-11-23       drh:   @ <blockquote><pre>
34af72801d 2007-11-23       drh:   @ %h(zDefaultFooter)
5f3ddcc1b8 2007-11-25       drh:   @ </pre></blockquote>
5f3ddcc1b8 2007-11-25       drh:   db_end_transaction(0);
5f3ddcc1b8 2007-11-25       drh: }
5f3ddcc1b8 2007-11-25       drh: 
5f3ddcc1b8 2007-11-25       drh: /*
5f3ddcc1b8 2007-11-25       drh: ** WEBPAGE: setup_ticket
5f3ddcc1b8 2007-11-25       drh: */
5f3ddcc1b8 2007-11-25       drh: void setup_ticket(void){
5f3ddcc1b8 2007-11-25       drh:   const char *zConfig;
5f3ddcc1b8 2007-11-25       drh:   int isSubmit;
5f3ddcc1b8 2007-11-25       drh: 
5f3ddcc1b8 2007-11-25       drh:   login_check_credentials();
5f3ddcc1b8 2007-11-25       drh:   if( !g.okSetup ){
5f3ddcc1b8 2007-11-25       drh:     login_needed();
5f3ddcc1b8 2007-11-25       drh:   }
5f3ddcc1b8 2007-11-25       drh:   isSubmit = P("submit")!=0;
5f3ddcc1b8 2007-11-25       drh:   db_begin_transaction();
5f3ddcc1b8 2007-11-25       drh:   zConfig = P("cfg");
5f3ddcc1b8 2007-11-25       drh:   if( zConfig==0 ){
5f3ddcc1b8 2007-11-25       drh:     zConfig = db_text((char*)zDefaultTicketConfig,
5f3ddcc1b8 2007-11-25       drh:                "SELECT value FROM config WHERE name='ticket-configuration'");
5f3ddcc1b8 2007-11-25       drh:   }
5f3ddcc1b8 2007-11-25       drh:   style_header("Edit Ticket Configuration");
5f3ddcc1b8 2007-11-25       drh:   if( P("clear")!=0 ){
5f3ddcc1b8 2007-11-25       drh:     db_multi_exec("DELETE FROM config WHERE name='ticket-configuration'");
5f3ddcc1b8 2007-11-25       drh:     zConfig = zDefaultTicketConfig;
5f3ddcc1b8 2007-11-25       drh:   }else if( isSubmit ){
5f3ddcc1b8 2007-11-25       drh:     char *zErr = ticket_config_check(zConfig);
5f3ddcc1b8 2007-11-25       drh:     if( zErr==0 ){
5f3ddcc1b8 2007-11-25       drh:       db_multi_exec(
5f3ddcc1b8 2007-11-25       drh:          "REPLACE INTO config(name,value) VALUES('ticket-configuration',"
5f3ddcc1b8 2007-11-25       drh:          "%Q)", zConfig
5f3ddcc1b8 2007-11-25       drh:       );
5f3ddcc1b8 2007-11-25       drh:     }else{
5f3ddcc1b8 2007-11-25       drh:       @ <p><font color="red"><b>
5f3ddcc1b8 2007-11-25       drh:       @ SCRIPT ERROR: %h(zErr)
5f3ddcc1b8 2007-11-25       drh:       @ </b></font></p>
5f3ddcc1b8 2007-11-25       drh:     }
5f3ddcc1b8 2007-11-25       drh:   }
5f3ddcc1b8 2007-11-25       drh:   @ <form action="%s(g.zBaseURL)/setup_ticket" method="POST">
5f3ddcc1b8 2007-11-25       drh:   @ <p>Edit the "subscript" script that defines the ticketing
5f3ddcc1b8 2007-11-25       drh:   @ system setup for this server.</p>
5f3ddcc1b8 2007-11-25       drh:   @ <textarea name="cfg" rows="40" cols="80">%h(zConfig)</textarea>
5f3ddcc1b8 2007-11-25       drh:   @ <br />
5f3ddcc1b8 2007-11-25       drh:   @ <input type="submit" name="submit" value="Apply Changes">
5f3ddcc1b8 2007-11-25       drh:   @ <input type="submit" name="clear" value="Revert To Default">
5f3ddcc1b8 2007-11-25       drh:   @ </form>
5f3ddcc1b8 2007-11-25       drh:   @ <hr>
5f3ddcc1b8 2007-11-25       drh:   @ Here is the default page header:
5f3ddcc1b8 2007-11-25       drh:   @ <blockquote><pre>
5f3ddcc1b8 2007-11-25       drh:   @ %h(zDefaultTicketConfig)
555911dff5 2007-11-21       drh:   @ </pre></blockquote>
555911dff5 2007-11-21       drh:   db_end_transaction(0);
dbda8d6ce9 2007-07-21       drh: }