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
|
<?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.
*/
/*
* Add tags for users
*/
if (AJAX) {
parse_str($protectedPost['ocs']['0'], $params);
$protectedPost += $params;
ob_start();
}
$form_name = 'taguser';
$table_name = $form_name;
$tab_options = $protectedPost;
$tab_options['form_name'] = $form_name;
$tab_options['table_name'] = $table_name;
//BEGIN SHOW ACCOUNTINFO
require_once 'require/function_commun.php';
require_once('require/function_admininfo.php');
$info_tag = find_info_accountinfo('1', 'COMPUTERS');
if (is_array($info_tag)) {
foreach ($info_tag as $key => $value) {
$info_value_tag = accountinfo_tab($value['id']);
if (is_array($info_value_tag)) {
$tab_options['REPLACE_VALUE'][$value['comment']] = $info_value_tag;
}
}
}
//END SHOW ACCOUNTINFO
printEnTete($l->g(616) . " " . $protectedGet["id"]);
if ($protectedPost['newtag'] != "") {
if (isset($protectedPost['use_generic_0'])) {
if (is_array($info_value_tag)) {
$arg = str_replace(array("*", "?"), "", $protectedPost["newtag"]);
$array_result = find_value_in_field(1, $arg);
} else {
$arg = str_replace(array("*", "?"), array("%", "_"), $protectedPost["newtag"]);
$sql = "select distinct TAG from accountinfo where TAG like '%s'";
$res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
while ($val_account_data = mysqli_fetch_array($res)) {
$array_result[] = $val_account_data['TAG'];
}
}
} else {
$array_result[] = $protectedPost["newtag"];
}
$tab_options['CACHE'] = 'RESET';
$sql = "insert into tags (tag,login) values ('%s','%s')";
$i = 0;
while (isset($array_result[$i])) {
$arg = array($array_result[$i], $protectedGet["id"]);
mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg);
$i++;
}
unset($protectedPost['newtag']);
}
//suppression d'une liste de tag
if (is_defined($protectedPost['del_check'])) {
$sql = "DELETE FROM tags WHERE tag in ";
$arg_sql = array();
$sql = mysql2_prepare($sql, $arg_sql, $protectedPost['del_check']);
$sql['SQL'] .= " AND login='%s'";
array_push($sql['ARG'], $protectedGet["id"]);
mysql2_query_secure($sql['SQL'], $_SESSION['OCS']["writeServer"], $sql['ARG']);
$tab_options['CACHE'] = 'RESET';
}
if (isset($protectedPost['SUP_PROF'])) {
$sql = "DELETE FROM tags WHERE tag='%s' AND login='%s'";
$arg = array($protectedPost['SUP_PROF'], $protectedGet["id"]);
mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg);
}
echo "<br>";
echo open_form($form_name);
$list_fields = array('TAG' => 'tag',
);
$tab_options['FILTRE'] = array_flip($list_fields);
$tab_options['FILTRE']['NAME'] = $l->g(49);
asort($tab_options['FILTRE']);
$list_fields['SUP'] = 'tag';
$list_fields['CHECK'] = 'tag';
$list_col_cant_del = array('SUP' => 'SUP', 'CHECK' => 'CHECK');
$default_fields = array('TAG' => 'tag');
$sql = prepare_sql_tab($list_fields, $list_col_cant_del);
$sql['SQL'] = "SELECT tag FROM tags where login='%s'";
$sql['ARG'] = array($protectedGet["id"]);
$tab_options['ARG_SQL'] = $sql['ARG'];
$queryDetails = $sql['SQL'];
$tab_options['LBL']['SUP'] = $l->g(122);
ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del);
$img['image/delete.png'] = $l->g(162);
del_selection($form_name);
if (is_array($info_value_tag) && !isset($protectedPost['use_generic_0'])) {
$type = 2;
} else {
$type = 0;
$info_value_tag = $protectedPost['newtag'];
}
echo "<div class='row'>";
echo "<div class='col-md-6 col-md-offset-3'>";
$select_choise = show_modif($info_value_tag, 'newtag', $type);
echo "<br>";
echo $l->g(617) . " " . $_SESSION['OCS']['TAG_LBL']['TAG'] . ": " . $select_choise;
echo "<input type='submit' name='ADD_TAG' value='" . $l->g(13) . "' class='btn'><br>";
echo $l->g(358);
echo "</div>";
echo "</div>";
echo close_form();
if (AJAX) {
ob_end_clean();
tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options);
}
?>
|