Move the defaulttimzone setting to the new page.
[bugdar.git] / admin / settings.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2013 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 namespace bugdar\admin;
23
24 use \bugdar;
25 use \hoplite\http;
26
27 require_once HOPLITE_ROOT . '/http/action.php';
28 require_once BUGDAR_ROOT . '/includes/functions_datastore.php';
29
30 class SettingsAction extends http\Action implements TemplatePreCaching
31 {
32 public function TemplateSet()
33 {
34 return array('admin_settings');
35 }
36
37 public function Invoke(http\Request $request, http\Response $response)
38 {
39 // TODO(port): global.
40 global $bugsys;
41
42 $response->data['title'] = T('Settings');
43 $response->context['template'] = 'admin_settings';
44
45 $response->data['timezone_list'] = $bugsys->datef->fetch_timezone_list();
46
47 // Save settings on POST.
48 if ($request->http_method == 'POST') {
49 $query_bits = array();
50 $values = array();
51 foreach ($request->data['_POST']['settings'] AS $varname => $value) {
52 $query_bits[] = '(?,?)';
53 array_push($values, $varname, $value);
54 }
55
56 $query = bugdar::$db->Prepare("
57 REPLACE into " . TABLE_PREFIX . "setting
58 (varname, value)
59 VALUES " . implode(', ', $query_bits));
60 $query->Execute($values);
61
62 build_settings();
63
64 $this->controller()->StopWithRedirect($this->controller()->MakeURL('/settings'));
65 }
66 }
67 }