From 352749c7986b91a650a61f57bb2d428de3e37a1a Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 15 Dec 2013 15:21:30 +0100 Subject: [PATCH] cant stop migrating to new Settings class, refs #1325 Signed-off-by: Michael Kaufmann (d00p) --- lib/classes/settings/class.Settings.php | 2 ++ .../settings/function.getSetting.php | 33 ------------------- .../settings/function.loadSettings.php | 7 ++++ .../settings/function.saveSetting.php | 28 ---------------- .../function.storeSettingDefaultIp.php | 2 +- .../function.storeSettingDefaultTheme.php | 4 +-- .../settings/function.storeSettingField.php | 4 +-- .../function.storeSettingHostname.php | 4 +-- .../function.storeSettingIpAddress.php | 21 +++++++----- lib/navigation/00.froxlor.main.php | 24 +++++++------- lib/navigation/10.tickets.php | 6 ++-- 11 files changed, 43 insertions(+), 92 deletions(-) delete mode 100644 lib/functions/settings/function.getSetting.php delete mode 100644 lib/functions/settings/function.saveSetting.php diff --git a/lib/classes/settings/class.Settings.php b/lib/classes/settings/class.Settings.php index 1d421506..23ac0e6a 100644 --- a/lib/classes/settings/class.Settings.php +++ b/lib/classes/settings/class.Settings.php @@ -140,7 +140,9 @@ class Settings { } self::$_data[$sstr[0]][$sstr[1]] = $value; } + return true; } + return false; } /** diff --git a/lib/functions/settings/function.getSetting.php b/lib/functions/settings/function.getSetting.php deleted file mode 100644 index ac20878e..00000000 --- a/lib/functions/settings/function.getSetting.php +++ /dev/null @@ -1,33 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -function getSetting($settinggroup, $varname) -{ - global $settings, $theme; - if(isset($settings[$settinggroup]) && is_array($settings[$settinggroup]) && isset($settings[$settinggroup][$varname])) - { - return $settings[$settinggroup][$varname]; - } - else - { - return false; - } -} - -?> diff --git a/lib/functions/settings/function.loadSettings.php b/lib/functions/settings/function.loadSettings.php index 34668e7a..430897db 100644 --- a/lib/functions/settings/function.loadSettings.php +++ b/lib/functions/settings/function.loadSettings.php @@ -17,6 +17,13 @@ * */ +/** + * @FIXME remove when fully migrated to new Settings class + * + * @param array $settings_data + * + * @return array + */ function loadSettings(&$settings_data) { $settings = array(); diff --git a/lib/functions/settings/function.saveSetting.php b/lib/functions/settings/function.saveSetting.php deleted file mode 100644 index a04d6e32..00000000 --- a/lib/functions/settings/function.saveSetting.php +++ /dev/null @@ -1,28 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -function saveSetting($settinggroup, $varname, $newvalue) { - - $upd_stmt = Database::Prepare(" - UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = :newvalue - WHERE `settinggroup` = :group AND `varname` = :varname - "); - Database::pexecute($upd_stmt, array('newvalue' => $newvalue, 'group' => $settinggroup, 'varname' => $varname)); - return true; -} diff --git a/lib/functions/settings/function.storeSettingDefaultIp.php b/lib/functions/settings/function.storeSettingDefaultIp.php index 3851e696..01aa5c8a 100644 --- a/lib/functions/settings/function.storeSettingDefaultIp.php +++ b/lib/functions/settings/function.storeSettingDefaultIp.php @@ -46,7 +46,7 @@ function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) { WHERE `id_domain` IN ('" . implode(', ', $ids) . "') AND `id_ipandports` = :defaultip "); - Database::pexecute($upd_stmt, array('newval' => $newfieldvalue, 'defaultip' => getSetting('system', 'defaultip'))); + Database::pexecute($upd_stmt, array('newval' => $newfieldvalue, 'defaultip' => Settings::Get('system.defaultip'))); } } diff --git a/lib/functions/settings/function.storeSettingDefaultTheme.php b/lib/functions/settings/function.storeSettingDefaultTheme.php index 9f1f5248..5f44ae47 100644 --- a/lib/functions/settings/function.storeSettingDefaultTheme.php +++ b/lib/functions/settings/function.storeSettingDefaultTheme.php @@ -43,13 +43,13 @@ function storeSettingDefaultTheme($fieldname, $fielddata, $newfieldvalue) { ) { // 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') { + if (Settings::Get('panel.allow_theme_change_customer') == '0') { $upd_stmt = Database::prepare(" UPDATE `".TABLE_PANEL_CUSTOMERS."` SET `theme` = :theme "); Database::pexecute($upd_stmt, array('theme' => $newfieldvalue)); } - if (getSetting('panel', 'allow_theme_change_admin') == '0') { + if (Settings::Get('panel.allow_theme_change_admin') == '0') { $upd_stmt = Database::prepare(" UPDATE `".TABLE_PANEL_ADMINS."` SET `theme` = :theme "); diff --git a/lib/functions/settings/function.storeSettingField.php b/lib/functions/settings/function.storeSettingField.php index e3828043..aa5afed1 100644 --- a/lib/functions/settings/function.storeSettingField.php +++ b/lib/functions/settings/function.storeSettingField.php @@ -25,7 +25,7 @@ function storeSettingField($fieldname, $fielddata, $newfieldvalue) { && isset($fielddata['varname']) && $fielddata['varname'] != '' ) { - if (saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false) { + if (Settings::Set($fielddata['settinggroup'].'.'.$fielddata['varname'], $newfieldvalue) !== false) { /* * when fielddata[cronmodule] is set, this means enable/disable a cronjob */ @@ -63,7 +63,7 @@ function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue) && isset($fielddata['varname']) && $fielddata['varname'] != '' ) { - if (saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false) { + if (Settings::Set($fielddata['settinggroup'].'.'.$fielddata['varname'], $newfieldvalue) !== false) { return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue); } else { return false; diff --git a/lib/functions/settings/function.storeSettingHostname.php b/lib/functions/settings/function.storeSettingHostname.php index 5f0c52c2..0015ec6e 100644 --- a/lib/functions/settings/function.storeSettingHostname.php +++ b/lib/functions/settings/function.storeSettingHostname.php @@ -31,7 +31,7 @@ function storeSettingHostname($fieldname, $fielddata, $newfieldvalue) { && $fielddata['varname'] == 'hostname' ) { $newfieldvalue = $idna_convert->encode($newfieldvalue); - + $customerstddomains_result_stmt = Database::prepare(" SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0' "); @@ -49,7 +49,7 @@ function storeSettingHostname($fieldname, $fielddata, $newfieldvalue) { `domain` = REPLACE(`domain`, :host, :newval) WHERE `id` IN ('" . implode(', ', $ids) . "') "); - Database::pexecute($upd_stmt, array('host' => getSetting('system', 'hostname'), 'newval' => $newfieldvalue)); + Database::pexecute($upd_stmt, array('host' => Settings::Get('system.hostname'), 'newval' => $newfieldvalue)); } } diff --git a/lib/functions/settings/function.storeSettingIpAddress.php b/lib/functions/settings/function.storeSettingIpAddress.php index acd20f3c..f3383e58 100644 --- a/lib/functions/settings/function.storeSettingIpAddress.php +++ b/lib/functions/settings/function.storeSettingIpAddress.php @@ -17,21 +17,24 @@ * */ -function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue) -{ +function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue) { + $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue); - if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'ipaddress') - { - $mysql_access_host_array = array_map('trim', explode(',', getSetting('system', 'mysql_access_host'))); + if ($returnvalue !== false + && is_array($fielddata) + && isset($fielddata['settinggroup']) + && $fielddata['settinggroup'] == 'system' + && isset($fielddata['varname']) + && $fielddata['varname'] == 'ipaddress' + ) { + $mysql_access_host_array = array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))); $mysql_access_host_array[] = $newfieldvalue; $mysql_access_host_array = array_unique(array_trim($mysql_access_host_array)); $mysql_access_host = implode(',', $mysql_access_host_array); correctMysqlUsers($mysql_access_host_array); - saveSetting('system', 'mysql_access_host', $mysql_access_host); + Settings::Set('system.mysql_access_host', $mysql_access_host); } - + return $returnvalue; } - -?> diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php index ce6eaefd..b27e83d9 100644 --- a/lib/navigation/00.froxlor.main.php +++ b/lib/navigation/00.froxlor.main.php @@ -37,7 +37,7 @@ return array ( array ( 'url' => 'customer_index.php?page=change_theme', 'label' => $lng['menue']['main']['changetheme'], - 'show_element' => (getSetting('panel', 'allow_theme_change_customer') == true) + 'show_element' => (Settings::Get('panel.allow_theme_change_customer') == true) ), array ( 'url' => 'customer_index.php?action=logout', @@ -60,11 +60,11 @@ return array ( 'required_resources' => 'emails' ), array ( - 'url' => getSetting('panel', 'webmail_url'), + 'url' => Setting::Get('panel.webmail_url'), 'new_window' => true, 'label' => $lng['menue']['email']['webmail'], 'required_resources' => 'emails_used', - 'show_element' => ( getSetting('panel', 'webmail_url') != '' ), + 'show_element' => ( Settings::Get('panel.webmail_url') != '' ), ), ), ), @@ -78,11 +78,11 @@ return array ( 'required_resources' => 'mysqls', ), array ( - 'url' => getSetting('panel', 'phpmyadmin_url'), + 'url' => Settings::Get('panel.phpmyadmin_url'), 'new_window' => true, 'label' => $lng['menue']['mysql']['phpmyadmin'], 'required_resources' => 'mysqls_used', - 'show_element' => ( getSetting('panel', 'phpmyadmin_url') != '' ), + 'show_element' => ( Settings::Get('panel.phpmyadmin_url') != '' ), ), ), ), @@ -105,10 +105,10 @@ return array ( 'label' => $lng['menue']['ftp']['accounts'], ), array ( - 'url' => getSetting('panel', 'webftp_url'), + 'url' => Settings::Get('panel.webftp_url'), 'new_window' => true, 'label' => $lng['menue']['ftp']['webftp'], - 'show_element' => ( getSetting('panel', 'webftp_url') != '' ), + 'show_element' => ( Settings::Get('panel.webftp_url') != '' ), ), ), ), @@ -156,7 +156,7 @@ return array ( array ( 'url' => 'admin_index.php?page=change_theme', 'label' => $lng['menue']['main']['changetheme'], - 'show_element' => (getSetting('panel', 'allow_theme_change_admin') == true) + 'show_element' => (Setting::Get('panel.allow_theme_change_admin') == true) ), array ( 'url' => 'admin_index.php?action=logout', @@ -238,9 +238,9 @@ return array ( array ( 'url' => 'admin_phpsettings.php?page=overview', 'label' => $lng['menue']['phpsettings']['maintitle'], - 'show_element' => ( - getSetting('system', 'mod_fcgid') == true || - getSetting('phpfpm', 'enabled') == true + 'show_element' => ( + Settings::Get('system.mod_fcgid') == true || + Settings::Get('phpfpm.enabled') == true ), ), ), @@ -256,7 +256,7 @@ return array ( 'url' => 'admin_logger.php?page=log', 'label' => $lng['menue']['logger']['logger'], 'required_resources' => 'change_serversettings', - 'show_element' => ( getSetting('logger', 'enabled') == true ), + 'show_element' => ( Settings::Get('logger.enabled') == true ), ), array ( 'url' => 'admin_message.php?page=message', diff --git a/lib/navigation/10.tickets.php b/lib/navigation/10.tickets.php index 3b99dc14..fe3877c9 100644 --- a/lib/navigation/10.tickets.php +++ b/lib/navigation/10.tickets.php @@ -22,7 +22,7 @@ return array ( 'tickets' => array ( 'url' => 'customer_tickets.php', 'label' => $lng['menue']['ticket']['ticket'], - 'show_element' => ( getSetting('ticket', 'enabled') == true ), + 'show_element' => ( Settings::Get('ticket.enabled') == true ), 'elements' => array ( array ( 'url' => 'customer_tickets.php?page=tickets', @@ -34,7 +34,7 @@ return array ( 'admin' => array ( 'tickets' => array ( 'label' => $lng['admin']['ticketsystem'], - 'show_element' => ( getSetting('ticket', 'enabled') == true ), + 'show_element' => ( Settings::Get('ticket.enabled') == true ), 'elements' => array ( array ( 'url' => 'admin_tickets.php?page=tickets', @@ -52,4 +52,4 @@ return array ( ), ), ); -?> \ No newline at end of file +?>