From f681909d0babb197d372a141eb6ab15b4099e231 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 22 Jul 2006 02:47:10 +0000 Subject: [PATCH] r920: Cleaning up the entire settings system --- admin/setting.php | 83 ++++++++++++++++++----------------------- includes/settings.php | 86 +++++++++++++++++++++---------------------- 2 files changed, 79 insertions(+), 90 deletions(-) diff --git a/admin/setting.php b/admin/setting.php index 10c9201..99961b2 100755 --- a/admin/setting.php +++ b/admin/setting.php @@ -43,9 +43,7 @@ if (empty($_REQUEST['do'])) if ($_POST['do'] == 'update') { - $settings = $_POST['setting']; - - foreach ($settings AS $varname => $value) + foreach ($bugsys->in['setting'] AS $varname => $value) { $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $bugsys->escape($varname) . "', '" . $bugsys->escape($value) . "')"); } @@ -63,65 +61,56 @@ if ($_REQUEST['do'] == 'modify') $admin->form_start('setting.php', 'update'); - $settings = $db->query("SELECT * FROM " . TABLE_PREFIX . "setting "); - while ($setting = $db->fetch_array($settings)) - { - $options["$setting[varname]"] = $setting['value']; - } - $IS_SETTINGS = true; - unset($settings, $setting); - - foreach ($config AS $varname => $setting) - { - $settings["$setting[0]"][] = $setting; - } - // Don't let them normal folk see what's going on ;-) if (!DEVDEBUG) { - unset($settings['untouchables'], $define['untouchables']); + unset($settings['untouchables']); } - unset($config); - - foreach ($define AS $group => $name) + $firstloop = true; + foreach ($settings AS $group => $values) { - $admin->table_start(); - $admin->table_head($name); - foreach ($settings["$group"] AS $opt) + foreach ($values AS $key => $options) { - if (!isset($options["$opt[1]"])) + if ($key == ':lang') { - $options["$opt[1]"] = $opt[3]; + if (!$firstloop) + { + $admin->table_end(); + } + $admin->table_start(); + $admin->table_head($options); } - - $admin->row_span('" . $opt[5] . "", 'thead'); - switch ($opt[2]) + else { - case 'textbox': - $admin->row_input($opt[6], 'setting[' . $opt[1] . ']', $options["$opt[1]"]); - break; - - case 'textarea': - $admin->row_textarea($opt[6], 'setting[' . $opt[1] . ']', $options["$opt[1]"]); - break; - - case 'yesno': - $admin->list_item($lang->string('Yes'), '1', (($options["$opt[1]"]) ? true : false)); - $admin->list_item($lang->string('No'), '0', (($options["$opt[1]"]) ? false : true)); - $admin->row_list($opt[6], 'setting[' . $opt[1] . ']', false); - break; - - default: - eval('$optcode = "' . $opt[2] . '";'); - $admin->row_text($opt[6], $optcode); - break; + $admin->row_span('" . $options[3] . "", 'thead'); + switch ($options[0]) + { + case 'textbox': + $admin->row_input($options[4], 'setting[' . $key . ']', $bugsys->options["$key"]); + break; + + case 'textarea': + $admin->row_textarea($options[4], 'setting[' . $key . ']', $bugsys->options["$key"]); + break; + + case 'yesno': + $admin->list_item($lang->string('Yes'), '1', ($bugsys->options["$key"] ? true : false)); + $admin->list_item($lang->string('No'), '0', ($bugsys->options["$key"] ? false : true)); + $admin->row_list($options[4], 'setting[' . $key . ']', false); + break; + + default: + eval('$optcode = "' . $options[0] . '";'); + $admin->row_text($options[4], $optcode); + break; + } } } - $admin->table_end(); } + $admin->table_end(); $admin->table_start(); $admin->row_submit(); diff --git a/includes/settings.php b/includes/settings.php index 2e50de0..cc74982 100755 --- a/includes/settings.php +++ b/includes/settings.php @@ -29,53 +29,53 @@ \*--------------------------------------------------------------------*/ /* -$define[GROUPNAME] = GROUPNAME; <-- sets up an option group -$config[VARNAME] = array(GROUPNAME, VARNAME, CODE, DEFAULT, VOLATILE, NAME, DESCRIPTION); <-- sets up a setting +VARNAME => array(CODE, DEFAULT, VOLATILE, NAME, DESCRIPTION); <-- sets up a setting */ -$settingconfig = array(); - -// ################################################################### - -$define['general'] = $lang->string('General Options'); - -$config['allownewreg'] = array('general', 'allownewreg', 'yesno', 1, false, $lang->string('Allow New Registrations'), $lang->string('If this is set to yes, then new users will be allowed to register.')); -$config['verifyemail'] = array('general', 'verifyemail', 'yesno', 0, false, $lang->string('Require Activation Email'), $lang->string('Setting this to yes will force all new users to verify their account with an email activation link.')); -$config['moderatenewusers'] = array('general', 'moderatenewusers', 'yesno', 0, false, $lang->string('Moderate New Users'), $lang->string('All new users will have to be approved by the administration before being able to have normal user rights.')); -$config['sendwelcomemail'] = array('general', 'sendwelcomemail', 'yesno', 1, false, $lang->string('Send New Use Welcome Email'), $lang->string('Setting this option to yes will send each new verified user a welcome email.')); -$config['webmasteremail'] = array('general', 'webmasteremail', 'textbox', '', false, $lang->string('Webmaster Email Address'), $lang->string('The email address from which emails will be sent out.')); -$config['trackertitle'] = array('general', 'trackertitle', 'textbox', '', false, $lang->string('Tracker Title'), $lang->string('The global name of the bug tracker. Example: Iris Studios Bug Tracker')); -$config['trackerurl'] = array('general', 'trackerurl', 'textbox', '', false, $lang->string('Tracker Base URL'), $lang->string('The base URL of the tracker. This is used when creating external links to the tracker. Be sure that this does not end in a trailing slash ("/").
Example: http://www.iris-studios.com/bugs')); -$config['dateformat'] = array('general', 'dateformat', 'textbox', 'F j, Y h:i:s A', false, $lang->string('Date Format'), $lang->string('Set the date format used for bug report and comment information. This is based on PHP\'s date() function.')); -$config['defaultlanguage'] = array('general', 'defaultlanguage', '" . construct_option_select(\'setting[defaultlanguage]\', $bugsys->datastore[\'language\'], $bugsys->options[\'defaultlanguage\'], \'languageid\', \'title\') . "', 1, false, $lang->string('Default Language'), $lang->string('You can set the default language that all new users (and guests) will use.')); -$config['syndicateditems'] = array('general', 'syndicateditems', 'textbox', 10, false, $lang->string('Number of Syndicated Items'), $lang->string('The number of bugs to be syndicated at any one time by the Atom XML feed.')); - // ################################################################### -$define['reporting'] = $lang->string('Bug Reporting Options'); - -$config['allowhtml'] = array('reporting', 'allowhtml', 'yesno', 0, false, $lang->string('Allow HTML in Bug Reports'), $lang->string('Set this to yes if you want to allow users to post raw HTML in their bug reports. This is very dangerous and it is not recommended.')); -$config['defaultseverity'] = array('reporting', 'defaultseverity', '" . construct_option_select(\'setting[defaultseverity]\', $bugsys->datastore[\'severity\'], $bugsys->options[\'defaultseverity\'], \'severityid\', \'severity\') . "', 2, false, $lang->string('Default Severity'), $lang->string('The default severity that is selected when creating a new bug report.')); -$config['defaultpriority'] = array('reporting', 'defaultpriority', '" . construct_option_select(\'setting[defaultpriority]\', $bugsys->datastore[\'priority\'], $bugsys->options[\'defaultpriority\'], \'priorityid\', \'priority\') . "', 3, false, $lang->string('Default Priority'), $lang->string('The default priority that will be selected when creating a new bug report. Depending on your permission setup, the user may not be able to set this in a new report so this will act as the value.')); -$config['defaultstatus'] = array('reporting', 'defaultstatus', '" . construct_option_select(\'setting[defaultstatus]\', $bugsys->datastore[\'status\'], $bugsys->options[\'defaultstatus\'], \'statusid\', \'status\') . "', 1, false, $lang->string('Default Status'), $lang->string('The default default that is selected when creating a new bug report. If a user can not assign a status, this will be the one inserted into the database.')); -$config['defaultresolve'] = array('reporting', 'defaultresolve', '" . construct_option_select(\'setting[defaultresolve]\', $bugsys->datastore[\'resolution\'], $bugsys->options[\'defaultresolve\'], \'resolutionid\', \'resolution\') . "', 1, false, $lang->string('Default Resolution'), $lang->string('This is the default bug resolution. If a user is not able to change this field, setting this will act as the default value.')); -$config['defaultassign'] = array('reporting', 'defaultassign', '" . construct_option_select(\'setting[defaultassign]\', $bugsys->datastore[\'assignto\'], $bugsys->options[\'defaultassign\'], \'userid\', \'displayname\', 0) . "', 0, false, $lang->string('Default Bug Assignment'), $lang->string('This is the default developer new bugs will be assigned to. If a user does not have permisssion to assign bugs, this will be the default. If you don\'t want any default assignment, leave this as Not Selected.')); -$config['defaultcomment'] = array('reporting', 'defaultcomment', 'textarea', '', false, $lang->string('Default Comment Text'), $lang->string('If you wish to set a template for entering the initial comment of a bug report, then you may specify this here. However, the template will only take effect on the initial report/comment. Note: the template cannot be forced on the user as there is no way to validate it.')); - -// ################################################################### - -$define['pagination'] = $lang->string('Pagination Options'); - -$config['defaultpp'] = array('pagination', 'defaultpp', 'textbox', 20, false, $lang->string('Default Per-Page Amount'), $lang->string('The number of items (e.g. bugs) to be displayed on a page by default. The user will have the option of over-riding these values.')); -$config['maxpp'] = array('pagination', 'maxpp', 'textbox', 100, false, $lang->string('Maximum Per-Page Value'), $lang->string('To prevent your server from experiencing load problems, set the maximum per page limit. Specifying a value here will make sure any user-entered value will not be higher than this, preventing server load problems.')); -$config['pagelinks'] = array('pagination', 'pagelinks', 'textbox', 3, false, $lang->string('Number of Page Links'), $lang->string('The number of pages that will appear in the page navigation system on either side of the current page. Set this to 0 to display all pages.')); - -// ################################################################### - -$define['untouchables'] = $lang->string('Untouchables'); - -$config['trackerversion'] = array('untouchables', 'trackerversion', 'textbox', '[#]version[#]', true, $lang->string('Tracker Version Number'), $lang->string('Do not touch this!')); - +$settings = array( +'general' => array( + ':lang' => $lang->string('General Options'), + + 'allownewreg' => array('yesno', 1, false, $lang->string('Allow New Registrations'), $lang->string('If this is set to yes, then new users will be allowed to register.')), + 'verifyemail' => array('yesno', 0, false, $lang->string('Require Activation Email'), $lang->string('Setting this to yes will force all new users to verify their account with an email activation link.')), + 'moderatenewusers' => array('yesno', 0, false, $lang->string('Moderate New Users'), $lang->string('All new users will have to be approved by the administration before being able to have normal user rights.')), + 'sendwelcomemail' => array('yesno', 1, false, $lang->string('Send New Use Welcome Email'), $lang->string('Setting this option to yes will send each new verified user a welcome email.')), + 'webmasteremail' => array('textbox', '', false, $lang->string('Webmaster Email Address'), $lang->string('The email address from which emails will be sent out.')), + 'trackertitle' => array('textbox', '', false, $lang->string('Tracker Title'), $lang->string('The global name of the bug tracker. Example: Iris Studios Bug Tracker')), + 'trackerurl' => array('textbox', '', false, $lang->string('Tracker Base URL'), $lang->string('The base URL of the tracker. This is used when creating external links to the tracker. Be sure that this does not end in a trailing slash ("/").
Example: http://www.iris-studios.com/bugs')), + 'dateformat' => array('textbox', 'F j, Y h:i:s A', false, $lang->string('Date Format'), $lang->string('Set the date format used for bug report and comment information. This is based on PHP\'s date() function.')), + 'defaultlanguage' => array('" . construct_option_select(\'setting[defaultlanguage]\', $bugsys->datastore[\'language\'], $bugsys->options[\'defaultlanguage\'], \'languageid\', \'title\') . "', 1, false, $lang->string('Default Language'), $lang->string('You can set the default language that all new users (and guests) will use.')), + 'syndicateditems' => array('textbox', 10, false, $lang->string('Number of Syndicated Items'), $lang->string('The number of bugs to be syndicated at any one time by the Atom XML feed.')) +), + +'reporting' => array( + ':lang' => $lang->string('Bug Reporting Options'), + + 'allowhtml' => array('yesno', 0, false, $lang->string('Allow HTML in Bug Reports'), $lang->string('Set this to yes if you want to allow users to post raw HTML in their bug reports. This is very dangerous and it is not recommended.')), + 'defaultseverity' => array('" . construct_option_select(\'setting[defaultseverity]\', $bugsys->datastore[\'severity\'], $bugsys->options[\'defaultseverity\'], \'severityid\', \'severity\') . "', 2, false, $lang->string('Default Severity'), $lang->string('The default severity that is selected when creating a new bug report.')), + 'defaultpriority' => array('" . construct_option_select(\'setting[defaultpriority]\', $bugsys->datastore[\'priority\'], $bugsys->options[\'defaultpriority\'], \'priorityid\', \'priority\') . "', 3, false, $lang->string('Default Priority'), $lang->string('The default priority that will be selected when creating a new bug report. Depending on your permission setup, the user may not be able to set this in a new report so this will act as the value.')), + 'defaultstatus' => array('" . construct_option_select(\'setting[defaultstatus]\', $bugsys->datastore[\'status\'], $bugsys->options[\'defaultstatus\'], \'statusid\', \'status\') . "', 1, false, $lang->string('Default Status'), $lang->string('The default default that is selected when creating a new bug report. If a user can not assign a status, this will be the one inserted into the database.')), + 'defaultresolve' => array('" . construct_option_select(\'setting[defaultresolve]\', $bugsys->datastore[\'resolution\'], $bugsys->options[\'defaultresolve\'], \'resolutionid\', \'resolution\') . "', 1, false, $lang->string('Default Resolution'), $lang->string('This is the default bug resolution. If a user is not able to change this field, setting this will act as the default value.')), + 'defaultassign' => array('" . construct_option_select(\'setting[defaultassign]\', $bugsys->datastore[\'assignto\'], $bugsys->options[\'defaultassign\'], \'userid\', \'displayname\', 0) . "', 0, false, $lang->string('Default Bug Assignment'), $lang->string('This is the default developer new bugs will be assigned to. If a user does not have permisssion to assign bugs, this will be the default. If you don\'t want any default assignment, leave this as Not Selected.')), + 'defaultcomment' => array('textarea', '', false, $lang->string('Default Comment Text'), $lang->string('If you wish to set a template for entering the initial comment of a bug report, then you may specify this here. However, the template will only take effect on the initial report/comment. Note: the template cannot be forced on the user as there is no way to validate it.')) +), + +'pagination' => array( + ':lang' => $lang->string('Pagination Options'), + + 'defaultpp' => array('textbox', 20, false, $lang->string('Default Per-Page Amount'), $lang->string('The number of items (e.g. bugs) to be displayed on a page by default. The user will have the option of over-riding these values.')), + 'maxpp' => array('textbox', 100, false, $lang->string('Maximum Per-Page Value'), $lang->string('To prevent your server from experiencing load problems, set the maximum per page limit. Specifying a value here will make sure any user-entered value will not be higher than this, preventing server load problems.')), + 'pagelinks' => array('textbox', 3, false, $lang->string('Number of Page Links'), $lang->string('The number of pages that will appear in the page navigation system on either side of the current page. Set this to 0 to display all pages.')) +), + +'untouchables' => array( + ':lang' => $lang->string('Untouchables'), + + 'trackerversion' => array('textbox', '[#]version[#]', true, $lang->string('Tracker Version Number'), $lang->string('Do not touch this!')) +) +); /*=====================================================================*\ || ################################################################### -- 2.22.5