public_html/admin/configuration.php
author Dirk Haun <dirk@haun-online.de>
Sun, 04 Oct 2009 17:36:41 +0200
branchHEAD
changeset 7360 d37545da9eb2
parent 6970 ebf565e1c06f
child 7434 aa322b3c4d3d
permissions -rw-r--r--
Minor code cleanup
     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-2008 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, 'strcasecmp');
    67 
    68     foreach ($themeFiles as $theme) {
    69         $words = explode('_', $theme);
    70         $bwords = array();
    71         foreach ($words as $th) {
    72             if ((strtolower($th{0}) == $th{0}) &&
    73                 (strtolower($th{1}) == $th{1})) {
    74                 $bwords[] = ucfirst($th);
    75             } else {
    76                 $bwords[] = $th;
    77             }
    78         }
    79 
    80         $themes[implode(' ', $bwords)] = $theme;
    81     }
    82 
    83     return $themes;
    84 }
    85 
    86 
    87 // MAIN
    88 $display = '';
    89 
    90 $conf_group = array_key_exists('conf_group', $_POST)
    91             ? $_POST['conf_group'] : 'Core';
    92 $config =& config::get_instance();
    93 $tokenstate = SEC_checkToken();
    94 
    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);
   101         }
   102     }
   103 }
   104 
   105 if (array_key_exists('form_submit', $_POST) && $tokenstate) {
   106     $result = null;
   107     if (! array_key_exists('form_reset', $_POST)) {
   108         $result = $config->updateConfig($_POST, $conf_group);
   109 
   110         // notify plugins
   111         if (is_array($result) && (count($result) > 0)) {
   112             PLG_configChange($conf_group, array_keys($result));
   113         }
   114     }
   115     $display = $config->get_ui($conf_group, $_POST['sub_group'], $result);
   116 } else {
   117     $display = $config->get_ui($conf_group, array_key_exists('subgroup', $_POST)
   118                                             ?  $_POST['subgroup'] : null);
   119 }
   120 
   121 COM_output($display);
   122 
   123 ?>