cant stop migrating to new Settings class, refs #1325

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-12-15 15:21:30 +01:00
parent 7f565c305c
commit 352749c798
11 changed files with 43 additions and 92 deletions

View File

@@ -140,7 +140,9 @@ class Settings {
} }
self::$_data[$sstr[0]][$sstr[1]] = $value; self::$_data[$sstr[0]][$sstr[1]] = $value;
} }
return true;
} }
return false;
} }
/** /**

View File

@@ -1,33 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}
}
?>

View File

@@ -17,6 +17,13 @@
* *
*/ */
/**
* @FIXME remove when fully migrated to new Settings class
*
* @param array $settings_data
*
* @return array
*/
function loadSettings(&$settings_data) { function loadSettings(&$settings_data) {
$settings = array(); $settings = array();

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -46,7 +46,7 @@ function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
WHERE `id_domain` IN ('" . implode(', ', $ids) . "') WHERE `id_domain` IN ('" . implode(', ', $ids) . "')
AND `id_ipandports` = :defaultip 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')));
} }
} }

View File

@@ -43,13 +43,13 @@ function storeSettingDefaultTheme($fieldname, $fielddata, $newfieldvalue) {
) { ) {
// now, if changing themes is disabled we recursivly set // now, if changing themes is disabled we recursivly set
// the new theme (customers and admin, depending on settings) // 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(" $upd_stmt = Database::prepare("
UPDATE `".TABLE_PANEL_CUSTOMERS."` SET `theme` = :theme UPDATE `".TABLE_PANEL_CUSTOMERS."` SET `theme` = :theme
"); ");
Database::pexecute($upd_stmt, array('theme' => $newfieldvalue)); 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(" $upd_stmt = Database::prepare("
UPDATE `".TABLE_PANEL_ADMINS."` SET `theme` = :theme UPDATE `".TABLE_PANEL_ADMINS."` SET `theme` = :theme
"); ");

View File

@@ -25,7 +25,7 @@ function storeSettingField($fieldname, $fielddata, $newfieldvalue) {
&& isset($fielddata['varname']) && isset($fielddata['varname'])
&& $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 * when fielddata[cronmodule] is set, this means enable/disable a cronjob
*/ */
@@ -63,7 +63,7 @@ function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue)
&& isset($fielddata['varname']) && isset($fielddata['varname'])
&& $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); return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
} else { } else {
return false; return false;

View File

@@ -49,7 +49,7 @@ function storeSettingHostname($fieldname, $fielddata, $newfieldvalue) {
`domain` = REPLACE(`domain`, :host, :newval) `domain` = REPLACE(`domain`, :host, :newval)
WHERE `id` IN ('" . implode(', ', $ids) . "') 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));
} }
} }

View File

@@ -17,21 +17,24 @@
* *
*/ */
function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue) function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue) {
{
$returnvalue = storeSettingField($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') if ($returnvalue !== false
{ && is_array($fielddata)
$mysql_access_host_array = array_map('trim', explode(',', getSetting('system', 'mysql_access_host'))); && 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[] = $newfieldvalue;
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array)); $mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
$mysql_access_host = implode(',', $mysql_access_host_array); $mysql_access_host = implode(',', $mysql_access_host_array);
correctMysqlUsers($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; return $returnvalue;
} }
?>

View File

@@ -37,7 +37,7 @@ return array (
array ( array (
'url' => 'customer_index.php?page=change_theme', 'url' => 'customer_index.php?page=change_theme',
'label' => $lng['menue']['main']['changetheme'], '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 ( array (
'url' => 'customer_index.php?action=logout', 'url' => 'customer_index.php?action=logout',
@@ -60,11 +60,11 @@ return array (
'required_resources' => 'emails' 'required_resources' => 'emails'
), ),
array ( array (
'url' => getSetting('panel', 'webmail_url'), 'url' => Setting::Get('panel.webmail_url'),
'new_window' => true, 'new_window' => true,
'label' => $lng['menue']['email']['webmail'], 'label' => $lng['menue']['email']['webmail'],
'required_resources' => 'emails_used', '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', 'required_resources' => 'mysqls',
), ),
array ( array (
'url' => getSetting('panel', 'phpmyadmin_url'), 'url' => Settings::Get('panel.phpmyadmin_url'),
'new_window' => true, 'new_window' => true,
'label' => $lng['menue']['mysql']['phpmyadmin'], 'label' => $lng['menue']['mysql']['phpmyadmin'],
'required_resources' => 'mysqls_used', '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'], 'label' => $lng['menue']['ftp']['accounts'],
), ),
array ( array (
'url' => getSetting('panel', 'webftp_url'), 'url' => Settings::Get('panel.webftp_url'),
'new_window' => true, 'new_window' => true,
'label' => $lng['menue']['ftp']['webftp'], '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 ( array (
'url' => 'admin_index.php?page=change_theme', 'url' => 'admin_index.php?page=change_theme',
'label' => $lng['menue']['main']['changetheme'], '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 ( array (
'url' => 'admin_index.php?action=logout', 'url' => 'admin_index.php?action=logout',
@@ -239,8 +239,8 @@ return array (
'url' => 'admin_phpsettings.php?page=overview', 'url' => 'admin_phpsettings.php?page=overview',
'label' => $lng['menue']['phpsettings']['maintitle'], 'label' => $lng['menue']['phpsettings']['maintitle'],
'show_element' => ( 'show_element' => (
getSetting('system', 'mod_fcgid') == true || Settings::Get('system.mod_fcgid') == true ||
getSetting('phpfpm', 'enabled') == true Settings::Get('phpfpm.enabled') == true
), ),
), ),
), ),
@@ -256,7 +256,7 @@ return array (
'url' => 'admin_logger.php?page=log', 'url' => 'admin_logger.php?page=log',
'label' => $lng['menue']['logger']['logger'], 'label' => $lng['menue']['logger']['logger'],
'required_resources' => 'change_serversettings', 'required_resources' => 'change_serversettings',
'show_element' => ( getSetting('logger', 'enabled') == true ), 'show_element' => ( Settings::Get('logger.enabled') == true ),
), ),
array ( array (
'url' => 'admin_message.php?page=message', 'url' => 'admin_message.php?page=message',

View File

@@ -22,7 +22,7 @@ return array (
'tickets' => array ( 'tickets' => array (
'url' => 'customer_tickets.php', 'url' => 'customer_tickets.php',
'label' => $lng['menue']['ticket']['ticket'], 'label' => $lng['menue']['ticket']['ticket'],
'show_element' => ( getSetting('ticket', 'enabled') == true ), 'show_element' => ( Settings::Get('ticket.enabled') == true ),
'elements' => array ( 'elements' => array (
array ( array (
'url' => 'customer_tickets.php?page=tickets', 'url' => 'customer_tickets.php?page=tickets',
@@ -34,7 +34,7 @@ return array (
'admin' => array ( 'admin' => array (
'tickets' => array ( 'tickets' => array (
'label' => $lng['admin']['ticketsystem'], 'label' => $lng['admin']['ticketsystem'],
'show_element' => ( getSetting('ticket', 'enabled') == true ), 'show_element' => ( Settings::Get('ticket.enabled') == true ),
'elements' => array ( 'elements' => array (
array ( array (
'url' => 'admin_tickets.php?page=tickets', 'url' => 'admin_tickets.php?page=tickets',