- Update the copyright notices to use the correct year and not a non-ASCII symbol
[bugdar.git] / admin / setting.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2008 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 ($input->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 = BSFunctions::scan_directory('./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] == bugdar::$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 // allownewreg
98 $admin->row_span(T('Allow New Registrations'), 'thead');
99 $admin->row_yesno(T('If this is set to <em>yes</em>, then new users will be allowed to register.'), 'setting[allownewreg]', bugdar::$options['allownewreg']);
100
101 // verifyemail
102 $admin->row_span(T('Require Activation Email'), 'thead');
103 $admin->row_yesno(T('Setting this to yes will force all new users to verify their account with an email activation link.'), 'setting[verifyemail]', bugdar::$options['verifyemail']);
104
105 // moderatenewusers
106 $admin->row_span(T('Moderate New Users'), 'thead');
107 $admin->row_yesno(T('All new users will have to be approved by the administration before being able to have normal user rights.'), 'setting[moderatenewusers]', bugdar::$options['moderatenewusers']);
108
109 // sendwelcomemail
110 $admin->row_span(T('Send New Use Welcome Email'), 'thead');
111 $admin->row_yesno(T('Setting this option to <em>yes</em> will send each new verified user a welcome email.'), 'setting[sendwelcomemail]', bugdar::$options['sendwelcomemail']);
112
113 // webmasteremail
114 $admin->row_span(T('Webmaster Email Address'), 'thead');
115 $admin->row_input(T('The email address from which emails will be sent out.'), 'setting[webmasteremail]', bugdar::$options['webmasteremail']);
116
117 // trackertitle
118 $admin->row_span(T('Tracker Title'), 'thead');
119 $admin->row_input(T('The global name of the bug tracker. Example: Blue Static Bug Tracker'), 'setting[trackertitle]', bugdar::$options['trackertitle']);
120
121 // trackerurl
122 $admin->row_span(T('Tracker Base URL'), 'thead');
123 $admin->row_input(T('The base URL of the tracker. This is used when creating external links to the tracker. <strong>Be sure that this does not end in a trailing slash (&quot;/&quot;).</strong><br />Example: http://www.bluestatic.org/bugs'), 'setting[trackerurl]', bugdar::$options['trackerurl']);
124
125 // dateformat
126 $admin->row_span(T('Date Format'), 'thead');
127 $admin->row_input(T('Set the date format used for bug report and comment information. This is based on PHP\'s date() function.'), 'setting[dateformat]', bugdar::$options['dateformat']);
128
129 // defaulttimezone
130 $admin->row_span(T('Default Time Zone'), 'thead');
131 $admin->row_text(T('This controls the time zone that all unregistered users view the tracker with.'), construct_option_select('setting[defaulttimezone]', $bugsys->datef->fetch_timezone_list(), bugdar::$options['defaulttimezone']), bugdar::$options['defaulttimezone']);
132
133 // defaultlanguage
134 $admin->row_span(T('Default Language'), 'thead');
135 $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'], bugdar::$options['defaultlanguage'], 'languageid', 'title'), bugdar::$options['defaultlanguage']);
136
137 // syndicateditems
138 $admin->row_span(T('Number of Syndicated Items'), 'thead');
139 $admin->row_input(T('The number of bugs to be syndicated at any one time by the Atom XML feed.'), 'setting[syndicateditems]', bugdar::$options['syndicateditems']);
140
141 // redirectheaders
142 $admin->row_span(T('Use Header Redirects'), 'thead');
143 $admin->row_yesno(T('Instead of displaying an intermediate page informing the user that their action was a success and a redirect is occurring, just send the user to the next screen using HTTP headers. This can save bandwidth.'), 'setting[redirectheaders]', bugdar::$options['redirectheaders']);
144
145 $admin->table_end();
146
147 // ###################################################################
148 $admin->table_start();
149 $admin->table_head(T('Bug Reporting Options'));
150
151 // allowhtml
152 $admin->row_span(T('Allow HTML in Bug Reports'), 'thead');
153 $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]', bugdar::$options['allowhtml']);
154
155 // defaultseverity
156 $admin->row_span(T('Default Severity'), 'thead');
157 $admin->row_text(T('The default severity that is selected when creating a new bug report.'), construct_option_select('setting[defaultseverity]', bugdar::$datastore['severity'], bugdar::$options['defaultseverity'], 'severityid', 'severity'));
158
159 // defaultpriority
160 $admin->row_span(T('Default Priority'), 'thead');
161 $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'], bugdar::$options['defaultpriority'], 'priorityid', 'priority'));
162
163 // defaultstatus
164 $admin->row_span(T('Default Status'), 'thead');
165 $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'], bugdar::$options['defaultstatus'], 'statusid', 'status'));
166
167 // defaultresolve
168 $admin->row_span(T('Default Resolution'), 'thead');
169 $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'], bugdar::$options['defaultresolve'], 'resolutionid', 'resolution'));
170
171 // defaultassign
172 $admin->row_span(T('Default Bug Assignment'), 'thead');
173 $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'], bugdar::$options['defaultassign'], 'userid', 'displayname', 0));
174
175 // defaultcomment
176 $admin->row_span(T('Default Comment Text'), 'thead');
177 $admin->row_textarea(T('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.'), 'setting[defaultcomment]', bugdar::$options['defaultcomment']);
178
179 $admin->table_end();
180
181 // ###################################################################
182 $admin->table_start();
183 $admin->table_head(T('Bug Listing Display Options'));
184
185 // hidestatuses
186 $admin->row_span(T('Hide Statuses on Bug Listings'), 'thead');
187 $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'], bugdar::$options['hidestatuses'], 'statusid', 'status', 0, true));
188
189 // defaultsortkey
190 $admin->row_span(T('Default Sort Column'), 'thead');
191 $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, false), bugdar::$options['defaultsortkey']));
192
193 // defaultsortas
194 $admin->row_span(T('Default Sort Direction'), 'thead');
195 $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), bugdar::$options['defaultsortas']));
196
197 // columnoptions
198 $admin->row_span(T('Default Column Ordering Options'), 'thead');
199 $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());
200
201 $admin->table_end();
202
203 // ###################################################################
204 $admin->table_start();
205 $admin->table_head(T('Pagination Options'));
206
207 // defaultpp
208 $admin->row_span(T('Default Per-Page Amount'), 'thead');
209 $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]', bugdar::$options['defaultpp']);
210
211 // maxpp
212 $admin->row_span(T('Maximum Per-Page Value'), 'thead');
213 $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]', bugdar::$options['maxpp']);
214
215 // pagelinks
216 $admin->row_span(T('Number of Page Links'), 'thead');
217 $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]', bugdar::$options['pagelinks']);
218
219 $admin->table_end();
220
221 // ###################################################################
222 if (DEVDEBUG)
223 {
224 $admin->table_start();
225 $admin->table_head('Untouchables');
226
227 // trackerversion
228 $admin->row_span('Version Number', 'thead');
229 $admin->row_input('Version Number', 'setting[trackerversion]', bugdar::$options['trackerversion']);
230
231 $admin->row_span('Custom Gettext Localizer', 'thead');
232 $admin->row_yesno('Use the custom MOReader implementation rather than the built-in Gettext extension.', 'setting[devgettext]', bugdar::$options['devgettext']);
233 }
234
235 // ###################################################################
236 $admin->table_start();
237 $admin->row_submit();
238 $admin->table_end();
239 $admin->form_end();
240
241 $admin->page_end();
242 }
243
244 // ###################################################################
245 /**
246 * Helper function for the bugdar::$options['columnoptions'] setting
247 *
248 * @return string Setting HTML code
249 */
250 function ConstructColumnOptionsSetting()
251 {
252 global $bugsys;
253
254 require_once('./includes/class_sort.php');
255
256 $array = (bugdar::$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) : bugdar::$options['columnoptions']);
257
258 $return = '<table cellspacing="2" cellpadding="1" border="0">';
259 foreach (ListSorter::fetch_by_text(false, false) AS $column => $name)
260 {
261 $return .= '<tr><td><strong>' . $name . '</strong></td><td><input type="text" name="setting[columnoptions][' . $column . ']" size="2" maxlength="2" class="input" value="' . intval($array["$column"]) . '" /></td></tr>';
262 }
263 $return .= '</table>';
264 return $return;
265 }
266
267 ?>