diff --git a/actions/admin/settings/100.panel.php b/actions/admin/settings/100.panel.php index cd0a0eb3..9a8859d9 100644 --- a/actions/admin/settings/100.panel.php +++ b/actions/admin/settings/100.panel.php @@ -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'], diff --git a/lib/functions/settings/function.storeSettingDefaultTheme.php b/lib/functions/settings/function.storeSettingDefaultTheme.php new file mode 100644 index 00000000..a049edea --- /dev/null +++ b/lib/functions/settings/function.storeSettingDefaultTheme.php @@ -0,0 +1,56 @@ + + * @author Froxlor team (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; +}