Move the defaulttimzone setting to the new page.
[bugdar.git] / admin / setting.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2007 Blue Static
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 2 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/class_sort.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 $updates = array();
47 foreach ($bugsys->in['setting'] AS $varname => $value)
48 {
49 if (is_array($value))
50 {
51 if ($varname == 'columnoptions')
52 {
53 $value = serialize($value);
54 }
55 else
56 {
57 $value = implode(',', $value);
58 }
59 }
60
61 $updates[] = "('" . $bugsys->escape($varname) . "', '" . $bugsys->escape($value) . "')";
62 }
63
64 $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES " . implode(',', $updates));
65
66 build_settings();
67
68 $admin->redirect('setting.php');
69 }
70
71 // ###################################################################
72
73 if ($_REQUEST['do'] == 'modify')
74 {
75 $admin->page_start(T('Settings'));
76
77 $admin->form_start('setting.php', 'update');
78
79 $IS_SETTINGS = true;
80
81 // ###################################################################
82 $admin->table_start();
83 $admin->table_head(T('General Options'));
84
85 // authmethod
86 $admin->row_span(T('Authentication Method'), 'thead');
87 $methods = $funct->scandir('./includes/auth/');
88 foreach ($methods[''] AS $path)
89 {
90 if (preg_match('#auth_(.*)\.php#', $path, $matches))
91 {
92 $admin->list_item(ucwords(str_replace('_', ' ', $matches[1])), $matches[1], ($matches[1] == $bugsys->options['authmethod']));
93 }
94 }
95 $admin->row_list(T('The authentication class to use to validate cookie data and longins. You may need to edit the actual file for certain authentication systems.'), 'setting[authmethod]');
96
97 // defaultlanguage
98 $admin->row_span(T('Default Language'), 'thead');
99 $admin->row_text(T('You can set the default language that all new users (and guests) will use.'), construct_option_select('setting[defaultlanguage]', Bugdar::$datastore['language'], $bugsys->options['defaultlanguage'], 'languageid', 'title'), $bugsys->options['defaultlanguage']);
100
101 $admin->table_end();
102
103 // ###################################################################
104 $admin->table_start();
105 $admin->table_head(T('Bug Reporting Options'));
106
107 // allowhtml
108 $admin->row_span(T('Allow HTML in Bug Reports'), 'thead');
109 $admin->row_yesno(T('Set this to <em>yes</em> if you want to allow users to post raw HTML in their bug reports. This is <strong>very</strong> dangerous and it is not recommended.'), 'setting[allowhtml]', $bugsys->options['allowhtml']);
110
111 // defaultseverity
112 $admin->row_span(T('Default Severity'), 'thead');
113 $admin->row_text(T('The default severity that is selected when creating a new bug report.'), construct_option_select('setting[defaultseverity]', Bugdar::$datastore['severity'], $bugsys->options['defaultseverity'], 'severityid', 'severity'));
114
115 // defaultpriority
116 $admin->row_span(T('Default Priority'), 'thead');
117 $admin->row_text(T('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.'), construct_option_select('setting[defaultpriority]', Bugdar::$datastore['priority'], $bugsys->options['defaultpriority'], 'priorityid', 'priority'));
118
119 // defaultstatus
120 $admin->row_span(T('Default Status'), 'thead');
121 $admin->row_text(T('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.'), construct_option_select('setting[defaultstatus]', Bugdar::$datastore['status'], $bugsys->options['defaultstatus'], 'statusid', 'status'));
122
123 // defaultresolve
124 $admin->row_span(T('Default Resolution'), 'thead');
125 $admin->row_text(T('This is the default bug resolution. If a user is not able to change this field, setting this will act as the default value.'), construct_option_select('setting[defaultresolve]', Bugdar::$datastore['resolution'], $bugsys->options['defaultresolve'], 'resolutionid', 'resolution'));
126
127 // defaultassign
128 $admin->row_span(T('Default Bug Assignment'), 'thead');
129 $admin->row_text(T('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 <em>Not Selected</em>.'), construct_option_select('setting[defaultassign]', Bugdar::$datastore['assignto'], $bugsys->options['defaultassign'], 'userid', 'displayname', 0));
130
131
132 $admin->table_end();
133
134 // ###################################################################
135 $admin->table_start();
136 $admin->table_head(T('Bug Listing Display Options'));
137
138 // hidestatuses
139 $admin->row_span(T('Hide Statuses on Bug Listings'), 'thead');
140 $admin->row_text(T('Here you can specify which statuses to hide on the bug list displays. Users have options in their controls to change this from these values, and this does not affect searches or the favorites list.'), construct_option_select('setting[hidestatuses]', Bugdar::$datastore['status'], $bugsys->options['hidestatuses'], 'statusid', 'status', 0, true));
141
142 // defaultsortkey
143 $admin->row_span(T('Default Sort Column'), 'thead');
144 $admin->row_text(T('Select the column to sort bugs by on listings. This is only a default setting which users can override in their preferences.'), construct_option_select('setting[defaultsortkey]', ListSorter::fetch_by_text(false), $bugsys->options['defaultsortkey']));
145
146 // defaultsortas
147 $admin->row_span(T('Default Sort Direction'), 'thead');
148 $admin->row_text(T('Specify the default direction to sort bugs in the selected column. This works with and follows the same rules as the Sort Column.'), construct_option_select('setting[defaultsortas]', ListSorter::fetch_as_text(false), $bugsys->options['defaultsortas']));
149
150 // columnoptions
151 $admin->row_span(T('Default Column Ordering Options'), 'thead');
152 $admin->row_text(T('Specify the order of the columns for bug listings. The value 0 disables the display of a column and if two or more columns have the same position number, they will be displayed in the same column.'), ConstructColumnOptionsSetting());
153
154 $admin->table_end();
155
156 // ###################################################################
157 $admin->table_start();
158 $admin->table_head(T('Pagination Options'));
159
160 // defaultpp
161 $admin->row_span(T('Default Per-Page Amount'), 'thead');
162 $admin->row_input(T('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.'), 'setting[defaultpp]', $bugsys->options['defaultpp']);
163
164 // maxpp
165 $admin->row_span(T('Maximum Per-Page Value'), 'thead');
166 $admin->row_input(T('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.'), 'setting[maxpp]', $bugsys->options['maxpp']);
167
168 // pagelinks
169 $admin->row_span(T('Number of Page Links'), 'thead');
170 $admin->row_input(T('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.'), 'setting[pagelinks]', $bugsys->options['pagelinks']);
171
172 $admin->table_end();
173
174 // ###################################################################
175 if (DEVDEBUG)
176 {
177 $admin->table_start();
178 $admin->table_head('Untouchables');
179
180 // trackerversion
181 $admin->row_span('Version Number', 'thead');
182 $admin->row_input('Version Number', 'setting[trackerversion]', $bugsys->options['trackerversion']);
183 }
184
185 // ###################################################################
186 $admin->table_start();
187 $admin->row_submit();
188 $admin->table_end();
189 $admin->form_end();
190
191 $admin->page_end();
192 }
193
194 // ###################################################################
195 /**
196 * Helper function for the $bugsys->options['columnoptions'] setting
197 *
198 * @return string Setting HTML code
199 */
200 function ConstructColumnOptionsSetting()
201 {
202 global $bugsys;
203
204 $array = ($bugsys->options['columnoptions'] == null ? array('bugid' => 1, 'summary' => 2, 'userid' => 2, 'product' => 3, 'version' => 3, 'component' => 0, 'status' => 4, 'resolution' => 4, 'priority' => 5, 'severity' => 5, 'lastpost' => 6, 'votes' => 0) : $bugsys->options['columnoptions']);
205
206 $return = '<table cellspacing="2" cellpadding="1" border="0">';
207 foreach ($bugsys->columns AS $column => $mask)
208 {
209 $return .= '<tr><td><strong>' . $bugsys->columnNames["$column"] . '</strong></td><td><input type="text" name="setting[columnoptions][' . $column . ']" size="2" maxlength="2" class="input" value="' . intval($array["$column"]) . '" /></td></tr>';
210 }
211 $return .= '</table>';
212 return $return;
213 }
214