]> src.bluestatic.org Git - bugdar.git/blob - admin/setting.php
r836: Implementing user API in userctrl.php
[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 if (!can_perform('canadmintools'))
27 {
28 admin_login();
29 }
30
31 // ###################################################################
32
33 if (empty($_REQUEST['do']))
34 {
35 $_REQUEST['do'] = 'modify';
36 }
37
38 // ###################################################################
39
40 if ($_POST['do'] == 'update')
41 {
42 $settings = $_POST['setting'];
43
44 foreach ($settings AS $varname => $value)
45 {
46 $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $bugsys->escape($varname) . "', '" . $bugsys->escape($value) . "')");
47 }
48
49 build_settings();
50
51 $admin->redirect('setting.php');
52 }
53
54 // ###################################################################
55
56 if ($_REQUEST['do'] == 'modify')
57 {
58 $admin->page_start($lang->string('Settings'));
59
60 $admin->form_start('setting.php', 'update');
61
62 $settings = $db->query("SELECT * FROM " . TABLE_PREFIX . "setting ");
63 while ($setting = $db->fetch_array($settings))
64 {
65 $options["$setting[varname]"] = $setting['value'];
66 }
67
68 $IS_SETTINGS = true;
69
70 unset($settings, $setting);
71
72 foreach ($config AS $varname => $setting)
73 {
74 $settings["$setting[0]"][] = $setting;
75 }
76
77 // Don't let them normal folk see what's going on ;-)
78 if (!DEVDEBUG)
79 {
80 unset($settings['untouchables'], $define['untouchables']);
81 }
82
83 unset($config);
84
85 foreach ($define AS $group => $name)
86 {
87 $admin->table_start();
88 $admin->table_head($name, 2, 'admin_settings_' . $group);
89 foreach ($settings["$group"] AS $opt)
90 {
91 $admin->row_span('<span' . ((DEVDEBUG) ? ' title="$bugsys->options[\'' . $opt[1] . '\']"' : '') . "><strong>" . $opt[5] . "</strong></span>", 'thead');
92 switch ($opt[2])
93 {
94 case 'textbox':
95 $admin->row_input($opt[6], 'setting[' . $opt[1] . ']', $options["$opt[1]"]);
96 break;
97
98 case 'textarea':
99 $admin->row_textarea($opt[6], 'setting[' . $opt[1] . ']', $options["$opt[1]"]);
100 break;
101
102 case 'yesno':
103 if (!isset($options["$opt[1]"]))
104 {
105 $options["$opt[1]"] = $opt[3];
106 }
107
108 $admin->list_item($lang->string('Yes'), '1', (($options["$opt[1]"]) ? true : false));
109 $admin->list_item($lang->string('No'), '0', (($options["$opt[1]"]) ? false : true));
110 $admin->row_list($opt[6], 'setting[' . $opt[1] . ']', false);
111 break;
112
113 default:
114 eval('$optcode = "' . $opt[2] . '";');
115 $admin->row_text($opt[6], $optcode);
116 break;
117 }
118 }
119 $admin->table_end();
120 }
121
122 $admin->table_start();
123 $admin->row_submit();
124 $admin->table_end();
125 $admin->form_end();
126
127 $admin->page_end();
128 }
129
130 /*=====================================================================*\
131 || ###################################################################
132 || # $HeadURL$
133 || # $Id$
134 || ###################################################################
135 \*=====================================================================*/
136 ?>