/*
** Copyright (c) 2002 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** Implementation of the Setup page
*/
#include
@ If you decide to Reconstruct the change history database all
@ of your check-ins will be renumbered. This might break links between
@ tickets and wiki pages and check-ins. Any edits you may have made
@ to check-in messages will be undone as well. A safer alternative is to select Rescan which will attempt
@ to preserve existing check-in numbers and check-in message changes.
@ In either case, you may want to make a
@ backup copy of the database so that you can recover if something
@ goes wrong.
@
@
}
/*
** WEBPAGE: /setup
*/
void setup_page(void){
/* The user must be at least the administrator in order to see
** this screen.
*/
login_check_credentials();
if( !g.okAdmin ){
login_needed();
return;
}
common_standard_menu("setup", 0);
common_add_help_item("CvstracAdmin");
common_header("Setup Menu");
@
if( zLink && zLink[0] ){
@ %s(zTitle)
}else{
@ %s(zTitle)
}
@
@ %s(zDesc)
@
if( g.okSetup ){
menu_entry(mprintf("%s Repository",g.scm.zName), "setup_repository",
"Identify the repository to which this server is linked.");
if( g.scm.pxUserWrite ){
menu_entry("User Database", "setup_user",
mprintf("Control how CVSTrac interacts with the %h user "
"and password database", g.scm.zName));
}
menu_entry("Log File", "setup_log",
"Turn the access log file on and off.");
menu_entry("Attachments", "setup_attach",
"Set the maximum allowable size for attachments.");
menu_entry("Abuse Control", "setup_throttle",
"Options to control bandwidth abuse and wiki spam.");
}
menu_entry("Ticket Types", "setup_enum?e=type",
"Enumerate the different types of tickets that can be entered into "
"the system.");
menu_entry("Ticket States", "setup_enum?e=status",
"Configure the allowed values for the \"status\" attribute of tickets.");
menu_entry("New Tickets Defaults", "setup_newtkt",
"Specify the default values assigned to various ticket attributes when "
"a new ticket is created.");
menu_entry("Subsystem Names", "setup_enum?e=subsys",
"List the names of subsystems that can be used in the \"subsystem\" "
"attribute of tickets.");
menu_entry("User-Defined Fields", "setup_udef",
"Create user-defined database columns in the TICKET table");
if( g.okSetup ){
menu_entry("Diff and Filter Programs", "setup_diff",
"Specify commands or scripts used to compute the difference between "
"two versions of a file and pretty print files.");
menu_entry("External Tools", "setup_tools",
"Manage tools for processing CVSTrac objects." );
menu_entry("Change Notification", "setup_chng",
"Define an external program to run whenever a ticket is created "
"or modified.");
menu_entry("Customize Style", "setup_style",
"Headers, footers, stylesheets, other web page elements.");
menu_entry("User Interface", "setup_interface",
"Control the user interface functionality." );
menu_entry("Wiki Markup", "setup_markup",
"Manage custom Wiki markups" );
menu_entry("Backup & Restore", "setup_backup",
"Make a backup copy of the database or restore the database from a "
"backup copy.");
menu_entry("Timeline & RSS", "setup_timeline",
"Set timeline cookie lifetime and RSS \"Time To Live\".");
}
@
common_footer();
}
/*
** WEBPAGE: /setup_repository
*/
void setup_repository_page(void){
const char *zRoot, *zOldRoot;
const char *zModule, *zOldModule;
/* The user must be the setup user in order to see
** this screen.
*/
login_check_credentials();
if( !g.okSetup ){
cgi_redirect("setup");
return;
}
/*
** The "r" query parameter is the name of the CVS repository root
** directory. Change it if it has changed.
*/
zOldRoot = db_config("cvsroot","");
zRoot = P("r");
if( zRoot && strcmp(zOldRoot,zRoot)!=0 ){
db_execute("REPLACE INTO config(name,value) VALUES('cvsroot','%q');",
zRoot);
zOldRoot = zRoot;
db_config(0,0);
}
/*
** The "m" query parameter is the name of the module within the
** CVS repository that this CVSTrac instance is suppose to track.
** Change it if it has changed.
*/
zOldModule = db_config("module","");
zModule = P("m");
if( zModule && strcmp(zOldModule,zModule)!=0 ){
db_execute("REPLACE INTO config(name,value) VALUES('module','%q');",
zModule);
zOldModule = zModule;
db_config(0,0);
}
/*
** The "rrh" query parameter is present if the user presses the
** "Reread Revision History" button. This causes the CVSROOT/history
** file to be reread. Do this with caution as it erases any edits
** to the history that are currently in the database. Only the
** setup user can do this.
*/
if( P("rrh") ){
common_add_action_item("setup_repository", "Cancel");
common_header("Confirm Reread Of Repository");
@ WARNING!
@
%s(g.scm.zName) repository: | @@ |
Module prefix: | @@ |
@ After changing the %s(g.scm.zName) repository above, you will generally @ want to press the following button to cause the repository history to be @ reread from the new repository. You can also use this button to @ resynchronize the database if a prior read @ failed or if you have manually changed it (always a bad idea). @
@ @ @@
@ } common_footer(); } /* ** WEBPAGE: /setup_log */ void setup_logfile_page(void){ const char *zLog, *zOldLog; /* The user must be the setup user in order to see ** this screen. */ login_check_credentials(); if( !g.okSetup ){ cgi_redirect("setup"); return; } /* ** The "log" query parameter specifies a log file into which a record ** of all HTTP hits is written. Write this value if this has changed. ** Only setup can make this change. */ zOldLog = db_config("logfile",""); zLog = P("log"); if( zLog && strcmp(zOldLog,zLog)!=0 ){ db_execute( "REPLACE INTO config(name,value) VALUES('logfile','%q');", zLog ); zOldLog = zLog; db_config(0,0); } common_add_nav_item("setup", "Main Setup Menu"); common_add_help_item("CvstracAdminLog"); common_header("Configure Log File"); @@
@ common_footer(); } /* ** WEBPAGE: /setup_newtkt */ void setup_newticket_page(void){ char **azResult; const char *zState, *zOldState; const char *zAsgnto, *zOldAsgnto; const char *zType, *zOldType; const char *zPri, *zOldPri; const char *zSev, *zOldSev; /* The user must be at least the administrator in order to see ** this screen. */ login_check_credentials(); if( !g.okAdmin ){ login_needed(); return; } /* ** The "asgnto" query parameter specifies a userid who is assigned to ** all new tickets. Record this value in the configuration table if ** it has changed. */ zOldAsgnto = db_config("assignto",""); zAsgnto = P("asgnto"); if( zAsgnto && strcmp(zOldAsgnto,zAsgnto)!=0 ){ db_execute( "REPLACE INTO config(name,value) VALUES('assignto','%q');", zAsgnto ); zOldAsgnto = zAsgnto; db_config(0,0); } /* ** The "istate" query parameter specifies the initial state for new ** tickets. Record any changes to this value. */ zOldState = db_config("initial_state",""); zState = P("istate"); if( zState && strcmp(zOldState,zState)!=0 ){ db_execute( "REPLACE INTO config(name,value) VALUES('initial_state','%q');", zState ); zOldState = zState; db_config(0,0); } /* ** The "type" query parameter specifies the initial type for new ** tickets. Record any changes to this value. */ zOldType = db_config("dflt_tkt_type","code"); zType = P("type"); if( zType && strcmp(zOldType,zType)!=0 ){ db_execute( "REPLACE INTO config(name,value) VALUES('dflt_tkt_type','%q');", zType ); zOldType = zType; db_config(0,0); } /* ** The "pri" query parameter specifies the initial priority for new ** tickets. Record any changes to this value. */ zOldPri = db_config("dflt_priority","1"); zPri = P("pri"); if( zPri && strcmp(zOldPri,zPri)!=0 ){ db_execute( "REPLACE INTO config(name,value) VALUES('dflt_priority','%q');", zPri ); zOldPri = zPri; db_config(0,0); } /* ** The "sev" query parameter specifies the initial severity for new ** tickets. Record any changes to this value. */ zOldSev = db_config("dflt_severity","1"); zSev = P("sev"); if( zSev && strcmp(zOldSev,zSev)!=0 ){ db_execute( "REPLACE INTO config(name,value) VALUES('dflt_severity','%q');", zSev ); zOldSev = zSev; db_config(0,0); } common_add_nav_item("setup", "Main Setup Menu"); common_add_help_item("CvstracAdminNewTicket"); common_header("Configure New Ticket Defaults"); @@
@ common_footer(); } /* ** WEBPAGE: /setup_interface */ void setup_interface_page(void){ int atkt, ack, tkt, ck; const char *zBrowseUrl; int nCookieLife; /* The user must be at least the administrator in order to see ** this screen. */ login_check_credentials(); if( !g.okAdmin ){ login_needed(); return; } if( P("update") ){ db_execute( "REPLACE INTO config(name,value) VALUES('anon_ticket_linkinfo','%d');" "REPLACE INTO config(name,value) VALUES('anon_checkin_linkinfo','%d');" "REPLACE INTO config(name,value) VALUES('ticket_linkinfo','%d');" "REPLACE INTO config(name,value) VALUES('checkin_linkinfo','%d');" "REPLACE INTO config(name,value) VALUES('browse_url_cookie_life',%d);" "REPLACE INTO config(name,value) VALUES('default_browse_url','%q');", atoi(PD("atkt","0")), atoi(PD("ack","0")), atoi(PD("tkt","0")), atoi(PD("ck","0")), atoi(PD("cl","0")), PD("bu","dir") ); db_config(0, 0); } atkt = atoi(db_config("anon_ticket_linkinfo","0")); ack = atoi(db_config("anon_checkin_linkinfo","0")); tkt = atoi(db_config("ticket_linkinfo","1")); ck = atoi(db_config("checkin_linkinfo","0")); zBrowseUrl = db_config("default_browse_url","dir"); nCookieLife = atoi(db_config("browse_url_cookie_life", "90")); common_add_nav_item("setup", "Main Setup Menu"); common_add_help_item("CvstracAdminInterface"); common_header("Configure User Interface"); @@
@ common_footer(); } /* ** Generate a string suitable for inserting into a