function creat_group($name, $descr, $list_id, $req, $group_type) { global $l; if (trim($name) == "") { return array('RESULT' => 'ERROR', 'LBL' => $l->g(638)); } if (trim($descr) == "") { return array('RESULT' => 'ERROR', 'LBL' => $l->g(1234)); } //static group? if ($group_type == 'STATIC') { $static = 1; $req = ""; } else { $static = 0; } //does $name group already exists $reqGetId = "SELECT id FROM hardware WHERE name='%s' and deviceid = '_SYSTEMGROUP_'"; $argGetId = $name; $resGetId = mysql2_query_secure($reqGetId, $_SESSION['OCS']["readServer"], $argGetId); if ($valGetId = mysql_fetch_array($resGetId)) { return array('RESULT' => 'ERROR', 'LBL' => $l->g(621)); } //insert new group $sql_insert = "INSERT INTO hardware(deviceid,name,description,lastdate) VALUES( '_SYSTEMGROUP_' , '%s', '%s', NOW())"; $arg_insert = array($name, $descr); mysql2_query_secure($sql_insert, $_SESSION['OCS']["writeServer"], $arg_insert); //Getting hardware id $insertId = mysql_insert_id($_SESSION['OCS']["writeServer"]); $xml = generate_xml($req); //Creating group $sql_group = "INSERT INTO groups(hardware_id, xmldef, create_time) VALUES ( %s, '%s', UNIX_TIMESTAMP() )"; $arg_group = array($insertId, $xml); mysql2_query_secure($sql_group, $_SESSION['OCS']["writeServer"], $arg_group); addLog("CREATE GROUPE", $name); //Generating cache if ($list_id != '') { $nb_computer = add_computers_cache($list_id, $insertId, $static); return array('RESULT' => 'OK', 'LBL' => $nb_computer); } return array('RESULT' => 'OK', 'LBL' => $l->g(607) . " " . $l->g(608)); }
if (!isset($name_or_id)) { $name_or_id = $protectedPost['group_list']; } if (!isset($lbl)) { $lbl = "''"; } $msg_error = admin_serveur($action, $name_or_id, $lbl, $list_id); } else { if ($protectedPost['onglet'] == $l->g(809)) { $group_type = "STATIC"; } else { $group_type = "DYNAMIC"; } //ajout a un groupe if ($protectedPost['NEW_RAZ'] == "ADD") { $nb_mach = add_computers_cache($list_id, $protectedPost['group_list'], 1); $msg_success = $l->g(973); } //suppression des machines du groupe en masse if ($protectedPost['NEW_RAZ'] == "DEL") { $nb_mach = remove_of_group($protectedPost['group_list'], $list_id); $msg_success = $l->g(971) . "<br>" . $l->g(972); } //Cr�ation d'un nouveau groupe if ($protectedPost['NEW_RAZ'] == "NEW") { $result = creat_group($protectedPost['NAME_GROUP'], $protectedPost['LBL_GROUP'], $list_id, $_SESSION['OCS']['SEARCH_SQL_GROUP'], $group_type); if ($result['RESULT'] == "ERROR") { $nb_mach = "ERROR"; } else { $nb_mach = $result['LBL']; }