make changing default theme in settings recurse through customers and admins if changing themes for them is disallowed, fixes #1233
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -40,7 +40,7 @@ return array(
|
||||
'default' => 'Froxlor',
|
||||
'option_mode' => 'one',
|
||||
'option_options_method' => 'getThemes',
|
||||
'save_method' => 'storeSettingField',
|
||||
'save_method' => 'storeSettingDefaultTheme',
|
||||
),
|
||||
'panel_allow_theme_change_customer' => array(
|
||||
'label' => $lng['serversettings']['panel_allow_theme_change_customer'],
|
||||
|
||||
56
lib/functions/settings/function.storeSettingDefaultTheme.php
Normal file
56
lib/functions/settings/function.storeSettingDefaultTheme.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
* @since 0.9.29.1
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* updates the setting for the default panel-theme
|
||||
* and also the user themes (customers and admins) if
|
||||
* the changing of themes is disallowed for them
|
||||
*
|
||||
* @param string $fieldname
|
||||
* @param array $fielddata
|
||||
* @param mixed $newfieldvalue
|
||||
*
|
||||
* @return boolean|array
|
||||
*/
|
||||
function storeSettingDefaultTheme($fieldname, $fielddata, $newfieldvalue) {
|
||||
|
||||
// first save the setting itself
|
||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||
|
||||
if ($returnvalue !== false
|
||||
&& is_array($fielddata)
|
||||
&& isset($fielddata['settinggroup'])
|
||||
&& $fielddata['settinggroup'] == 'panel'
|
||||
&& isset($fielddata['varname'])
|
||||
&& $fielddata['varname'] == 'default_theme'
|
||||
) {
|
||||
global $db;
|
||||
// now, if changing themes is disabled we recursivly set
|
||||
// the new theme (customers and admin, depending on settings)
|
||||
if (getSetting('panel', 'allow_theme_change_customer') == '0') {
|
||||
$db->query("UPDATE `".TABLE_PANEL_CUSTOMERS."` SET `theme`='".$db->escape($newfieldvalue)."'");
|
||||
}
|
||||
if (getSetting('panel', 'allow_theme_change_admin') == '0') {
|
||||
$db->query("UPDATE `".TABLE_PANEL_ADMINS."` SET `theme`='".$db->escape($newfieldvalue)."'");
|
||||
}
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
Reference in New Issue
Block a user