- more work on settings for FroxlorClients (upcoming multiserver-mode)

This commit is contained in:
Michael Kaufmann (d00p) 2010-10-18 09:20:17 +00:00
parent cad3c02f08
commit 699f451234
4 changed files with 148 additions and 17 deletions

View File

@ -0,0 +1,108 @@
<?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 Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* @version $Id$
*/
return array(
'groups' => array(
'froxlorclient' => array(
'title' => $lng['admin']['froxlorclient'],
'fields' => array(
'froxlorclient_enabled' => array(
'label' => $lng['froxlorclient']['enabled'],
'settinggroup' => 'client',
'varname' => 'enabled',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => true
),
'froxlorclient_ipaddress' => array(
'label' => $lng['froxlorclient']['ipaddress'],
'settinggroup' => 'client',
'varname' => 'ipaddress',
'type' => 'string',
'default' => '',
/* 'plausibility_check_method' => 'validateIP', */
'save_method' => 'storeSettingField',
),
'froxlorclient_hostname' => array(
'label' => $lng['froxlorclient']['hostname'],
'settinggroup' => 'client',
'varname' => 'hostname',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField'
),
'froxlorclient_deploy_mode' => array(
'label' => $lng['froxlorclient']['deploy_mode'],
'settinggroup' => 'client',
'varname' => 'deploy_mode',
'type' => 'option',
'default' => 'pubkey',
'option_mode' => 'one',
'option_options' => array('pubkey' => 'PublicKey', 'plainpass' => 'Passphrase'),
'save_method' => 'storeSettingField',
),
'froxlorclient_ssh_port' => array(
'label' => $lng['froxlorclient']['ssh_port'],
'settinggroup' => 'client',
'varname' => 'ssh_port',
'type' => 'int',
'int_min' => 1,
'int_max' => 65535,
'default' => 22,
'save_method' => 'storeSettingField',
),
'froxlorclient_ssh_user' => array(
'label' => $lng['froxlorclient']['ssh_user'],
'settinggroup' => 'client',
'varname' => 'ssh_user',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField'
),
'froxlorclient_ssh_passphrase' => array(
'label' => $lng['froxlorclient']['ssh_passphrase'],
'settinggroup' => 'client',
'varname' => 'ssh_passphrase',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField'
),
'froxlorclient_ssh_pubkey' => array(
'label' => $lng['froxlorclient']['ssh_pubkey'],
'settinggroup' => 'client',
'varname' => 'ssh_pubkey',
'type' => 'string',
'string_type' => 'file',
'default' => '',
'string_emptyallowed' => true,
'save_method' => 'storeSettingField'
),
'froxlorclient_ssh_privkey' => array(
'label' => $lng['froxlorclient']['ssh_privkey'],
'settinggroup' => 'client',
'varname' => 'ssh_privkey',
'type' => 'string',
'string_type' => 'file',
'default' => '',
'string_emptyallowed' => true,
'save_method' => 'storeSettingField'
)
)
)
)
);

View File

@ -2,7 +2,6 @@
/**
* 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
@ -323,11 +322,19 @@ class froxlorclient
if(isset($this->cid)
&& $this->cid != - 1
) {
$_settings = $this->db->query("SELECT * FROM `".TABLE_PANEL_SETTINGS."` WHERE `sid` = '".(int)$this->cid."'");
$spath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
$settings_data = loadConfigArrayDir(
makeCorrectDir($spath.'/actions/admin/settings/'),
makeCorrectDir($spath.'/actions/multiserver/clientsettings/')
);
$settings = loadSettings($settings_data, $db, $this->cid);
while($_s = mysql_fetch_array($_settings))
foreach($settings as $group => $fv)
{
$this->_setSetting($_s['settinggroup'], $_s['varname'], $_s['value'], true, true, true);
foreach($fv as $field => $value)
{
$this->_setSetting($group, $field, $value, true, true, true);
}
}
}
}

View File

@ -17,25 +17,44 @@
* @version $Id$
*/
function loadConfigArrayDir($data_dirname)
function loadConfigArrayDir()
{
// Workaround until we use gettext
global $lng;
// we now use dynamic function parameters
// so we can read from more than one directory
// and still be valid for old calls
$numargs = func_num_args();
if($numargs <= 0) { return null; }
$configdirs = array();
for($x=0;$x<$numargs;$x++) {
$configdirs[] = func_get_arg($x);
}
$data = array();
$data_files = array();
$has_data = false;
if(is_dir($data_dirname))
foreach($configdirs as $data_dirname)
{
$data_files = array();
$data_dirhandle = opendir($data_dirname);
while(false !== ($data_filename = readdir($data_dirhandle)))
if(is_dir($data_dirname))
{
if($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, -4 ) == '.php')
$data_dirhandle = opendir($data_dirname);
while(false !== ($data_filename = readdir($data_dirhandle)))
{
$data_files[] = $data_dirname . $data_filename;
if($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, -4 ) == '.php')
{
$data_files[] = $data_dirname . $data_filename;
}
}
$has_data = true;
}
}
if($has_data)
{
sort($data_files);
foreach($data_files as $data_filename)

View File

@ -17,13 +17,10 @@
* @version $Id$
*/
function loadSettings(&$settings_data, $db)
function loadSettings(&$settings_data, $db, $server_id = 0)
{
global $version;
// multi-server-support, get the destination server id (master = 0)
$server_id = getServerId();
$settings = array();
if(is_array($settings_data) && isset($settings_data['groups']) && is_array($settings_data['groups']))