1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
<?php
/*
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
* See the Contributors file for more details about them.
*
* This file is part of OCSInventory-NG/OCSInventory-ocsreports.
*
* OCSInventory-NG/OCSInventory-ocsreports is free software: you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the License,
* or (at your option) any later version.
*
* OCSInventory-NG/OCSInventory-ocsreports is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
require_once('require/function_search.php');
require_once('require/function_groups.php');
$form_name = "groups_affect";
echo open_form($form_name, '', '', 'form-horizontal');
$list_id = multi_lot($form_name, $l->g(601));
/* * *******************************************TRAITEMENT DES DONNEES**************************************** */
if (isset($protectedPost['VALID_GROUP'])) {
echo "<div class='col col-md-12'>";
//gestion groupe de serveurs
if ($protectedPost['onglet'] == mb_strtoupper($l->g(651))) {
require_once('require/function_server.php');
//ajout de machines
if ($protectedPost['NEW_RAZ'] == "ADD") {
$action = 'add_serv';
}
//nouveau groupe
if ($protectedPost['NEW_RAZ'] == "NEW") {
$name_or_id = $protectedPost['NAME_GROUP'];
$lbl = $protectedPost['LBL_GROUP'];
$action = 'new_serv';
}
//remplacement d'un groupe
if ($protectedPost['NEW_RAZ'] == "RAZ") {
$action = 'replace_serv';
}
//suppression de machines dans le groupe de serveur
if ($protectedPost['NEW_RAZ'] == "DEL") {
$action = 'del_serv';
}
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);
}//gestion groupe de machines
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'];
}
$msg_success = $l->g(880);
}
//ecrasement d'un groupe
if ($protectedPost['NEW_RAZ'] == "RAZ") {
$nb_mach = replace_group($protectedPost['group_list'], $list_id, $_SESSION['OCS']['SEARCH_SQL_GROUP'], $group_type);
$msg_success = $l->g(879);
}
if ($nb_mach == "ERROR") {
$msg_error = $result['LBL'];
} elseif (isset($nb_mach) && $protectedPost['NEW_RAZ'] != "DEL") {
$msg_success .= "<br>" . $nb_mach . " " . $l->g(974);
}
}
if (is_defined($msg_success)) {
msg_success($msg_success);
}
if (is_defined($msg_error)) {
msg_error($msg_error);
}
echo "</div>";
}
/* * *******************************************CALCUL DES CHAMPS A AFFICHER************************************ */
if ($list_id) {
//définition des onglets
//for all
$def_onglets[$l->g(809)] = $l->g(809); //GROUPES STATIQUES
}
if ($_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES") {
$def_onglets[$l->g(810)] = $l->g(810); //GROUPES DYNAMIQUES
$def_onglets[mb_strtoupper($l->g(651))] = mb_strtoupper($l->g(651)); //GROUPES DE SERVEURS
//definition of option NEW every time
$optionList['NEW'] = $l->g(586);
}
//if no select => first onget selected
if (!is_defined($protectedPost['onglet'])) {
if (isset($def_onglets[$l->g(809)])) {
$protectedPost['onglet'] = $l->g(809);
} else {
$protectedPost['onglet'] = $l->g(810);
}
}
if ($protectedPost['onglet'] == $l->g(810)) {
$all_groups = all_groups('DYNAMIC');
}
if ($protectedPost['onglet'] == $l->g(809)) {
$all_groups = all_groups('STATIC');
$delGroups = "select distinct id, name,workgroup from hardware,groups_cache
where groups_cache.HARDWARE_ID in (" . $list_id . ")
and groups_cache.group_id=hardware.id
and deviceid = '_SYSTEMGROUP_'
and groups_cache.static = 1";
if (!($_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES")) {
$delGroups .= " and workgroup = 'GROUP_4_ALL'";
}
}
if ($protectedPost['onglet'] == mb_strtoupper($l->g(651)) && $list_id != '') {
$all_groups = all_groups('SERVER');
$delGroups = "select distinct group_id as id, name
from download_servers,hardware
where hardware_id in(" . $list_id . ")
and hardware.id=download_servers.group_id";
}
//search all groups for listid selection
if (isset($delGroups)) {
$resDelGroups = mysqli_query($_SESSION['OCS']["readServer"], $delGroups);
while ($valDelGroups = mysqli_fetch_array($resDelGroups)) {
$groupDelList[$valDelGroups["id"]] = $valDelGroups["name"];
}
}
if ($protectedPost['onglet'] != $l->g(810)) {
$optionList['ADD'] = $l->g(975);
} else {
$optionList['ADD'] = $l->g(589);
}
//if groups exist => add option for go out of the group
if (isset($groupDelList)) {
$optionList['DEL'] = $l->g(818);
} else {
if ($protectedPost['NEW_RAZ'] == "DEL") {
unset($protectedPost['NEW_RAZ']);
}
}
//if group list exist
if (isset($all_groups) && $_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES") {
//show RAZ field
$optionList['RAZ'] = $l->g(588);
}
$select = show_modif($optionList, 'NEW_RAZ', 2, $form_name);
/* * ****************************************show RESULT*********************************************** */
//show onglet
echo "<div class='col col-md-8 col-md-offset-1'>";
if(is_defined($protectedPost['CHOISE']) && $protectedPost['CHOISE'] != 'NONE'){
echo "<p>";
onglet($def_onglets, $form_name, 'onglet', 7);
echo "</p>";
}
//create a "valid" button
$valid = "<tr><td align=center colspan=10><input type=submit value='" . $l->g(13) . "' name='VALID_GROUP' class='btn'></td></tr>";
//open table
echo "<table cellspacing='5' width='80%' BORDER='0' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'><tr><td>";
echo "<tr><td align =center colspan=10>";
if (is_defined($protectedPost['CHOISE']) && $protectedPost['CHOISE'] != 'NONE') {
echo $select;
echo "</td></tr>";
//if user want give up or go out of the group
if ($protectedPost['NEW_RAZ'] == "RAZ" || $protectedPost['NEW_RAZ'] == "ADD") {
$List = $all_groups;
}
if ($protectedPost['NEW_RAZ'] == "DEL") {
$List = $groupDelList;
}
if ($protectedPost['NEW_RAZ'] == "NEW") {
$nom = show_modif($protectedPost['NAME_GROUP'], 'NAME_GROUP', 0, '');
$lbl = show_modif($protectedPost['LBL_GROUP'], 'LBL_GROUP', 1, '');
$addgroup = "<tr><td align=center>" . $l->g(49) . ":</td><td align=left>" . $nom . "</td></tr>";
$addgroup .= "<tr><td align=center>" . $l->g(53) . ":</td><td align=left>" . $lbl . "</td></tr>";
$addgroup .= $valid;
echo $addgroup;
}
if ($protectedPost['NEW_RAZ'] == "RAZ" || $protectedPost['NEW_RAZ'] == "DEL" || $protectedPost['NEW_RAZ'] == "ADD") {
$select = show_modif($List, 'group_list', 2, '');
//list of choise
$groupList = "<tr><td align =center>";
$groupList .= $select;
$groupList .= "</td></tr>";
$groupList .= $valid;
echo $groupList;
}
}
echo "</td></tr></table>";
echo "</div>";
echo close_form();
?>
|