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

@@ -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) {
$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) . "')
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
// 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
");

View File

@@ -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;

View File

@@ -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));
}
}

View File

@@ -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;
}
?>