- implement multiserver-client edit
- fix various undefined variables
This commit is contained in:
@@ -20,15 +20,6 @@ return array(
|
|||||||
'froxlorclient' => array(
|
'froxlorclient' => array(
|
||||||
'title' => $lng['admin']['froxlorclient'],
|
'title' => $lng['admin']['froxlorclient'],
|
||||||
'fields' => array(
|
'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(
|
'froxlorclient_ipaddress' => array(
|
||||||
'label' => $lng['froxlorclient']['ipaddress'],
|
'label' => $lng['froxlorclient']['ipaddress'],
|
||||||
'settinggroup' => 'client',
|
'settinggroup' => 'client',
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ if((int)$settings['multiserver']['enabled'] == 1)
|
|||||||
'enabled' => $lng['admin']['froxlorclients']['enabled']
|
'enabled' => $lng['admin']['froxlorclients']['enabled']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_FROXLOR_CLIENTS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$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());
|
$result = $db->query("SELECT * FROM `" . TABLE_FROXLOR_CLIENTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||||
$paging->setEntries($db->num_rows($result));
|
$paging->setEntries($db->num_rows($result));
|
||||||
$sortcode = $paging->getHtmlSortCode($lng);
|
$sortcode = $paging->getHtmlSortCode($lng);
|
||||||
@@ -57,7 +57,7 @@ if((int)$settings['multiserver']['enabled'] == 1)
|
|||||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
while($row = $db->fetch_array($result))
|
while($row = $db->fetch_array($result))
|
||||||
{
|
{
|
||||||
if($paging->checkDisplay($i))
|
if($paging->checkDisplay($i))
|
||||||
@@ -78,7 +78,7 @@ if((int)$settings['multiserver']['enabled'] == 1)
|
|||||||
elseif($action == 'delete'
|
elseif($action == 'delete'
|
||||||
&& $id != 0)
|
&& $id != 0)
|
||||||
{
|
{
|
||||||
$client = froxlorclient::getInstance($userinfo, $db, $settings, $id);
|
$client = froxlorclient::getInstance($userinfo, $db, $id);
|
||||||
|
|
||||||
if(isset($_POST['send'])
|
if(isset($_POST['send'])
|
||||||
&& $_POST['send'] == 'send')
|
&& $_POST['send'] == 'send')
|
||||||
@@ -99,7 +99,7 @@ if((int)$settings['multiserver']['enabled'] == 1)
|
|||||||
{
|
{
|
||||||
$name = validate($_POST['name'], 'name');
|
$name = validate($_POST['name'], 'name');
|
||||||
$desc = validate($_POST['desc'], 'desc');
|
$desc = validate($_POST['desc'], 'desc');
|
||||||
$client_enabled = intval($_POST['vhostcontainer']);
|
$client_enabled = intval($_POST['enabled']);
|
||||||
|
|
||||||
if($name == '')
|
if($name == '')
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ if((int)$settings['multiserver']['enabled'] == 1)
|
|||||||
$client_enabled = 0;
|
$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('name', $name, true, false);
|
||||||
$new_client->Set('desc', $desc, true, false);
|
$new_client->Set('desc', $desc, true, false);
|
||||||
$new_client->Set('enabled', $client_enabled, true, true);
|
$new_client->Set('enabled', $client_enabled, true, true);
|
||||||
@@ -136,16 +136,41 @@ if((int)$settings['multiserver']['enabled'] == 1)
|
|||||||
elseif($action == 'edit'
|
elseif($action == 'edit'
|
||||||
&& $id != 0
|
&& $id != 0
|
||||||
) {
|
) {
|
||||||
$client = froxlorclient::getInstance($userinfo, $db, $settings, $id);
|
$client = froxlorclient::getInstance($userinfo, $db, $id);
|
||||||
|
|
||||||
if(isset($_POST['send'])
|
if(isset($_POST['send'])
|
||||||
&& $_POST['send'] == '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
|
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'
|
elseif($action == 'settings'
|
||||||
&& $id != 0
|
&& $id != 0
|
||||||
) {
|
) {
|
||||||
$client = froxlorclient::getInstance($userinfo, $db, $settings, $id);
|
$client = froxlorclient::getInstance($userinfo, $db, $id);
|
||||||
|
|
||||||
$settings_data = $client->getSettingsData();
|
$settings_data = $client->getSettingsData();
|
||||||
$settings = $client->getSettingsArray();
|
$settings = $client->getSettingsArray();
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ class froxlorclient
|
|||||||
*/
|
*/
|
||||||
private $db = false;
|
private $db = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings array
|
|
||||||
* @var settings
|
|
||||||
*/
|
|
||||||
private $settings = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client ID
|
* Client ID
|
||||||
* @var cid
|
* @var cid
|
||||||
@@ -69,14 +63,12 @@ class froxlorclient
|
|||||||
*
|
*
|
||||||
* @param array $userinfo userdetails array of logged in user
|
* @param array $userinfo userdetails array of logged in user
|
||||||
* @param resource $db database-object
|
* @param resource $db database-object
|
||||||
* @param array $settings settings-array
|
|
||||||
* @param int $cid client-id
|
* @param int $cid client-id
|
||||||
*/
|
*/
|
||||||
private function __construct($userinfo, $db, $settings, $cid = -1)
|
private function __construct($userinfo, $db, $cid = -1)
|
||||||
{
|
{
|
||||||
$this->userinfo = $userinfo;
|
$this->userinfo = $userinfo;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->settings = $settings;
|
|
||||||
$this->cid = $cid;
|
$this->cid = $cid;
|
||||||
|
|
||||||
// read data from database
|
// read data from database
|
||||||
@@ -89,14 +81,13 @@ class froxlorclient
|
|||||||
*
|
*
|
||||||
* @param array $_usernfo userdetails array of logged in user
|
* @param array $_usernfo userdetails array of logged in user
|
||||||
* @param resource $_db database-object
|
* @param resource $_db database-object
|
||||||
* @param array $_settings settings-array
|
|
||||||
* @param int $_cid client-id
|
* @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]))
|
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];
|
return self::$clients[$_cid];
|
||||||
@@ -376,11 +367,11 @@ class froxlorclient
|
|||||||
$_value = htmlspecialchars($_value);
|
$_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();
|
$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();
|
$this->c_data['settings'][$_grp] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +392,7 @@ class froxlorclient
|
|||||||
makeCorrectDir($spath.'/actions/admin/settings/'),
|
makeCorrectDir($spath.'/actions/admin/settings/'),
|
||||||
makeCorrectDir($spath.'/actions/multiserver/clientsettings/')
|
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)
|
foreach($settings as $group => $fv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled
|
|||||||
|
|
||||||
if($disabled) {
|
if($disabled) {
|
||||||
$d = ' disabled="disabled"';
|
$d = ' disabled="disabled"';
|
||||||
|
} else {
|
||||||
|
$d = '';
|
||||||
}
|
}
|
||||||
return '<select class="dropdown_noborder" name="' . $name . '"'.$d.'><option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
|
return '<select class="dropdown_noborder" name="' . $name . '"'.$d.'><option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1519,6 +1519,7 @@ $lng['multiserver']['enabled']['description'] = '@TODO';
|
|||||||
// ADDED IN FROXLOR 0.9.14-svn9
|
// ADDED IN FROXLOR 0.9.14-svn9
|
||||||
$lng['mysql']['database_edit'] = 'Edit database';
|
$lng['mysql']['database_edit'] = 'Edit database';
|
||||||
$lng['admin']['froxlorclients']['add'] = 'Create new Froxlor-client';
|
$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']['longdesc_add'] = '@TODO a long description on how the multiserver-client thing works';
|
||||||
$lng['admin']['froxlorclients']['client'] = 'Froxlor client';
|
$lng['admin']['froxlorclients']['client'] = 'Froxlor client';
|
||||||
$lng['admin']['froxlorclients']['name'] = 'Client name';
|
$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']['enabled'] = 'Client enabled?';
|
||||||
$lng['admin']['froxlorclients']['settings'] = 'settings';
|
$lng['admin']['froxlorclients']['settings'] = 'settings';
|
||||||
$lng['menue']['multiserver']['clients'] = 'Multiserver clients';
|
$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';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ $header
|
|||||||
<td class="main_field_name" valign="top">{$lng['admin']['froxlorclients']['desc']}:</td>
|
<td class="main_field_name" valign="top">{$lng['admin']['froxlorclients']['desc']}:</td>
|
||||||
<td class="main_field_display" nowrap="nowrap"><textarea class="textarea_border" rows="12" cols="60" name="desc"></textarea></td>
|
<td class="main_field_display" nowrap="nowrap"><textarea class="textarea_border" rows="12" cols="60" name="desc"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="main_field_name" valign="top">{$lng['admin']['froxlorclients']['enabled']}:</td>
|
||||||
|
<td class="main_field_display" nowrap="nowrap">$client_enabled</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="main_field_confirm" colspan="2"><input type="hidden" name="send" value="send" /><input class="bottom" type="submit" value="{$lng['panel']['save']}" /></td>
|
<td class="main_field_confirm" colspan="2"><input type="hidden" name="send" value="send" /><input class="bottom" type="submit" value="{$lng['panel']['save']}" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
45
templates/admin/froxlorclients/froxlorclients_edit.tpl
Normal file
45
templates/admin/froxlorclients/froxlorclients_edit.tpl
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
$header
|
||||||
|
<form method="post" action="$filename">
|
||||||
|
<input type="hidden" name="s" value="$s" />
|
||||||
|
<input type="hidden" name="page" value="$page" />
|
||||||
|
<input type="hidden" name="action" value="$action" />
|
||||||
|
<input type="hidden" name="id" value="$id" />
|
||||||
|
<input type="hidden" name="send" value="send" />
|
||||||
|
<table cellpadding="5" cellspacing="4" border="0" align="center" class="maintable_60">
|
||||||
|
<tr>
|
||||||
|
<td class="maintitle" colspan="2"><b><img src="images/title.gif" alt="" /> {$lng['admin']['froxlorclients']['edit']}</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="main_field_name" colspan="2">
|
||||||
|
<!-- tell people what this is about -->
|
||||||
|
{$lng['admin']['froxlorclients']['longdesc_add']}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="maintitle_apply_left">
|
||||||
|
<b><img src="images/title.gif" alt="" /> {$lng['admin']['froxlorclients']['client']}</b>
|
||||||
|
</td>
|
||||||
|
<td class="maintitle_apply_right" nowrap="nowrap">
|
||||||
|
<input class="bottom" type="reset" value="{$lng['panel']['reset']}" /><input class="bottom" type="submit" value="{$lng['panel']['save']}" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="main_field_name">{$lng['admin']['froxlorclients']['name']}:</td>
|
||||||
|
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="name" value="{$client->Get('name')}" size="255" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="main_field_name" valign="top">{$lng['admin']['froxlorclients']['desc']}:</td>
|
||||||
|
<td class="main_field_display" nowrap="nowrap"><textarea class="textarea_border" rows="12" cols="60" name="desc">{$client->Get('desc')}</textarea></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="main_field_name" valign="top">{$lng['admin']['froxlorclients']['enabled']}:</td>
|
||||||
|
<td class="main_field_display" nowrap="nowrap">$client_enabled</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="main_field_confirm" colspan="2"><input class="bottom" type="submit" value="{$lng['panel']['save']}" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
$footer
|
||||||
Reference in New Issue
Block a user