- 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

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