From fc5aea1c3334168efc584ead68e2e53f3ac3bf43 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Tue, 19 Oct 2010 16:07:48 +0000 Subject: [PATCH] - implement multiserver-client edit - fix various undefined variables --- .../clientsettings/999.froxlorclient.php | 9 ---- admin_clients.php | 41 +++++++++++++---- .../froxlorclient/class.froxlorclient.php | 21 +++------ lib/functions/output/function.makeyesno.php | 2 + lng/english.lng.php | 10 +++++ .../froxlorclients/froxlorclients_add.tpl | 4 ++ .../froxlorclients/froxlorclients_edit.tpl | 45 +++++++++++++++++++ 7 files changed, 100 insertions(+), 32 deletions(-) create mode 100644 templates/admin/froxlorclients/froxlorclients_edit.tpl diff --git a/actions/multiserver/clientsettings/999.froxlorclient.php b/actions/multiserver/clientsettings/999.froxlorclient.php index 424376fa..a196a768 100644 --- a/actions/multiserver/clientsettings/999.froxlorclient.php +++ b/actions/multiserver/clientsettings/999.froxlorclient.php @@ -20,15 +20,6 @@ return 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', diff --git a/admin_clients.php b/admin_clients.php index 6726c252..ee91d58a 100644 --- a/admin_clients.php +++ b/admin_clients.php @@ -48,7 +48,7 @@ if((int)$settings['multiserver']['enabled'] == 1) 'enabled' => $lng['admin']['froxlorclients']['enabled'] ); $paging = new paging($userinfo, $db, TABLE_FROXLOR_CLIENTS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']); - $ipsandports = ''; + $froxlorclients = ''; $result = $db->query("SELECT * FROM `" . TABLE_FROXLOR_CLIENTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); $paging->setEntries($db->num_rows($result)); $sortcode = $paging->getHtmlSortCode($lng); @@ -57,7 +57,7 @@ if((int)$settings['multiserver']['enabled'] == 1) $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $i = 0; $count = 0; - + while($row = $db->fetch_array($result)) { if($paging->checkDisplay($i)) @@ -78,7 +78,7 @@ if((int)$settings['multiserver']['enabled'] == 1) elseif($action == 'delete' && $id != 0) { - $client = froxlorclient::getInstance($userinfo, $db, $settings, $id); + $client = froxlorclient::getInstance($userinfo, $db, $id); if(isset($_POST['send']) && $_POST['send'] == 'send') @@ -99,7 +99,7 @@ if((int)$settings['multiserver']['enabled'] == 1) { $name = validate($_POST['name'], 'name'); $desc = validate($_POST['desc'], 'desc'); - $client_enabled = intval($_POST['vhostcontainer']); + $client_enabled = intval($_POST['enabled']); if($name == '') { @@ -115,7 +115,7 @@ if((int)$settings['multiserver']['enabled'] == 1) $client_enabled = 0; } - $new_client = froxlorclient::getInstance($userinfo, $db, $settings, -1); + $new_client = froxlorclient::getInstance($userinfo, $db, -1); $new_client->Set('name', $name, true, false); $new_client->Set('desc', $desc, true, false); $new_client->Set('enabled', $client_enabled, true, true); @@ -136,16 +136,41 @@ if((int)$settings['multiserver']['enabled'] == 1) elseif($action == 'edit' && $id != 0 ) { - $client = froxlorclient::getInstance($userinfo, $db, $settings, $id); + $client = froxlorclient::getInstance($userinfo, $db, $id); if(isset($_POST['send']) && $_POST['send'] == 'send') { + $name = validate($_POST['name'], 'name'); + $desc = validate($_POST['desc'], 'desc'); + $client_enabled = intval($_POST['enabled']); + if($name == '') + { + standard_error(array('stringisempty', 'name')); + } + + if($desc == '') + { + standard_error(array('stringisempty', 'desc')); + } + + if($client_enabled != 1) { + $client_enabled = 0; + } + + $client->Set('name', $name, true, false); + $client->Set('desc', $desc, true, false); + $client->Set('enabled', $client_enabled, true, true); + $client->Update(); + + $log->logAction(ADM_ACTION, LOG_WARNING, "updated froxlor-client '" . $name . "' (#" . $id . ")"); + redirectTo($filename, Array('page' => $page, 's' => $s)); } else { - + $client_enabled = makeyesno('enabled', '1', '0', $client->Get('enabled')); + eval("echo \"" . getTemplate("froxlorclients/froxlorclients_edit") . "\";"); } } /** @@ -154,7 +179,7 @@ if((int)$settings['multiserver']['enabled'] == 1) elseif($action == 'settings' && $id != 0 ) { - $client = froxlorclient::getInstance($userinfo, $db, $settings, $id); + $client = froxlorclient::getInstance($userinfo, $db, $id); $settings_data = $client->getSettingsData(); $settings = $client->getSettingsArray(); diff --git a/lib/classes/froxlorclient/class.froxlorclient.php b/lib/classes/froxlorclient/class.froxlorclient.php index dad9b39e..7db3f373 100644 --- a/lib/classes/froxlorclient/class.froxlorclient.php +++ b/lib/classes/froxlorclient/class.froxlorclient.php @@ -34,12 +34,6 @@ class froxlorclient */ private $db = false; - /** - * Settings array - * @var settings - */ - private $settings = array(); - /** * Client ID * @var cid @@ -69,14 +63,12 @@ class froxlorclient * * @param array $userinfo userdetails array of logged in user * @param resource $db database-object - * @param array $settings settings-array * @param int $cid client-id */ - private function __construct($userinfo, $db, $settings, $cid = -1) + private function __construct($userinfo, $db, $cid = -1) { $this->userinfo = $userinfo; $this->db = $db; - $this->settings = $settings; $this->cid = $cid; // read data from database @@ -89,14 +81,13 @@ class froxlorclient * * @param array $_usernfo userdetails array of logged in user * @param resource $_db database-object - * @param array $_settings settings-array * @param int $_cid client-id */ - static public function getInstance($_usernfo, $_db, $_settings, $_cid) + static public function getInstance($_usernfo, $_db, $_cid) { if(!isset(self::$clients[$_cid])) { - self::$clients[$_cid] = new froxlorclient($_usernfo, $_db, $_settings, $_cid); + self::$clients[$_cid] = new froxlorclient($_usernfo, $_db, $_cid); } return self::$clients[$_cid]; @@ -376,11 +367,11 @@ class froxlorclient $_value = htmlspecialchars($_value); } - if(!is_array($this->c_data['settings'])) { + if(!isset($this->c_data['settings']) || !is_array($this->c_data['settings'])) { $this->c_data['settings'] = array(); } - if(!is_array($this->c_data['settings'][$_grp])) { + if(!isset($this->c_data['settings'][$_grp]) || !is_array($this->c_data['settings'][$_grp])) { $this->c_data['settings'][$_grp] = array(); } @@ -401,7 +392,7 @@ class froxlorclient makeCorrectDir($spath.'/actions/admin/settings/'), makeCorrectDir($spath.'/actions/multiserver/clientsettings/') ); - $settings = loadSettings($this->s_data, $db, $this->cid); + $settings = loadSettings($this->s_data, $this->db, $this->cid); foreach($settings as $group => $fv) { diff --git a/lib/functions/output/function.makeyesno.php b/lib/functions/output/function.makeyesno.php index 614ab7be..6b29584b 100644 --- a/lib/functions/output/function.makeyesno.php +++ b/lib/functions/output/function.makeyesno.php @@ -36,6 +36,8 @@ function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled if($disabled) { $d = ' disabled="disabled"'; + } else { + $d = ''; } return ''; } diff --git a/lng/english.lng.php b/lng/english.lng.php index 1f4a40a9..186c9373 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1519,6 +1519,7 @@ $lng['multiserver']['enabled']['description'] = '@TODO'; // ADDED IN FROXLOR 0.9.14-svn9 $lng['mysql']['database_edit'] = 'Edit database'; $lng['admin']['froxlorclients']['add'] = 'Create new Froxlor-client'; +$lng['admin']['froxlorclients']['edit'] = 'Edit Froxlor-client'; $lng['admin']['froxlorclients']['longdesc_add'] = '@TODO a long description on how the multiserver-client thing works'; $lng['admin']['froxlorclients']['client'] = 'Froxlor client'; $lng['admin']['froxlorclients']['name'] = 'Client name'; @@ -1526,5 +1527,14 @@ $lng['admin']['froxlorclients']['desc'] = 'Client description'; $lng['admin']['froxlorclients']['enabled'] = 'Client enabled?'; $lng['admin']['froxlorclients']['settings'] = 'settings'; $lng['menue']['multiserver']['clients'] = 'Multiserver clients'; +$lng['admin']['froxlorclient'] = 'Multiserver client settings'; +$lng['froxlorclient']['ipaddress'] = 'Client IP'; +$lng['froxlorclient']['hostname'] = 'Client hostname'; +$lng['froxlorclient']['deploy_mode'] = 'Deploy mode'; +$lng['froxlorclient']['ssh_port'] = 'SSH port'; +$lng['froxlorclient']['ssh_user'] = 'SSH user'; +$lng['froxlorclient']['ssh_passphrase'] = 'SSH passphrase'; +$lng['froxlorclient']['ssh_pubkey'] = 'SSH public key'; +$lng['froxlorclient']['ssh_privkey'] = 'SSH private key'; ?> diff --git a/templates/admin/froxlorclients/froxlorclients_add.tpl b/templates/admin/froxlorclients/froxlorclients_add.tpl index 048398d1..55584783 100644 --- a/templates/admin/froxlorclients/froxlorclients_add.tpl +++ b/templates/admin/froxlorclients/froxlorclients_add.tpl @@ -29,6 +29,10 @@ $header {$lng['admin']['froxlorclients']['desc']}: + + {$lng['admin']['froxlorclients']['enabled']}: + $client_enabled + diff --git a/templates/admin/froxlorclients/froxlorclients_edit.tpl b/templates/admin/froxlorclients/froxlorclients_edit.tpl new file mode 100644 index 00000000..9c3ebbfc --- /dev/null +++ b/templates/admin/froxlorclients/froxlorclients_edit.tpl @@ -0,0 +1,45 @@ +$header +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 {$lng['admin']['froxlorclients']['edit']}
+ + {$lng['admin']['froxlorclients']['longdesc_add']} +
+  {$lng['admin']['froxlorclients']['client']} + + +
{$lng['admin']['froxlorclients']['name']}:
{$lng['admin']['froxlorclients']['desc']}:
{$lng['admin']['froxlorclients']['enabled']}:$client_enabled
+
+
+
+$footer