- added form to add new froxlor-clients (no deploy etc.)

- implemented function to return all active client-id's for inserttask-function (task for all clients+master)
This commit is contained in:
Michael Kaufmann (d00p)
2010-10-19 14:35:33 +00:00
parent c0b19fa2b2
commit b2ea0cb666
5 changed files with 116 additions and 8 deletions

View File

@@ -90,11 +90,37 @@ if((int)$settings['multiserver']['enabled'] == 1)
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$name = validate($_POST['name'], 'name');
$desc = validate($_POST['desc'], 'desc');
$client_enabled = intval($_POST['vhostcontainer']);
if($name == '')
{
standard_error(array('stringisempty', 'name'));
}
if($desc == '')
{
standard_error(array('stringisempty', 'desc'));
}
if($client_enabled != 1) {
$client_enabled = 0;
}
$new_client = froxlorclient::getInstance($userinfo, $db, $settings, -1);
$new_client->Set('name', $name, true, false);
$new_client->Set('desc', $desc, true, false);
$new_client->Set('enabled', $client_enabled, true, true);
$cid = $new_client->Insert();
$log->logAction(ADM_ACTION, LOG_WARNING, "added froxlor-client '" . $name . "' (#" . $cid . ")");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$client_enabled = makeyesno('enabled', '1', '0', '0');
eval("echo \"" . getTemplate("froxlorclients/froxlorclients_add") . "\";");
}
}
/**

View File

@@ -102,6 +102,25 @@ class froxlorclient
return self::$clients[$_cid];
}
/**
* return an array of enabled froxlor-client ids
*
* @param resource mysql-object
*
* @return array
*/
static public function getFroxlorClients($_db = null)
{
$sql = "SELECT `id` FROM `".TABLE_FROXLOR_CLIENTS."` WHERE `enabled` = '1';";
$res = $_db->query($sql);
$result = array();
while($_r = mysql_fetch_array($res))
{
$result[] = $_r['id'];
}
return $result;
}
/**
* This functions deploys the needed files
* to the client destination server
@@ -151,6 +170,22 @@ class froxlorclient
}
}
/**
* Insert new client to database
*/
public function Insert()
{
$this->db->query("INSERT INTO
`" . TABLE_FROXLOR_CLIENTS . "`
SET
`name` = '" . $this->db->escape($this->Get('name')) . "',
`desc` = '" . $this->db->escape($this->Get('desc')) . "',
`enabled` = '" . (int)$this->Get('enabled') . "';
");
$this->cid = $this->db->insert_id();
return $this->cid;
}
/**
* Update data in database
*/

View File

@@ -52,14 +52,16 @@ function inserttask()
// if server_id = -1 then add this task for EVERY froxlor-client
if($server_id == -1)
{
// @TODO implement function to get number of froxlor-clients
/*
$numclients = getNumberOfFroxlorClients();
foreach($numclients as $froxclient_id)
{
inserttask($type, implode(', ', $taskparams), $froxclient_id);
$numclients = froxlorclient::getFroxlorClients($db);
if(is_array($numclients)
&& count($numclients) > 0
) {
foreach($numclients as $froxclient_id)
{
inserttask($type, implode(', ', $taskparams), $froxclient_id);
}
}
*/
// also for the master
inserttask($type, implode(', ', $taskparams), 0);
return;

View File

@@ -1514,8 +1514,14 @@ $lng['serversettings']['login_domain_login'] = 'Allow login with domains';
// ADDED IN FROXLOR 0.9.14-svn7
$lng['admin']['multiserver'] = 'Multiserver settings';
$lng['multiserver']['enabled']['title'] = 'Enable multiserver mode';
$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']['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';
$lng['admin']['froxlorclients']['desc'] = 'Client description';
?>

View File

@@ -0,0 +1,39 @@
$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" />
<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="" />&nbsp;{$lng['admin']['froxlorclients']['add']}</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="" />&nbsp;{$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="" 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"></textarea></td>
</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>
</tr>
</table>
</form>
<br />
<br />
$footer