Commit cd75be74 authored by Johan Cwiklinski's avatar Johan Cwiklinski Committed by Johan Cwiklinski

Short array syntax (from phpcbf)

parent bcc6bdd6
......@@ -58,9 +58,9 @@ if (!isset($item->fields[$_GET['field']]) || !$item->canView()) {
// Security : blacklist fields
if (in_array($table.'.'.$_GET['field'],
array('glpi_authldaps.rootdn', 'glpi_authldaps.rootdn_passwd',
['glpi_authldaps.rootdn', 'glpi_authldaps.rootdn_passwd',
'glpi_configs.value', 'glpi_mailcollectors.login',
'glpi_mailcollectors.passwd', 'glpi_users.name', 'glpi_users.password'))) {
'glpi_mailcollectors.passwd', 'glpi_users.name', 'glpi_users.password'])) {
exit();
}
......@@ -91,7 +91,7 @@ $query = "SELECT DISTINCT `".$_GET['field']."` AS VAL
$entity
ORDER BY `".$_GET['field']."`";
$values = array();
$values = [];
if ($result=$DB->query($query)) {
......
......@@ -83,7 +83,7 @@ if ($item = getItemForItemtype($_GET['_itemtype'])) {
}
}
$notvalidoptions = array('_glpi_tab', '_itemtype', 'sort', 'order', 'withtemplate');
$notvalidoptions = ['_glpi_tab', '_itemtype', 'sort', 'order', 'withtemplate'];
$options = $_GET;
foreach ($notvalidoptions as $key) {
if (isset($options[$key])) {
......
......@@ -56,11 +56,11 @@ if ($_POST["idtable"] && class_exists($_POST["idtable"])) {
$field_id = Html::cleanId("dropdown_".$_POST["name"].$rand);
$p = array('value' => 0,
$p = ['value' => 0,
'valuename' => Dropdown::EMPTY_VALUE,
'itemtype' => $_POST["idtable"],
'display_emptychoice' => true,
'displaywith' => array('otherserial', 'serial'));
'displaywith' => ['otherserial', 'serial']];
if (isset($_POST['value'])) {
$p['value'] = $_POST['value'];
}
......@@ -79,8 +79,8 @@ if ($_POST["idtable"] && class_exists($_POST["idtable"])) {
$p);
if (!empty($_POST['showItemSpecificity'])) {
$params = array('items_id' => '__VALUE__',
'itemtype' => $_POST["idtable"]);
$params = ['items_id' => '__VALUE__',
'itemtype' => $_POST["idtable"]];
if (isset($_POST['entity_restrict'])) {
$params['entity_restrict'] = $_POST['entity_restrict'];
}
......
......@@ -48,7 +48,7 @@ if (!isset($_POST['fromtype']) || !($fromitem = getItemForItemtype($_POST['fromt
$fromitem->checkGlobal(UPDATE);
$used = array();
$used = [];
if (isset($_POST["used"])) {
$used = $_POST["used"];
}
......
......@@ -112,5 +112,5 @@ if (class_exists($_POST["itemtype"])
$values[$ID] = $output_long;
}
}
Dropdown::showFromArray($_POST['myname'], $values, array('display_emptychoice' => true));
Dropdown::showFromArray($_POST['myname'], $values, ['display_emptychoice' => true]);
}
......@@ -47,14 +47,14 @@ if (class_exists($_POST["itemtype"])) {
$table = getTableForItemType($_POST["itemtype"]);
$rand = mt_rand();
$toupdate = array('value_fieldname' => 'item',
$toupdate = ['value_fieldname' => 'item',
'to_update' => "results_item_$rand",
'url' => $CFG_GLPI["root_doc"]."/ajax/dropdownConnectNetworkPort.php",
'moreparams' => array('networkports_id' => $_POST['networkports_id'],
'moreparams' => ['networkports_id' => $_POST['networkports_id'],
'itemtype' => $_POST['itemtype'],
'myname' => $_POST['myname'],
'instantiation_type' => $_POST['instantiation_type']));
$params = array('rand' => $rand,
'instantiation_type' => $_POST['instantiation_type']]];
$params = ['rand' => $rand,
'name' => "items",
'entity' => $_POST["entity_restrict"],
// Beware: '\n' inside condition is transformed to 'n' in SQL request
......@@ -64,7 +64,7 @@ if (class_exists($_POST["itemtype"])) {
"WHERE `itemtype` = '".$_POST["itemtype"]."'".
"AND `instantiation_type`".
"= '".$_POST['instantiation_type']."'))",
'toupdate' => $toupdate);
'toupdate' => $toupdate];
Dropdown::show($_POST['itemtype'], $params);
......
......@@ -68,7 +68,7 @@ if ($_POST['softwares_id'] > 0) {
$result = $DB->query($query);
$number = $DB->numrows($result);
$values = array();
$values = [];
if ($number) {
while ($data = $DB->fetch_assoc($result)) {
$ID = $data['id'];
......@@ -85,5 +85,5 @@ if ($_POST['softwares_id'] > 0) {
}
}
Dropdown::showFromArray($_POST['myname'], $values, array('display_emptychoice' => true));
Dropdown::showFromArray($_POST['myname'], $values, ['display_emptychoice' => true]);
}
......@@ -58,38 +58,38 @@ if (isset($_POST["type"])
}
}
$options = array('name' => '_itil_'.$_POST["actortype"].'[users_id]',
$options = ['name' => '_itil_'.$_POST["actortype"].'[users_id]',
'entity' => $_POST['entity_restrict'],
'right' => $right,
'rand' => $rand,
'ldap_import' => true);
'ldap_import' => true];
if ($CFG_GLPI["notifications_mailing"]) {
$withemail = (isset($_POST["allow_email"]) ? $_POST["allow_email"] : false);
$paramscomment = array('value' => '__VALUE__',
$paramscomment = ['value' => '__VALUE__',
'allow_email' => $withemail,
'field' => "_itil_".$_POST["actortype"],
'use_notification' => $_POST["use_notif"]);
'use_notification' => $_POST["use_notif"]];
// Fix rand value
$options['rand'] = $rand;
$options['toupdate'] = array('value_fieldname' => 'value',
$options['toupdate'] = ['value_fieldname' => 'value',
'to_update' => "notif_user_$rand",
'url' => $CFG_GLPI["root_doc"].
"/ajax/uemailUpdate.php",
'moreparams' => $paramscomment);
'moreparams' => $paramscomment];
}
if (($_POST["itemtype"] == 'Ticket')
&& ($_POST["actortype"] == 'assign')) {
$toupdate = array();
$toupdate = [];
if (isset($options['toupdate']) && is_array($options['toupdate'])) {
$toupdate[] = $options['toupdate'];
}
$toupdate[] = array('value_fieldname' => 'value',
$toupdate[] = ['value_fieldname' => 'value',
'to_update' => "countassign_$rand",
'url' => $CFG_GLPI["root_doc"].
"/ajax/ticketassigninformation.php",
'moreparams' => array('users_id_assign' => '__VALUE__'));
'moreparams' => ['users_id_assign' => '__VALUE__']];
$options['toupdate'] = $toupdate;
}
......@@ -124,18 +124,18 @@ if (isset($_POST["type"])
$cond = '`is_assign`';
}
$param = array('name' => '_itil_'.$_POST["actortype"].'[groups_id]',
$param = ['name' => '_itil_'.$_POST["actortype"].'[groups_id]',
'entity' => $_POST['entity_restrict'],
'condition' => $cond,
'rand' => $rand);
'rand' => $rand];
if (($_POST["itemtype"] == 'Ticket')
&& ($_POST["actortype"] == 'assign')) {
$param['toupdate'] = array('value_fieldname' => 'value',
$param['toupdate'] = ['value_fieldname' => 'value',
'to_update' => "countgroupassign_$rand",
'url' => $CFG_GLPI["root_doc"].
"/ajax/ticketassigninformation.php",
'moreparams' => array('groups_id_assign'
=> '__VALUE__'));
'moreparams' => ['groups_id_assign'
=> '__VALUE__']];
}
$rand = Group::dropdown($param);
......@@ -149,34 +149,34 @@ if (isset($_POST["type"])
break;
case "supplier" :
$options = array('name' => '_itil_'.$_POST["actortype"].'[suppliers_id]',
$options = ['name' => '_itil_'.$_POST["actortype"].'[suppliers_id]',
'entity' => $_POST['entity_restrict'],
'rand' => $rand);
'rand' => $rand];
if ($CFG_GLPI["notifications_mailing"]) {
$withemail = (isset($_POST["allow_email"]) ? $_POST["allow_email"] : false);
$paramscomment = array('value' => '__VALUE__',
$paramscomment = ['value' => '__VALUE__',
'allow_email' => $withemail,
'field' => '_itil_'.$_POST["actortype"],
'typefield' => "supplier",
'use_notification' => $_POST["use_notif"]);
'use_notification' => $_POST["use_notif"]];
// Fix rand value
$options['rand'] = $rand;
$options['toupdate'] = array('value_fieldname' => 'value',
$options['toupdate'] = ['value_fieldname' => 'value',
'to_update' => "notif_supplier_$rand",
'url' => $CFG_GLPI["root_doc"].
"/ajax/uemailUpdate.php",
'moreparams' => $paramscomment);
'moreparams' => $paramscomment];
}
if ($_POST["itemtype"] == 'Ticket') {
$toupdate = array();
$toupdate = [];
if (isset($options['toupdate']) && is_array($options['toupdate'])) {
$toupdate[] = $options['toupdate'];
}
$toupdate[] = array('value_fieldname' => 'value',
$toupdate[] = ['value_fieldname' => 'value',
'to_update' => "countassign_$rand",
'url' => $CFG_GLPI["root_doc"].
"/ajax/ticketassigninformation.php",
'moreparams' => array('suppliers_id_assign' => '__VALUE__'));
'moreparams' => ['suppliers_id_assign' => '__VALUE__']];
$options['toupdate'] = $toupdate;
}
......
......@@ -45,7 +45,7 @@ Session::checkRight('ticket', UPDATE);
if ($_POST["actortype"] > 0) {
$ticket = new Ticket();
$rand = mt_rand();
$ticket->showActorAddForm($_POST["actortype"], $rand, $_SESSION['glpiactive_entity'], array(),
$ticket->showActorAddForm($_POST["actortype"], $rand, $_SESSION['glpiactive_entity'], [],
true, false, false);
echo "&nbsp;<input type='submit' name='add_actor' class='submit' value=\""._sx('button', 'Add')."\">";
}
......@@ -45,9 +45,9 @@ if (isset($_POST["validatortype"])) {
switch ($_POST["validatortype"]) {
case 'user' :
echo "<input type='hidden' name='groups_id' value=0 />";
User::dropdown(array('name' => 'users_id_validate',
User::dropdown(['name' => 'users_id_validate',
'entity' => $_SESSION["glpiactive_entity"],
'right' => array('validate_request', 'validate_incident')));
'right' => ['validate_request', 'validate_incident']]);
echo "<br><br>".__('Comments')." ";
echo "<textarea name='comment_submission' cols='50' rows='6'></textarea>&nbsp;";
......@@ -57,12 +57,12 @@ if (isset($_POST["validatortype"])) {
case 'group' :
echo "<input type='hidden' name='users_id_validate' value=0 />";
$rand = Group::dropdown(array('name' => 'groups_id',
'entity' => $_SESSION["glpiactive_entity"]));
$rand = Group::dropdown(['name' => 'groups_id',
'entity' => $_SESSION["glpiactive_entity"]]);
$param = array('validatortype' => 'group_user',
$param = ['validatortype' => 'group_user',
'groups_id' =>'__VALUE__',
'right' => array('validate_request', 'validate_incident'));
'right' => ['validate_request', 'validate_incident']];
Ajax::updateItemOnSelectEvent("dropdown_groups_id$rand", "show_groups_users",
$CFG_GLPI["root_doc"]."/ajax/dropdownMassiveActionAddValidator.php",
......@@ -73,14 +73,14 @@ if (isset($_POST["validatortype"])) {
case 'group_user' :
$opt = array('groups_id' => $_POST["groups_id"],
$opt = ['groups_id' => $_POST["groups_id"],
'right' => $_POST['right'],
'entity' => $_SESSION["glpiactive_entity"]);
'entity' => $_SESSION["glpiactive_entity"]];
$groups_users = TicketValidation::getGroupUserHaveRights($opt);
$users = array();
$param['values'] = array();
$users = [];
$param['values'] = [];
foreach ($groups_users as $data) {
$users[$data['id']] = formatUserName($data['id'], $data['name'], $data['realname'],
$data['firstname']);
......@@ -104,17 +104,17 @@ if (isset($_POST["validatortype"])) {
$param_button['users_id_validate'] = '';
$param_button['all_users'] = 1;
$param_button['groups_id'] = $_POST['groups_id'];
$param_button['right'] = array('validate_request', 'validate_incident');
$param_button['right'] = ['validate_request', 'validate_incident'];
$param_button['entity'] = $_SESSION["glpiactive_entity"];
Ajax::updateItemOnEvent('all_users', 'show_groups_users',
$CFG_GLPI["root_doc"]."/ajax/dropdownMassiveActionAddValidator.php",
$param_button, array('click'));
$param_button, ['click']);
echo "&nbsp;<a id='no_users' class='vsubmit'>".__('None')."</a>";
$param_button['all_users'] = 0;
Ajax::updateItemOnEvent('no_users', 'show_groups_users',
$CFG_GLPI["root_doc"]."/ajax/dropdownMassiveActionAddValidator.php",
$param_button, array('click'));
$param_button, ['click']);
}
echo "<br><br>".__('Comments')." ";
......
......@@ -56,13 +56,13 @@ if ($_POST["authtype"] > 0) {
case Auth::LDAP :
case Auth::EXTERNAL :
AuthLDAP::dropdown(array('name' => "auths_id",
'condition' => "`is_active` = 1"));
AuthLDAP::dropdown(['name' => "auths_id",
'condition' => "`is_active` = 1"]);
break;
case Auth::MAIL :
AuthMail::dropdown(array('name' => "auths_id",
'condition' => "`is_active` = 1"));
AuthMail::dropdown(['name' => "auths_id",
'condition' => "`is_active` = 1"]);
break;
}
......
......@@ -44,8 +44,8 @@ if (!isset($_POST["itemtype"]) || !($item = getItemForItemtype($_POST['itemtype'
}
if (InfoCom::canApplyOn($_POST["itemtype"])) {
Session::checkSeveralRightsOr(array($_POST["itemtype"] => UPDATE,
"infocom" => UPDATE));
Session::checkSeveralRightsOr([$_POST["itemtype"] => UPDATE,
"infocom" => UPDATE]);
} else {
$item->checkGlobal(UPDATE);
}
......@@ -80,8 +80,8 @@ if (isset($_POST["itemtype"])
// Specific for plugin which add link to core object
|| ($plug = isPluginItemType(getItemTypeForTable($search['table'])))) {
$plugdisplay = Plugin::doOneHook($plug['plugin'], 'MassiveActionsFieldsDisplay',
array('itemtype' => $_POST["itemtype"],
'options' => $search));
['itemtype' => $_POST["itemtype"],
'options' => $search]);
}
$fieldname = '';
......@@ -93,8 +93,8 @@ if (isset($_POST["itemtype"])
$fieldname = $search["linkfield"];
}
if (!$plugdisplay) {
$options = array();
$values = array();
$options = [];
$values = [];
// For ticket template or aditional options of massive actions
if (isset($_POST['options'])) {
$options = $_POST['options'];
......
......@@ -45,7 +45,7 @@ Session::checkCentralAccess();
// Make a select box
if (isset($_POST["rubdoc"])) {
$used = array();
$used = [];
// Clean used array
if (isset($_POST['used']) && is_array($_POST['used']) && (count($_POST['used']) > 0)) {
......@@ -75,11 +75,11 @@ if (isset($_POST["rubdoc"])) {
}
Dropdown::show('Document',
array('name' => $_POST['myname'],
['name' => $_POST['myname'],
'used' => $used,
'width' => '50%',
'entity' => intval($_POST['entity']),
'rand' => intval($_POST['rand']),
'condition' => "glpi_documents.documentcategories_id='".intval($_POST["rubdoc"])."'"));
'condition' => "glpi_documents.documentcategories_id='".intval($_POST["rubdoc"])."'"]);
}
......@@ -72,5 +72,5 @@ if ($_POST['softwares_id'] > 0) {
$values[$ID] = $output;
}
}
Dropdown::showFromArray($_POST['myname'], $values, array('display_emptychoice' => true));
Dropdown::showFromArray($_POST['myname'], $values, ['display_emptychoice' => true]);
}
......@@ -42,7 +42,7 @@ if (strpos($_SERVER['PHP_SELF'], "dropdownTicketCategories.php")) {
die("Sorry. You can't access this file directly");
}
$opt = array('entity' => $_POST["entity_restrict"]);
$opt = ['entity' => $_POST["entity_restrict"]];
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
$opt['condition'] = "`is_helpdeskvisible`='1' AND ";
......
......@@ -56,12 +56,12 @@ if (isset($_POST["itemtype"])
}
echo