public_html/admin/configuration.php
author Dirk Haun <dirk@haun-online.de>
Sun, 20 Sep 2009 11:00:03 +0200
branchHEAD
changeset 7428 df55886043f2
parent 6970 ebf565e1c06f
child 7434 aa322b3c4d3d
permissions -rw-r--r--
Modernized the "timezone hack", made the config option a dropdown, and moved all timezone-related code into a new TimeZoneConfig class
     1 <?php
     2 
     3 /* Reminder: always indent with 4 spaces (no tabs). */
     4 // +---------------------------------------------------------------------------+
     5 // | Geeklog 1.6                                                               |
     6 // +---------------------------------------------------------------------------+
     7 // | configuration.php                                                         |
     8 // |                                                                           |
     9 // | Loads the administration UI and sends input to config.class               |
    10 // +---------------------------------------------------------------------------+
    11 // | Copyright (C) 2007-2009 by the following authors:                         |
    12 // |                                                                           |
    13 // | Authors: Aaron Blankstein  - kantai AT gmail DOT com                      |
    14 // +---------------------------------------------------------------------------+
    15 // |                                                                           |
    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.                    |
    20 // |                                                                           |
    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.                              |
    25 // |                                                                           |
    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.           |
    29 // |                                                                           |
    30 // +---------------------------------------------------------------------------+
    31 
    32 /**
    33 * Geeklog common function library
    34 */
    35 require_once '../lib-common.php';
    36 require_once 'auth.inc.php';
    37 
    38 /**
    39 * Helper function: Provide language dropdown
    40 *
    41 * NOTE:     Note that key/value are being swapped!
    42 *
    43 * @return   array   Array of (filename, displayname) pairs
    44 *
    45 */
    46 function configmanager_select_language_helper()
    47 {
    48     global $_CONF;
    49 
    50     return array_flip(MBYTE_languageList($_CONF['default_charset']));
    51 }
    52 
    53 /**
    54 * Helper function: Provide themes dropdown
    55 *
    56 * NOTE:     Beautifying code duplicated from usersettings.php
    57 *
    58 * @return   array   Array of (filename, displayname) pairs
    59 *
    60 */
    61 function configmanager_select_theme_helper()
    62 {
    63     $themes = array();
    64 
    65     $themeFiles = COM_getThemes(true);
    66     usort($themeFiles,
    67           create_function('$a,$b', 'return strcasecmp($a,$b);'));
    68 
    69     foreach ($themeFiles as $theme) {
    70         $words = explode ('_', $theme);
    71         $bwords = array ();
    72         foreach ($words as $th) {
    73             if ((strtolower ($th{0}) == $th{0}) &&
    74                 (strtolower ($th{1}) == $th{1})) {
    75                 $bwords[] = strtoupper ($th{0}) . substr ($th, 1);
    76             } else {
    77                 $bwords[] = $th;
    78             }
    79         }
    80 
    81         $themes[implode(' ', $bwords)] = $theme;
    82     }
    83 
    84     return $themes;
    85 }
    86 
    87 /**
    88 * Helper function: Provide timezone dropdown
    89 *
    90 * @return   array   Array of (timezone-long-name, timezone-short-name) pairs
    91 *
    92 */
    93 function configmanager_select_timezone_helper()
    94 {
    95     global $_CONF;
    96 
    97     require_once $_CONF['path_system'] . 'classes/timezoneconfig.class.php';
    98 
    99     return array_flip(TimeZoneConfig::listAvailableTimeZones());
   100 }
   101 
   102 
   103 // MAIN
   104 $display = '';
   105 
   106 $conf_group = array_key_exists('conf_group', $_POST)
   107             ? $_POST['conf_group'] : 'Core';
   108 $config =& config::get_instance();
   109 $tokenstate = SEC_checkToken();
   110 
   111 if (array_key_exists('set_action', $_POST) && $tokenstate){
   112     if (SEC_inGroup('Root')) {
   113         if ($_POST['set_action'] == 'restore') {
   114             $config->restore_param($_POST['name'], $conf_group);
   115         } elseif ($_POST['set_action'] == 'unset') {
   116             $config->unset_param($_POST['name'], $conf_group);
   117         }
   118     }
   119 }
   120 
   121 if (array_key_exists('form_submit', $_POST) && $tokenstate) {
   122     $result = null;
   123     if (! array_key_exists('form_reset', $_POST)) {
   124         $result = $config->updateConfig($_POST, $conf_group);
   125 
   126         // notify plugins
   127         if (is_array($result) && (count($result) > 0)) {
   128             PLG_configChange($conf_group, array_keys($result));
   129         }
   130     }
   131     $display = $config->get_ui($conf_group, $_POST['sub_group'], $result);
   132 } else {
   133     $display = $config->get_ui($conf_group, array_key_exists('subgroup', $_POST)
   134                                             ?  $_POST['subgroup'] : null);
   135 }
   136 
   137 COM_output($display);
   138 
   139 ?>