r883: - Updating the Admin CP navigation system
[bugdar.git] / admin / setting.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 require_once('./global.php');
23 require_once('./includes/settings.php');
24 require_once('./includes/functions_datastore.php');
25
26 NavLinks::optionsPages();
27 $navigator->set_focus('tab', 'options', null);
28 $navigator->set_focus('link', 'options-pages-settings', 'options-pages');
29
30 if (!can_perform('canadmintools'))
31 {
32 admin_login();
33 }
34
35 // ###################################################################
36
37 if (empty($_REQUEST['do']))
38 {
39 $_REQUEST['do'] = 'modify';
40 }
41
42 // ###################################################################
43
44 if ($_POST['do'] == 'update')
45 {
46 $settings = $_POST['setting'];
47
48 foreach ($settings AS $varname => $value)
49 {
50 $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $bugsys->escape($varname) . "', '" . $bugsys->escape($value) . "')");
51 }
52
53 build_settings();
54
55 $admin->redirect('setting.php');
56 }
57
58 // ###################################################################
59
60 if ($_REQUEST['do'] == 'modify')
61 {
62 $admin->page_start($lang->string('Settings'));
63
64 $admin->form_start('setting.php', 'update');
65
66 $settings = $db->query("SELECT * FROM " . TABLE_PREFIX . "setting ");
67 while ($setting = $db->fetch_array($settings))
68 {
69 $options["$setting[varname]"] = $setting['value'];
70 }
71
72 $IS_SETTINGS = true;
73
74 unset($settings, $setting);
75
76 foreach ($config AS $varname => $setting)
77 {
78 $settings["$setting[0]"][] = $setting;
79 }
80
81 // Don't let them normal folk see what's going on ;-)
82 if (!DEVDEBUG)
83 {
84 unset($settings['untouchables'], $define['untouchables']);
85 }
86
87 unset($config);
88
89 foreach ($define AS $group => $name)
90 {
91 $admin->table_start();
92 $admin->table_head($name, 2, 'admin_settings_' . $group);
93 foreach ($settings["$group"] AS $opt)
94 {
95 if (!isset($options["$opt[1]"]))
96 {
97 $options["$opt[1]"] = $opt[3];
98 }
99
100 $admin->row_span('<span' . ((DEVDEBUG) ? ' title="$bugsys->options[\'' . $opt[1] . '\']"' : '') . "><strong>" . $opt[5] . "</strong></span>", 'thead');
101 switch ($opt[2])
102 {
103 case 'textbox':
104 $admin->row_input($opt[6], 'setting[' . $opt[1] . ']', $options["$opt[1]"]);
105 break;
106
107 case 'textarea':
108 $admin->row_textarea($opt[6], 'setting[' . $opt[1] . ']', $options["$opt[1]"]);
109 break;
110
111 case 'yesno':
112 $admin->list_item($lang->string('Yes'), '1', (($options["$opt[1]"]) ? true : false));
113 $admin->list_item($lang->string('No'), '0', (($options["$opt[1]"]) ? false : true));
114 $admin->row_list($opt[6], 'setting[' . $opt[1] . ']', false);
115 break;
116
117 default:
118 eval('$optcode = "' . $opt[2] . '";');
119 $admin->row_text($opt[6], $optcode);
120 break;
121 }
122 }
123 $admin->table_end();
124 }
125
126 $admin->table_start();
127 $admin->row_submit();
128 $admin->table_end();
129 $admin->form_end();
130
131 $admin->page_end();
132 }
133
134 /*=====================================================================*\
135 || ###################################################################
136 || # $HeadURL$
137 || # $Id$
138 || ###################################################################
139 \*=====================================================================*/
140 ?>