diff --git a/admin_clients.php b/admin_clients.php index f8380538..79f44650 100644 --- a/admin_clients.php +++ b/admin_clients.php @@ -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") . "\";"); } } /** diff --git a/lib/classes/froxlorclient/class.froxlorclient.php b/lib/classes/froxlorclient/class.froxlorclient.php index 057545f4..dad9b39e 100644 --- a/lib/classes/froxlorclient/class.froxlorclient.php +++ b/lib/classes/froxlorclient/class.froxlorclient.php @@ -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 */ diff --git a/lib/functions/froxlor/function.inserttask.php b/lib/functions/froxlor/function.inserttask.php index 388067e1..8d650632 100644 --- a/lib/functions/froxlor/function.inserttask.php +++ b/lib/functions/froxlor/function.inserttask.php @@ -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; diff --git a/lng/english.lng.php b/lng/english.lng.php index c7fde3be..f2d33518 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -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'; ?> diff --git a/templates/admin/froxlorclients/froxlorclients_add.tpl b/templates/admin/froxlorclients/froxlorclients_add.tpl new file mode 100644 index 00000000..048398d1 --- /dev/null +++ b/templates/admin/froxlorclients/froxlorclients_add.tpl @@ -0,0 +1,39 @@ +$header +
+