Commit 4950ba97 authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski

Clean ajax files

1. Replace usage of uninitialized arrays
2. Remove unused variables
parent 07c82676
......@@ -49,8 +49,10 @@ if (isset($_POST["table"])
switch ($_POST["table"]) {
case "glpi_users" :
if ($_POST['value'] == 0) {
$tmpname['link'] = $CFG_GLPI['root_doc']."/front/user.php";
$tmpname['comment'] = "";
$tmpname = [
'link' => $CFG_GLPI['root_doc']."/front/user.php",
'comment' => "",
];
} else {
$tmpname = getUserName($_POST["value"], 2);
}
......
......@@ -85,6 +85,7 @@ if (class_exists($_POST["itemtype"])
echo "<br>";
$values = [];
if ($DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
// Device name + port name
......
......@@ -99,12 +99,14 @@ if (isset($_POST["validatortype"])) {
// Display all/none buttons to select all or no users in group
if (!empty($_POST['groups_id'])) {
echo "<a id='all_users' class='vsubmit'>".__('All')."</a>";
$param_button['validatortype'] = 'group_user';
$param_button['users_id_validate'] = '';
$param_button['all_users'] = 1;
$param_button['groups_id'] = $_POST['groups_id'];
$param_button['right'] = ['validate_request', 'validate_incident'];
$param_button['entity'] = $_SESSION["glpiactive_entity"];
$param_button = [
'validatortype' => 'group_user',
'users_id_validate' => '',
'all_users' => 1,
'groups_id' => $_POST['groups_id'],
'right' => ['validate_request', 'validate_incident'],
'entity' => $_SESSION["glpiactive_entity"],
];
Ajax::updateItemOnEvent('all_users', 'show_groups_users',
$CFG_GLPI["root_doc"]."/ajax/dropdownMassiveActionAddValidator.php",
$param_button, ['click']);
......
......@@ -42,11 +42,6 @@ Session::checkLoginUser();
if (isset($_POST["projects_id"])) {
$rand = mt_rand();
if (isset($_POST["rand"])) {
$rand = $_POST["rand"];
}
if ($_POST["projects_id"] > 0) {
$condition = "`glpi_projecttasks`.`projectstates_id` <> 3
......
......@@ -56,6 +56,7 @@ if ($_POST['softwares_id'] > 0) {
$result = $DB->query($query);
$number = $DB->numrows($result);
$values = [];
if ($number) {
while ($data = $DB->fetch_assoc($result)) {
$ID = $data['id'];
......
......@@ -120,13 +120,15 @@ if (isset($_POST["validatortype"])) {
// Display all/none buttons to select all or no users in group
if (!empty($_POST['groups_id'])) {
echo "<br><br><a id='all_users' class='vsubmit'>".__('All')."</a>";
$param_button['validatortype'] = 'list_users';
$param_button['name'] = !empty($_POST['name']) ? $_POST['name']:'';
$param_button['users_id_validate'] = '';
$param_button['all_users'] = 1;
$param_button['groups_id'] = $_POST['groups_id'];
$param_button['entity'] = $_POST['entity'];
$param_button['right'] = $_POST['right'];
$param_button = [
'validatortype' => 'list_users',
'name' => !empty($_POST['name']) ? $_POST['name']:'',
'users_id_validate' => '',
'all_users' => 1,
'groups_id' => $_POST['groups_id'],
'entity' => $_POST['entity'],
'right' => $_POST['right'],
];
Ajax::updateItemOnEvent('all_users', 'show_list_users',
$CFG_GLPI["root_doc"]."/ajax/dropdownValidator.php",
$param_button, ['click']);
......
......@@ -44,7 +44,9 @@ Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['data'])) {
foreach ($_POST['data'] as $key => $values) {
$response = [];
foreach (array_keys($_POST['data']) as $key) {
$unique_name = Rule::getUuid();
$response[$key] = ['tag' => Document::getImageTag($unique_name), 'name' => $unique_name];
}
......
......@@ -88,13 +88,6 @@ if (isset($_POST["itemtype"])
'width' => '40%']);
// Display select of the linked item type available
foreach ($linked as $key) {
if (!isset($metanames[$key])) {
if ($linkitem = getItemForItemtype($key)) {
$metanames[$key] = $linkitem->getTypeName();
}
}
}
$value = '';
if (isset($metacriteria['itemtype'])
&& !empty($metacriteria['itemtype'])) {
......
......@@ -34,6 +34,14 @@
* @since 0.85
*/
/**
* Following variables are defined in Search::showGenericSearch() before inclusion of this file:
* @var array $p
* @var string $nbsearchcountvar
* @var string $nbmetasearchcountvar
* @var string $searchcriteriatableid
*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "searchrow.php")) {
include ('../inc/includes.php');
......
......@@ -44,17 +44,23 @@ if (isset($_POST['users_id_assign']) && ($_POST['users_id_assign'] > 0)) {
$ticket = new Ticket();
$options2['criteria'][0]['field'] = 5; // users_id assign
$options2['criteria'][0]['searchtype'] = 'equals';
$options2['criteria'][0]['value'] = $_POST['users_id_assign'];
$options2['criteria'][0]['link'] = 'AND';
$options2['criteria'][1]['field'] = 12; // status
$options2['criteria'][1]['searchtype'] = 'equals';
$options2['criteria'][1]['value'] = 'notold';
$options2['criteria'][1]['link'] = 'AND';
$options2['reset'] = 'reset';
$options2 = [
'criteria' => [
[
'field' => 5, // users_id assign
'searchtype' => 'equals',
'value' => $_POST['users_id_assign'],
'link' => 'AND',
],
[
'field' => 12, // status
'searchtype' => 'equals',
'value' => 'notold',
'link' => 'AND',
],
],
'reset' => 'reset',
];
$url = $ticket->getSearchURL()."?".Toolbox::append_params($options2, '&amp;');
......@@ -67,17 +73,23 @@ if (isset($_POST['users_id_assign']) && ($_POST['users_id_assign'] > 0)) {
} else if (isset($_POST['groups_id_assign']) && ($_POST['groups_id_assign'] > 0)) {
$ticket = new Ticket();
$options2['criteria'][0]['field'] = 8; // groups_id assign
$options2['criteria'][0]['searchtype'] = 'equals';
$options2['criteria'][0]['value'] = $_POST['groups_id_assign'];
$options2['criteria'][0]['link'] = 'AND';
$options2['criteria'][1]['field'] = 12; // status
$options2['criteria'][1]['searchtype'] = 'equals';
$options2['criteria'][1]['value'] = 'notold';
$options2['criteria'][1]['link'] = 'AND';
$options2['reset'] = 'reset';
$options2 = [
'criteria' => [
[
'field' => 8, // groups_id assign
'searchtype' => 'equals',
'value' => $_POST['groups_id_assign'],
'link' => 'AND',
],
[
'field' => 12, // status
'searchtype' => 'equals',
'value' => 'notold',
'link' => 'AND',
],
],
'reset' => 'reset',
];
$url = $ticket->getSearchURL()."?".Toolbox::append_params($options2, '&amp;');
......@@ -90,17 +102,23 @@ if (isset($_POST['users_id_assign']) && ($_POST['users_id_assign'] > 0)) {
$ticket = new Ticket();
$options2['criteria'][0]['field'] = 6; // suppliers_id assign
$options2['criteria'][0]['searchtype'] = 'equals';
$options2['criteria'][0]['value'] = $_POST['suppliers_id_assign'];
$options2['criteria'][0]['link'] = 'AND';
$options2['criteria'][1]['field'] = 12; // status
$options2['criteria'][1]['searchtype'] = 'equals';
$options2['criteria'][1]['value'] = 'notold';
$options2['criteria'][1]['link'] = 'AND';
$options2['reset'] = 'reset';
$options2 = [
'criteria' => [
[
'field' => 6, // suppliers_id assign
'searchtype' => 'equals',
'value' => $_POST['suppliers_id_assign'],
'link' => 'AND',
],
[
'field' => 12, // status
'searchtype' => 'equals',
'value' => 'notold',
'link' => 'AND',
],
],
'reset' => 'reset',
];
$url = $ticket->getSearchURL()."?".Toolbox::append_params($options2, '&amp;');
......
......@@ -51,7 +51,7 @@ if (isset($_GET['tab']) && isset($_GET['itemtype'])) {
$tabs[-1] = 'All';
$selected_tab = '';
$current = 0;
foreach ($tabs as $key => $val) {
foreach (array_keys($tabs) as $key) {
if ($current == $_GET['tab']) {
$selected_tab = $key;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment