3 /* Reminder: always indent with 4 spaces (no tabs). */
4 // +---------------------------------------------------------------------------+
6 // +---------------------------------------------------------------------------+
7 // | configuration.php |
9 // | Loads the administration UI and sends input to config.class |
10 // +---------------------------------------------------------------------------+
11 // | Copyright (C) 2007-2008 by the following authors: |
13 // | Authors: Aaron Blankstein - kantai AT gmail DOT com |
14 // +---------------------------------------------------------------------------+
16 // | This program is free software; you can redistribute it and/or |
17 // | modify it under the terms of the GNU General Public License |
18 // | as published by the Free Software Foundation; either version 2 |
19 // | of the License, or (at your option) any later version. |
21 // | This program is distributed in the hope that it will be useful, |
22 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 // | GNU General Public License for more details. |
26 // | You should have received a copy of the GNU General Public License |
27 // | along with this program; if not, write to the Free Software Foundation, |
28 // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
30 // +---------------------------------------------------------------------------+
33 * Geeklog common function library
35 require_once '../lib-common.php';
36 require_once 'auth.inc.php';
39 * Helper function: Provide language dropdown
41 * NOTE: Note that key/value are being swapped!
43 * @return array Array of (filename, displayname) pairs
46 function configmanager_select_language_helper()
50 return array_flip(MBYTE_languageList($_CONF['default_charset']));
54 * Helper function: Provide themes dropdown
56 * NOTE: Beautifying code duplicated from usersettings.php
58 * @return array Array of (filename, displayname) pairs
61 function configmanager_select_theme_helper()
65 $themeFiles = COM_getThemes(true);
66 usort($themeFiles, 'strcasecmp');
68 foreach ($themeFiles as $theme) {
69 $words = explode('_', $theme);
71 foreach ($words as $th) {
72 if ((strtolower($th{0}) == $th{0}) &&
73 (strtolower($th{1}) == $th{1})) {
74 $bwords[] = ucfirst($th);
80 $themes[implode(' ', $bwords)] = $theme;
90 $conf_group = array_key_exists('conf_group', $_POST)
91 ? $_POST['conf_group'] : 'Core';
92 $config =& config::get_instance();
93 $tokenstate = SEC_checkToken();
95 if (array_key_exists('set_action', $_POST) && $tokenstate){
96 if (SEC_inGroup('Root')) {
97 if ($_POST['set_action'] == 'restore') {
98 $config->restore_param($_POST['name'], $conf_group);
99 } elseif ($_POST['set_action'] == 'unset') {
100 $config->unset_param($_POST['name'], $conf_group);
105 if (array_key_exists('form_submit', $_POST) && $tokenstate) {
107 if (! array_key_exists('form_reset', $_POST)) {
108 $result = $config->updateConfig($_POST, $conf_group);
111 if (is_array($result) && (count($result) > 0)) {
112 PLG_configChange($conf_group, array_keys($result));
115 $display = $config->get_ui($conf_group, $_POST['sub_group'], $result);
117 $display = $config->get_ui($conf_group, array_key_exists('subgroup', $_POST)
118 ? $_POST['subgroup'] : null);
121 COM_output($display);