diff --git a/ajax/dropdownitems.php b/ajax/dropdownitems.php index 977f5cc5..bfa5dc1a 100644 --- a/ajax/dropdownitems.php +++ b/ajax/dropdownitems.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -45,12 +45,12 @@ echo ""; echo "
"; $field_id = Html::cleanId("dropdown_" . $_POST['myname'] . $rand); - $p = array('itemtype' => $_POST["itemtype"], + $p = ['itemtype' => $_POST["itemtype"], //'entity_restrict' => $_POST['entity_restrict'], 'table' => $table, //'multiple' => $_POST["multiple"], 'myname' => $_POST["myname"], - 'rand' => $_POST["rand"]); + 'rand' => $_POST["rand"]]; if (isset($_POST["used"]) && !empty($_POST["used"])) { if (isset($_POST["used"][$_POST["itemtype"]])) { @@ -62,4 +62,4 @@ $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/ajax/getDropdownFindItem.php", $p); -} \ No newline at end of file +} diff --git a/ajax/getDropdownFindItem.php b/ajax/getDropdownFindItem.php index afdf8393..c17f44ce 100644 --- a/ajax/getDropdownFindItem.php +++ b/ajax/getDropdownFindItem.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -33,7 +33,9 @@ Html::header_nocache(); Session::checkLoginUser(); -if (!isset($_POST) || empty($_POST)) $_POST = $_GET; +if (!isset($_POST) || empty($_POST)) { + $_POST = $_GET; +} // Security if (!$DB->tableExists($_POST['table'])) { exit(); @@ -107,12 +109,12 @@ $LIMIT"; $result = $DB->query($query); -$datas = array(); +$datas = []; // Display first if no search if ($_POST['page'] == 1 && empty($_POST['searchText'])) { - array_push($datas, array('id' => 0, - 'text' => Dropdown::EMPTY_VALUE)); + array_push($datas, ['id' => 0, + 'text' => Dropdown::EMPTY_VALUE]); } $count = 0; if ($DB->numrows($result)) { @@ -135,12 +137,12 @@ $output = sprintf(__('%1$s (%2$s)'), $output, $data['id']); } - array_push($datas, array('id' => $data['id'], - 'text' => $output)); + array_push($datas, ['id' => $data['id'], + 'text' => $output]); $count++; } } $ret['count'] = $count; $ret['results'] = $datas; -echo json_encode($ret); \ No newline at end of file +echo json_encode($ret); diff --git a/css/ocsinventoryng.css b/css/ocsinventoryng.css index 60c85a4a..163e76d3 100644 --- a/css/ocsinventoryng.css +++ b/css/ocsinventoryng.css @@ -125,7 +125,7 @@ table.ipdisc_tab, table.ipdisc_tab_header { } /*table{ - border-spacing: 0; + border-spacing: 0; }*/ td.ipdisc_tab, td.ipdisc_tab_row, table.ipdisc_tab_header { @@ -165,4 +165,4 @@ td.ipdisc_tab, td.ipdisc_tab_row, table.ipdisc_tab_header { .ocsinventoryng_toner_level_other { border: 0px; background-color: #0464BB; -} \ No newline at end of file +} diff --git a/front/config.form.php b/front/config.form.php index 1d3d2207..d9a60d79 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -48,7 +48,7 @@ if ($plugin->isActivated("ocsinventoryng")) { Html::header(__("Automatic synchronization's configuration", 'ocsinventoryng'), '', "tools", "pluginocsinventoryngmenu", "config"); - $config->display(array('id' => 1)); + $config->display(['id' => 1]); } else { Html::header(__('Setup'), '', "tools", "pluginocsinventoryngmenu", "config"); echo "


"; @@ -56,4 +56,4 @@ echo "" . __('Please activate the plugin', 'ocsinventoryng') . "
"; } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/config.php b/front/config.php index 3fddffde..53865a35 100644 --- a/front/config.php +++ b/front/config.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,4 +46,4 @@ echo "" . __('Please activate the plugin', 'ocsinventoryng') . ""; } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/deleted_equiv.php b/front/deleted_equiv.php index 07ffd1f8..c8447f73 100644 --- a/front/deleted_equiv.php +++ b/front/deleted_equiv.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -94,4 +94,4 @@ echo ""; -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/detail.php b/front/detail.php index 63a8c9f5..5977bafe 100644 --- a/front/detail.php +++ b/front/detail.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -35,4 +35,4 @@ Search::show('PluginOcsinventoryngDetail'); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ipdiscover.import.php b/front/ipdiscover.import.php index 6ab2f37a..86985bfb 100644 --- a/front/ipdiscover.import.php +++ b/front/ipdiscover.import.php @@ -55,7 +55,7 @@ } $subnet = PluginOcsinventoryngIpdiscoverOcslink::getSubnetIDbyIP($ipAdress); - $hardware = array(); + $hardware = []; $knownMacAdresses = $ip->getKnownMacAdresseFromGlpi(); if (isset($status)) { $hardware = $ip->getHardware($ipAdress, $ocsServerId, $status, $knownMacAdresses); @@ -89,7 +89,7 @@ $itemsNames = $_POST["itemsname"]; $itemsDescription = $_POST["itemsdescription"]; $itemsIp = $_POST["itemsip"]; - $entities = array(); + $entities = []; if (isset($_POST["entities"])) { $entities = $_POST["entities"]; @@ -167,7 +167,7 @@ $itemsDescription = $_POST["itemsdescription"]; $ocsItemstypes = $_POST["ocsitemstype"]; $itemsIp = $_POST["itemsip"]; - $entities = array(); + $entities = []; if (isset($_POST["entities"])) { $entities = $_POST["entities"]; @@ -240,8 +240,8 @@ $itemtypes = $_POST["tolink_itemtype"]; $items_id = $_POST["tolink_items"]; $macAdresses = $_POST["mactoimport"]; - $itemsDescription = (isset($_POST["itemsdescription"]) ? $_POST["itemsdescription"] : array()); - $ocsItemstypes = (isset($_POST["ocsitemstype"]) ? $_POST["ocsitemstype"] : array()); + $itemsDescription = (isset($_POST["itemsdescription"]) ? $_POST["itemsdescription"] : []); + $ocsItemstypes = (isset($_POST["ocsitemstype"]) ? $_POST["ocsitemstype"] : []); $ip->linkIpDiscover($_SESSION["plugin_ocsinventoryng_ocsservers_id"], $itemtypes, $items_id, $macAdresses, $ocsItemstypes, $itemsDescription, $_POST["subnet"], 0); } @@ -287,4 +287,4 @@ } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ipdiscover.modifynetwork.php b/front/ipdiscover.modifynetwork.php index 1d65a12e..bf48824e 100644 --- a/front/ipdiscover.modifynetwork.php +++ b/front/ipdiscover.modifynetwork.php @@ -42,11 +42,11 @@ if (isset($_POST["ip"])) { $ipAdress = $_POST["ip"]; - $values = array(); + $values = []; if (isset($_POST["subnetName"]) && isset($_POST["subnetChoice"]) && isset($_POST["SubnetMask"])) { - $values = array("subnetName" => $_POST["subnetName"], "subnetChoice" => $_POST["subnetChoice"], "subnetMask" => $_POST["SubnetMask"]); + $values = ["subnetName" => $_POST["subnetName"], "subnetChoice" => $_POST["subnetChoice"], "subnetMask" => $_POST["SubnetMask"]]; } $ip->modifyNetworkForm($ipAdress, $values); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ipdiscover.php b/front/ipdiscover.php index 71338784..988eaec0 100644 --- a/front/ipdiscover.php +++ b/front/ipdiscover.php @@ -51,7 +51,7 @@ || isset($_SESSION["subnets"]) ) { $sN = ""; - $networksDetail = array(); + $networksDetail = []; $ocsServerId = $_SESSION["plugin_ocsinventoryng_ocsservers_id"]; $tab = $_SESSION["subnets"]; $subnets = $ip->getSubnets($ocsServerId); @@ -84,4 +84,4 @@ } } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/logs.php b/front/logs.php index bb5e865a..08a74cbc 100644 --- a/front/logs.php +++ b/front/logs.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -36,4 +36,4 @@ $thread = new PluginOcsinventoryngThread(); $thread->showErrorLog(); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/networkport.php b/front/networkport.php index ee1496db..678b7ba8 100644 --- a/front/networkport.php +++ b/front/networkport.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify diff --git a/front/networkporttype.form.php b/front/networkporttype.form.php index c0a49682..0fb734eb 100644 --- a/front/networkporttype.form.php +++ b/front/networkporttype.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -30,4 +30,4 @@ include('../../../inc/includes.php'); $dropdown = new PluginOcsinventoryngNetworkPortType(); -include(GLPI_ROOT . "/front/dropdown.common.form.php"); \ No newline at end of file +include(GLPI_ROOT . "/front/dropdown.common.form.php"); diff --git a/front/networkporttype.php b/front/networkporttype.php index 2169bb5a..bc06ef3d 100644 --- a/front/networkporttype.php +++ b/front/networkporttype.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify diff --git a/front/notimportedcomputer.form.php b/front/notimportedcomputer.form.php index f02d3bd2..96d93df6 100644 --- a/front/notimportedcomputer.form.php +++ b/front/notimportedcomputer.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -52,4 +52,4 @@ } } -include(GLPI_ROOT . "/front/dropdown.common.form.php"); \ No newline at end of file +include(GLPI_ROOT . "/front/dropdown.common.form.php"); diff --git a/front/notimportedcomputer.php b/front/notimportedcomputer.php index 81846405..1528edf6 100644 --- a/front/notimportedcomputer.php +++ b/front/notimportedcomputer.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -35,4 +35,4 @@ Search::show('PluginOcsinventoryngNotimportedcomputer'); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocslink.form.php b/front/ocslink.form.php index f067098a..060d9654 100644 --- a/front/ocslink.form.php +++ b/front/ocslink.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -58,4 +58,4 @@ } } else { Html::displayErrorAndDie("lost"); -} \ No newline at end of file +} diff --git a/front/ocsng.clean.php b/front/ocsng.clean.php index 52421c11..4088a4af 100644 --- a/front/ocsng.clean.php +++ b/front/ocsng.clean.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -57,4 +57,4 @@ } } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsng.import.php b/front/ocsng.import.php index f72e3f2c..59ceb3d7 100644 --- a/front/ocsng.import.php +++ b/front/ocsng.import.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -133,4 +133,4 @@ Html::redirect($_SERVER['PHP_SELF']); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsng.link.php b/front/ocsng.link.php index 8b1c1f0d..e3512ba4 100644 --- a/front/ocsng.link.php +++ b/front/ocsng.link.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -50,12 +50,12 @@ } if (isset ($_POST["delete_link"])) { - + $link = new PluginOcsinventoryngOcslink(); if (isset($_POST["toimport"]) && (count($_POST['toimport']) > 0)) { foreach ($_POST['toimport'] as $key => $val) { if ($val == "on") { - $link->deleteByCriteria(array('ocsid' => $key)); + $link->deleteByCriteria(['ocsid' => $key]); } } } @@ -97,7 +97,7 @@ 1); } else { - + if (isset($_POST["toimport"]) && (count($_POST['toimport']) > 0)) { $_SESSION["ocs_link_count"] = 0; @@ -107,8 +107,8 @@ foreach ($_POST['tolink'] as $ocsid => $computers_id) { if ($computers_id > 0 && $key == $ocsid) { - $_SESSION["ocs_link"][] = array('ocsid' => $ocsid, - 'computers_id' => $computers_id); + $_SESSION["ocs_link"][] = ['ocsid' => $ocsid, + 'computers_id' => $computers_id]; } } @@ -120,4 +120,4 @@ Html::redirect($_SERVER['PHP_SELF']); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsng.php b/front/ocsng.php index 601f3ccb..e9241e1e 100644 --- a/front/ocsng.php +++ b/front/ocsng.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -29,8 +29,8 @@ include('../../../inc/includes.php'); -Session::checkSeveralRightsOr(array("plugin_ocsinventoryng" => READ, - "plugin_ocsinventoryng_clean" => READ)); +Session::checkSeveralRightsOr(["plugin_ocsinventoryng" => READ, + "plugin_ocsinventoryng_clean" => READ]); Html::header('OCS Inventory NG', '', "tools", "pluginocsinventoryngmenu", "ocsinventoryng"); @@ -62,4 +62,4 @@ } //PluginOcsinventoryngOcsServer::ocsMenu($_SESSION["plugin_ocsinventoryng_ocsservers_id"]); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsng.sync.php b/front/ocsng.sync.php index 5f96fea7..83b65b67 100644 --- a/front/ocsng.sync.php +++ b/front/ocsng.sync.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -100,4 +100,4 @@ Html::redirect($_SERVER['PHP_SELF']); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsngsnmp.import.php b/front/ocsngsnmp.import.php index abb49076..ee3e79de 100644 --- a/front/ocsngsnmp.import.php +++ b/front/ocsngsnmp.import.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -140,4 +140,4 @@ Html::redirect($_SERVER['PHP_SELF']); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsngsnmp.link.php b/front/ocsngsnmp.link.php index d31ab55f..a6016163 100644 --- a/front/ocsngsnmp.link.php +++ b/front/ocsngsnmp.link.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -128,4 +128,4 @@ Html::redirect($_SERVER['PHP_SELF']); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsngsnmp.sync.php b/front/ocsngsnmp.sync.php index 507e31b6..f3d7a002 100644 --- a/front/ocsngsnmp.sync.php +++ b/front/ocsngsnmp.sync.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -44,7 +44,7 @@ foreach ($_POST['toupdate'] as $key => $val) { if ($val == "on") { $link = new PluginOcsinventoryngSnmpOcslink(); - $link->delete(array('id' => $key), 1); + $link->delete(['id' => $key], 1); } } Html::redirect($_SERVER['PHP_SELF']); @@ -113,4 +113,4 @@ Html::redirect($_SERVER['PHP_SELF']); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsserver.form.php b/front/ocsserver.form.php index 78e880ab..b70b2701 100644 --- a/front/ocsserver.form.php +++ b/front/ocsserver.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -45,7 +45,7 @@ $ocs->delete($_POST); $ocs->redirectToList(); -//Update server + //Update server } else if (isset ($_POST["update"]) || isset ($_POST["updateSNMP"]) ) { @@ -53,7 +53,7 @@ $ocs->update($_POST); Html::back(); -//Add new server + //Add new server } else if (isset ($_POST["add"])) { $ocs->check(-1, CREATE, $_POST); $newID = $ocs->add($_POST); @@ -62,7 +62,7 @@ } Html::back(); -//Other + //Other } else if (isset ($_POST["force_checksum"])) { $ocs->check($_POST['id'], UPDATE); $_POST['checksum'] = 0; @@ -72,4 +72,4 @@ } else { $ocs->display($_GET); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/ocsserver.php b/front/ocsserver.php index 68b392c8..7c570def 100644 --- a/front/ocsserver.php +++ b/front/ocsserver.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -35,4 +35,4 @@ Search::show('PluginOcsinventoryngOcsServer'); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/profile.form.php b/front/profile.form.php index 9a5f6f3a..89ae6265 100644 --- a/front/profile.form.php +++ b/front/profile.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -50,10 +50,10 @@ $_SESSION["plugin_ocsinventoryng_ocsservers_id"] = PluginOcsinventoryngOcsServer::getFirstServer(); if (isset ($_POST['delete'])) { - $input = array(); + $input = []; foreach ($_POST['item'] as $id => $val) { $input['id'] = $id; $profservers->delete($input); } Html::back(); -} \ No newline at end of file +} diff --git a/front/snmpocslink.form.php b/front/snmpocslink.form.php index 66e26a98..2cfd4afa 100644 --- a/front/snmpocslink.form.php +++ b/front/snmpocslink.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -38,9 +38,9 @@ } else if (isset($_POST["delete_link"])) { $link = new PluginOcsinventoryngSnmpOcslink(); - $link->delete(array('id' => $_POST["id"]), 1); + $link->delete(['id' => $_POST["id"]], 1); Html::back(); } else { Html::displayErrorAndDie("lost"); -} \ No newline at end of file +} diff --git a/front/thread.form.php b/front/thread.form.php index e04f5b98..274677d3 100644 --- a/front/thread.form.php +++ b/front/thread.form.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -37,4 +37,4 @@ $thread->title(); $thread->showForm($_GET["pid"]); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/thread.php b/front/thread.php index 51c66bf3..9191229e 100644 --- a/front/thread.php +++ b/front/thread.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -31,8 +31,9 @@ Session::checkRight("plugin_ocsinventoryng", UPDATE); -if (!isset($_GET["plugin_ocsinventoryng_ocsservers_id"])) +if (!isset($_GET["plugin_ocsinventoryng_ocsservers_id"])) { $_GET["plugin_ocsinventoryng_ocsservers_id"] = "0"; +} $thread = new PluginOcsinventoryngThread(); @@ -52,4 +53,4 @@ $thread->showProcesses($_SERVER["PHP_SELF"], $_GET["plugin_ocsinventoryng_ocsservers_id"]); } -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/hook.php b/hook.php index 034d6927..acffa492 100644 --- a/hook.php +++ b/hook.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -45,34 +45,34 @@ function plugin_ocsinventoryng_install() { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/ocsinventoryng/install/mysql/1.4.3-empty.sql"); - $migration->createRule(array('sub_type' => 'RuleImportComputer', + $migration->createRule(['sub_type' => 'RuleImportComputer', 'entities_id' => 0, 'is_recursive' => 0, 'is_active' => 1, 'match' => 'AND', - 'name' => 'RootComputerOcs'), - array(array('criteria' => 'serial', + 'name' => 'RootComputerOcs'], + [['criteria' => 'serial', 'condition' => Rule::PATTERN_FIND, - 'pattern' => '1')), - array(array('field' => '_fusion', + 'pattern' => '1']], + [['field' => '_fusion', 'action_type' => 'assign', - 'value' => 0))); + 'value' => 0]]); - $migration->createRule(array('sub_type' => 'RuleImportEntity', + $migration->createRule(['sub_type' => 'RuleImportEntity', 'entities_id' => 0, 'is_recursive' => 1, 'is_active' => 1, 'match' => 'AND', - 'name' => 'RootEntityOcs'), - array(array('criteria' => 'TAG', + 'name' => 'RootEntityOcs'], + [['criteria' => 'TAG', 'condition' => Rule::PATTERN_IS, - 'pattern' => '*'), - array('criteria' => 'OCS_SERVER', + 'pattern' => '*'], + ['criteria' => 'OCS_SERVER', 'condition' => Rule::PATTERN_IS, - 'pattern' => 1)), - array(array('field' => 'entities_id', + 'pattern' => 1]], + [['field' => 'entities_id', 'action_type' => 'assign', - 'value' => 0))); + 'value' => 0]]); } else if (!$DB->tableExists("glpi_plugin_ocsinventoryng_ocsservers") && !$DB->tableExists("ocs_glpi_ocsservers") @@ -80,34 +80,34 @@ function plugin_ocsinventoryng_install() { CronTask::Register('PluginOcsinventoryngOcsServer', 'ocsng', MINUTE_TIMESTAMP * 5); - $migration->createRule(array('sub_type' => 'RuleImportComputer', + $migration->createRule(['sub_type' => 'RuleImportComputer', 'entities_id' => 0, 'is_recursive' => 0, 'is_active' => 1, 'match' => 'AND', - 'name' => 'RootComputerOcs'), - array(array('criteria' => 'serial', + 'name' => 'RootComputerOcs'], + [['criteria' => 'serial', 'condition' => Rule::PATTERN_FIND, - 'pattern' => '1')), - array(array('field' => '_fusion', + 'pattern' => '1']], + [['field' => '_fusion', 'action_type' => 'assign', - 'value' => 0))); + 'value' => 0]]); - $migration->createRule(array('sub_type' => 'RuleImportEntity', + $migration->createRule(['sub_type' => 'RuleImportEntity', 'entities_id' => 0, 'is_recursive' => 1, 'is_active' => 1, 'match' => 'AND', - 'name' => 'RootEntityOcs'), - array(array('criteria' => 'TAG', + 'name' => 'RootEntityOcs'], + [['criteria' => 'TAG', 'condition' => Rule::PATTERN_IS, - 'pattern' => '*'), - array('criteria' => 'OCS_SERVER', + 'pattern' => '*'], + ['criteria' => 'OCS_SERVER', 'condition' => Rule::PATTERN_IS, - 'pattern' => 1)), - array(array('field' => 'entities_id', + 'pattern' => 1]], + [['field' => 'entities_id', 'action_type' => 'assign', - 'value' => 0))); + 'value' => 0]]); } else if (!$DB->tableExists("glpi_plugin_ocsinventoryng_ocsservers") && $DB->tableExists("ocs_glpi_ocsservers") @@ -132,7 +132,6 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, "1.0.0 insert profiles for OCS in plugin"); } - // recuperation des paramètres du core If ($DB->tableExists("ocs_glpi_crontasks")) { @@ -272,7 +271,6 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, "1.1.0 add table glpi_plugin_ocsinventoryng_items_devicebiosdatas"); } - PluginOcsinventoryngProfile::initProfile(); PluginOcsinventoryngProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); @@ -321,7 +319,6 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, "1.2.3 add table glpi_plugin_ocsinventoryng_ipdiscoverocslinks"); } - // Si massocsimport import est installe, on verifie qu'il soit bien dans la dernière version if ($DB->tableExists("glpi_plugin_mass_ocs_import")) { //1.1 ou 1.2 if (!$DB->fieldExists('glpi_plugin_mass_ocs_import_config', 'warn_if_not_imported')) { //1.1 @@ -368,7 +365,6 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_ocsinventoryng_configs` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `thread_log_frequency` INT(11) NOT NULL DEFAULT '10', @@ -387,7 +383,6 @@ function plugin_ocsinventoryng_install() { VALUES (1, 2, 1, 0);"; $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_ocsinventoryng_details` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `entities_id` INT(11) NOT NULL DEFAULT '0', @@ -424,7 +419,6 @@ function plugin_ocsinventoryng_install() { ('PluginOcsinventoryngDetail', 80, 6, 0)"; $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_ocsinventoryng_notimportedcomputers` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT, `entities_id` INT(11) NOT NULL DEFAULT '0', @@ -447,7 +441,6 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_ocsinventoryng_servers` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `plugin_ocsinventoryng_ocsservers_id` INT(11) NOT NULL DEFAULT '0', @@ -565,7 +558,6 @@ function plugin_ocsinventoryng_install() { $migration->dropField("glpi_plugin_ocsinventoryng_configs", "ocsservers_id"); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_ocsinventoryng_details` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `entities_id` INT(11) NOT NULL DEFAULT '0', @@ -610,7 +602,6 @@ function plugin_ocsinventoryng_install() { $migration->changeField("glpi_plugin_ocsinventoryng_details", "ocsservers_id", "plugin_ocsinventoryng_ocsservers_id", 'integer'); - $query = "UPDATE `glpi_displaypreferences` SET `itemtype` = 'PluginOcsinventoryngNotimportedcomputer' WHERE `itemtype` = 'PluginMassocsimportNotimported'"; @@ -623,7 +614,6 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_ocsinventoryng_notimportedcomputers` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT, `entities_id` INT(11) NOT NULL DEFAULT '0', @@ -695,7 +685,6 @@ function plugin_ocsinventoryng_install() { $migration->changeField("glpi_plugin_ocsinventoryng_servers", "ocsservers_id", "plugin_ocsinventoryng_ocsservers_id", 'integer'); - $query = "UPDATE `glpi_notificationtemplates` SET `itemtype` = 'PluginOcsinventoryngNotimportedcomputer' WHERE `itemtype` = 'PluginMassocsimportNotimported'"; @@ -1139,11 +1128,11 @@ function plugin_ocsinventoryng_install() { $condition = "`plugin_ocsinventoryng_devicebiosdatas_id` = " . $ocsbios["id"]; foreach (getAllDatasFromTable('glpi_plugin_ocsinventoryng_items_devicebiosdatas', $condition) as $item_bios) { $CompDevice = new Item_DeviceFirmware(); - $CompDevice->add(array('items_id' => $item_bios['items_id'], + $CompDevice->add(['items_id' => $item_bios['items_id'], 'itemtype' => $item_bios['itemtype'], 'devicefirmwares_id' => $bios_id, 'is_dynamic' => 1, - 'entities_id' => $item_bios['entities_id']), array(), false); + 'entities_id' => $item_bios['entities_id']], [], false); } } @@ -1268,13 +1257,12 @@ function plugin_ocsinventoryng_install() { $DB->queryOrDie($query, "1.4.4 update table glpi_plugin_ocsinventoryng_ocsservers add linksnmp_computerdisks"); } - /******************* Migration 1.4.4 *******************/ $cron = new CronTask(); if (!$cron->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) { CronTask::Register('PluginOcsinventoryngThread', 'CleanOldThreads', HOUR_TIMESTAMP, - array('param' => 24)); + ['param' => 24]); } if (!$cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'ocsng')) { CronTask::Register('PluginOcsinventoryngOcsServer', 'ocsng', MINUTE_TIMESTAMP * 5); @@ -1282,30 +1270,30 @@ function plugin_ocsinventoryng_install() { if (!$cron->getFromDBbyName('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts')) { // creation du cron - param = duree de conservation CronTask::Register('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts', 10 * MINUTE_TIMESTAMP, - array('param' => 24)); + ['param' => 24]); } if (!$cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'CleanOldAgents')) { - CronTask::Register('PluginOcsinventoryngOcsServer', 'CleanOldAgents', DAY_TIMESTAMP, array('state' => CronTask::STATE_DISABLE)); + CronTask::Register('PluginOcsinventoryngOcsServer', 'CleanOldAgents', DAY_TIMESTAMP, ['state' => CronTask::STATE_DISABLE]); } /*1.3.2*/ if (!$cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'RestoreOldAgents')) { - CronTask::Register('PluginOcsinventoryngOcsServer', 'RestoreOldAgents', DAY_TIMESTAMP, array('state' => CronTask::STATE_DISABLE)); + CronTask::Register('PluginOcsinventoryngOcsServer', 'RestoreOldAgents', DAY_TIMESTAMP, ['state' => CronTask::STATE_DISABLE]); } if (!$cron->getFromDBbyName('PluginOcsinventoryngRuleImportEntity', 'CheckRuleImportEntity')) { - CronTask::Register('PluginOcsinventoryngRuleImportEntity', 'CheckRuleImportEntity', DAY_TIMESTAMP, array('state' => CronTask::STATE_DISABLE)); + CronTask::Register('PluginOcsinventoryngRuleImportEntity', 'CheckRuleImportEntity', DAY_TIMESTAMP, ['state' => CronTask::STATE_DISABLE]); } /*Now delete old tables*/ - $tables_ocs = array("ocs_glpi_crontasks", "ocs_glpi_displaypreferences", + $tables_ocs = ["ocs_glpi_crontasks", "ocs_glpi_displaypreferences", "ocs_glpi_ocsadmininfoslinks", "ocs_glpi_ocslinks", - "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles"); + "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles"]; foreach ($tables_ocs as $table_ocs) { $DB->query("DROP TABLE IF EXISTS `$table_ocs`;"); } - $tables_mass = array("backup_glpi_plugin_massocsimport_configs", "backup_glpi_plugin_massocsimport_details", + $tables_mass = ["backup_glpi_plugin_massocsimport_configs", "backup_glpi_plugin_massocsimport_details", "backup_glpi_plugin_massocsimport_notimported", "backup_glpi_plugin_massocsimport_servers", - "backup_glpi_plugin_massocsimport_threads"); + "backup_glpi_plugin_massocsimport_threads"]; foreach ($tables_mass as $table_mass) { $DB->query("DROP TABLE IF EXISTS `$table_mass`;"); @@ -1324,7 +1312,7 @@ function plugin_ocsinventoryng_uninstall() { include_once(GLPI_ROOT . "/plugins/ocsinventoryng/inc/profile.class.php"); include_once(GLPI_ROOT . "/plugins/ocsinventoryng/inc/menu.class.php"); - $tables = array("glpi_plugin_ocsinventoryng_ocsservers", + $tables = ["glpi_plugin_ocsinventoryng_ocsservers", "glpi_plugin_ocsinventoryng_ocslinks", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks", "glpi_plugin_ocsinventoryng_threads", @@ -1346,24 +1334,24 @@ function plugin_ocsinventoryng_uninstall() { "glpi_plugin_ocsinventoryng_networkshares", "glpi_plugin_ocsinventoryng_runningprocesses", "glpi_plugin_ocsinventoryng_services", - "glpi_plugin_ocsinventoryng_teamviewers"); + "glpi_plugin_ocsinventoryng_teamviewers"]; foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `$table`;"); } - $old_tables = array("glpi_plugin_ocsinventoryng_profiles", + $old_tables = ["glpi_plugin_ocsinventoryng_profiles", "glpi_plugin_ocsinventoryng_devicebiosdatas", - "glpi_plugin_ocsinventoryng_items_devicebiosdatas"); + "glpi_plugin_ocsinventoryng_items_devicebiosdatas"]; - foreach ($old_tables as $table) { - $DB->query("DROP TABLE IF EXISTS `$table`;"); - } - - $tables_glpi = array("glpi_savedsearches", "glpi_displaypreferences", "glpi_logs"); + foreach ($old_tables as $table) { + $DB->query("DROP TABLE IF EXISTS `$table`;"); + } + + $tables_glpi = ["glpi_savedsearches", "glpi_displaypreferences", "glpi_logs"]; - foreach ($tables_glpi as $table_glpi) { - $DB->query("DELETE + foreach ($tables_glpi as $table_glpi) { + $DB->query("DELETE FROM `" . $table_glpi . "` WHERE `itemtype` IN ('PluginMassocsimportNotimported', 'PluginMassocsimportDetail', @@ -1371,90 +1359,89 @@ function plugin_ocsinventoryng_uninstall() { 'PluginOcsinventoryngNotimportedcomputer', 'PluginOcsinventoryngDetail', 'PluginOcsinventoryngRuleImportEntity')"); - } + } - $tables_ocs = array("ocs_glpi_crontasks", "ocs_glpi_displaypreferences", + $tables_ocs = ["ocs_glpi_crontasks", "ocs_glpi_displaypreferences", "ocs_glpi_ocsadmininfoslinks", "ocs_glpi_ocslinks", - "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles"); + "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles"]; - foreach ($tables_ocs as $table_ocs) { - $DB->query("DROP TABLE IF EXISTS `$table_ocs`;"); - } - $tables_mass = array("backup_glpi_plugin_massocsimport_configs", + foreach ($tables_ocs as $table_ocs) { + $DB->query("DROP TABLE IF EXISTS `$table_ocs`;"); + } + $tables_mass = ["backup_glpi_plugin_massocsimport_configs", "backup_glpi_plugin_massocsimport_details", "backup_glpi_plugin_massocsimport_notimported", "backup_glpi_plugin_massocsimport_servers", - "backup_glpi_plugin_massocsimport_threads"); + "backup_glpi_plugin_massocsimport_threads"]; - foreach ($tables_mass as $table_mass) { - $DB->query("DROP TABLE IF EXISTS `$table_mass`;"); - } + foreach ($tables_mass as $table_mass) { + $DB->query("DROP TABLE IF EXISTS `$table_mass`;"); + } - $query = "DELETE + $query = "DELETE FROM `glpi_alerts` WHERE `itemtype` IN ('PluginMassocsimportNotimported', 'PluginOcsinventoryngNotimportedcomputer', 'PluginOcsinventoryngRuleImportEntity')"; - $DB->queryOrDie($query, $DB->error()); - - // clean rules - $rule = new RuleImportEntity(); - foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportEntity')) AS $data) { - $rule->delete($data); - } - $rule = new RuleImportComputer(); - foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportComputer')) AS $data) { - $rule->delete($data); - } + $DB->queryOrDie($query, $DB->error()); + // clean rules + $rule = new RuleImportEntity(); + foreach ($DB->request("glpi_rules", ['sub_type' => 'RuleImportEntity']) AS $data) { + $rule->delete($data); + } + $rule = new RuleImportComputer(); + foreach ($DB->request("glpi_rules", ['sub_type' => 'RuleImportComputer']) AS $data) { + $rule->delete($data); + } - $notification = new Notification(); - foreach (getAllDatasFromTable($notification->getTable(), + $notification = new Notification(); + foreach (getAllDatasFromTable($notification->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported', 'PluginOcsinventoryngNotimportedcomputer', 'PluginOcsinventoryngRuleImportEntity')") as $data) { $notification->delete($data); - } - $template = new NotificationTemplate(); - foreach (getAllDatasFromTable($template->getTable(), + } + $template = new NotificationTemplate(); + foreach (getAllDatasFromTable($template->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported', 'PluginOcsinventoryngNotimportedcomputer', 'PluginOcsinventoryngRuleImportEntity')") as $data) { $template->delete($data); - } + } - $cron = new CronTask; - if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) { - CronTask::Unregister('massocsimport'); - CronTask::Unregister('CleanOldThreads'); - } - if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'ocsng')) { - CronTask::Unregister('ocsinventoryng'); - CronTask::Unregister('ocsng'); - } - if ($cron->getFromDBbyName('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts')) { - CronTask::Unregister('SendAlerts'); - } - if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'CleanOldAgents')) { - CronTask::Unregister('CleanOldAgents'); - } - if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'RestoreOldAgents')) { - CronTask::Unregister('RestoreOldAgents'); - } - if ($cron->getFromDBbyName('PluginOcsinventoryngRuleImportEntity', 'CheckRuleImportEntity')) { - CronTask::Unregister('CheckRuleImportEntity'); - } + $cron = new CronTask; + if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) { + CronTask::Unregister('massocsimport'); + CronTask::Unregister('CleanOldThreads'); + } + if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'ocsng')) { + CronTask::Unregister('ocsinventoryng'); + CronTask::Unregister('ocsng'); + } + if ($cron->getFromDBbyName('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts')) { + CronTask::Unregister('SendAlerts'); + } + if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'CleanOldAgents')) { + CronTask::Unregister('CleanOldAgents'); + } + if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'RestoreOldAgents')) { + CronTask::Unregister('RestoreOldAgents'); + } + if ($cron->getFromDBbyName('PluginOcsinventoryngRuleImportEntity', 'CheckRuleImportEntity')) { + CronTask::Unregister('CheckRuleImportEntity'); + } - //Delete rights associated with the plugin - $profileRight = new ProfileRight(); - foreach (PluginOcsinventoryngProfile::getAllRights() as $right) { - $profileRight->deleteByCriteria(array('name' => $right['field'])); - } - PluginOcsinventoryngMenu::removeRightsFromSession(); + //Delete rights associated with the plugin + $profileRight = new ProfileRight(); + foreach (PluginOcsinventoryngProfile::getAllRights() as $right) { + $profileRight->deleteByCriteria(['name' => $right['field']]); + } + PluginOcsinventoryngMenu::removeRightsFromSession(); - PluginOcsinventoryngProfile::removeRightsFromSession(); + PluginOcsinventoryngProfile::removeRightsFromSession(); - return true; + return true; } @@ -1463,9 +1450,9 @@ function plugin_ocsinventoryng_uninstall() { */ function plugin_ocsinventoryng_getDropdown() { // Table => Name - return array('PluginOcsinventoryngNetworkPortType' => PluginOcsinventoryngNetworkPortType::getTypeName(2), + return ['PluginOcsinventoryngNetworkPortType' => PluginOcsinventoryngNetworkPortType::getTypeName(2), 'PluginOcsinventoryngNetworkPort' => PluginOcsinventoryngNetworkPort::getTypeName(2), - "PluginOcsinventoryngNotimportedcomputer" => __('Computers not imported by automatic actions', 'ocsinventoryng')); + "PluginOcsinventoryngNotimportedcomputer" => __('Computers not imported by automatic actions', 'ocsinventoryng')]; } /** @@ -1476,62 +1463,61 @@ function plugin_ocsinventoryng_getDatabaseRelations() { $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng")) { - return array("glpi_plugin_ocsinventoryng_ocsservers" - => array("glpi_plugin_ocsinventoryng_ocslinks" + return ["glpi_plugin_ocsinventoryng_ocsservers" + => ["glpi_plugin_ocsinventoryng_ocslinks" => "plugin_ocsinventoryng_ocsservers_id", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks" - => "plugin_ocsinventoryng_ocsservers_id"), + => "plugin_ocsinventoryng_ocsservers_id"], "glpi_entities" - => array("glpi_plugin_ocsinventoryng_ocslinks" => "entities_id", + => ["glpi_plugin_ocsinventoryng_ocslinks" => "entities_id", "glpi_plugin_ocsinventoryng_threads" => "entities_id", "glpi_plugin_ocsinventoryng_details" => "entities_id", - "glpi_plugin_ocsinventoryng_notimportedcomputers" => "entities_id"), + "glpi_plugin_ocsinventoryng_notimportedcomputers" => "entities_id"], "glpi_computers" - => array("glpi_plugin_ocsinventoryng_ocslinks" => "computers_id", + => ["glpi_plugin_ocsinventoryng_ocslinks" => "computers_id", "glpi_plugin_ocsinventoryng_registrykeys" => "computers_id", "glpi_plugin_ocsinventoryng_winupdates" => "computers_id", "glpi_plugin_ocsinventoryng_proxysettings" => "computers_id", - "glpi_plugin_ocsinventoryng_winusers" => "computers_id"), - + "glpi_plugin_ocsinventoryng_winusers" => "computers_id"], "glpi_states" - => array("glpi_plugin_ocsinventoryng_ocsservers" => "states_id_default")); + => ["glpi_plugin_ocsinventoryng_ocsservers" => "states_id_default"]]; } - return array(); + return []; } function plugin_ocsinventoryng_postinit() { global $PLUGIN_HOOKS; - $PLUGIN_HOOKS['pre_item_add']['ocsinventoryng'] = array(); - $PLUGIN_HOOKS['item_update']['ocsinventoryng'] = array(); + $PLUGIN_HOOKS['pre_item_add']['ocsinventoryng'] = []; + $PLUGIN_HOOKS['item_update']['ocsinventoryng'] = []; $PLUGIN_HOOKS['pre_item_add']['ocsinventoryng'] - = array('Computer_Item' => array('PluginOcsinventoryngOcslink', 'addComputer_Item')); + = ['Computer_Item' => ['PluginOcsinventoryngOcslink', 'addComputer_Item']]; - $PLUGIN_HOOKS['pre_item_update']['ocsinventoryng'] = array( + $PLUGIN_HOOKS['pre_item_update']['ocsinventoryng'] = [ 'Infocom' => 'plugin_ocsinventoryng_pre_item_update', - ); + ]; $PLUGIN_HOOKS['item_update']['ocsinventoryng'] - = array('Computer' => array('PluginOcsinventoryngOcslink', 'updateComputer'), + = ['Computer' => ['PluginOcsinventoryngOcslink', 'updateComputer'], 'Infocom' => 'plugin_ocsinventoryng_item_update', - 'Item_OperatingSystem' => array('PluginOcsinventoryngOcslink', 'updateComputerOS'), - ); + 'Item_OperatingSystem' => ['PluginOcsinventoryngOcslink', 'updateComputerOS'], + ]; $PLUGIN_HOOKS['pre_item_purge']['ocsinventoryng'] - = array('Computer' => array('PluginOcsinventoryngOcslink', 'purgeComputer'), - 'Computer_Item' => array('PluginOcsinventoryngOcslink', 'purgeComputer_Item')); + = ['Computer' => ['PluginOcsinventoryngOcslink', 'purgeComputer'], + 'Computer_Item' => ['PluginOcsinventoryngOcslink', 'purgeComputer_Item']]; $PLUGIN_HOOKS['item_purge']['ocsinventoryng'] - = array('Printer' => array('PluginOcsinventoryngSnmpOcslink', 'purgePrinter'), - 'NetworkEquipment' => array('PluginOcsinventoryngSnmpOcslink', 'purgeNetworkEquipment'), - 'Computer' => array('PluginOcsinventoryngSnmpOcslink', 'purgeComputer'), - 'Peripheral' => array('PluginOcsinventoryngSnmpOcslink', 'purgePeripheral'), - 'Phone' => array('PluginOcsinventoryngSnmpOcslink', 'purgePhone')); + = ['Printer' => ['PluginOcsinventoryngSnmpOcslink', 'purgePrinter'], + 'NetworkEquipment' => ['PluginOcsinventoryngSnmpOcslink', 'purgeNetworkEquipment'], + 'Computer' => ['PluginOcsinventoryngSnmpOcslink', 'purgeComputer'], + 'Peripheral' => ['PluginOcsinventoryngSnmpOcslink', 'purgePeripheral'], + 'Phone' => ['PluginOcsinventoryngSnmpOcslink', 'purgePhone']]; if (Session::haveRight("plugin_ocsinventoryng", UPDATE) || Session::haveRight("plugin_ocsinventoryng_view", READ) @@ -1554,7 +1540,7 @@ function plugin_ocsinventoryng_MassiveActions($type) { switch ($type) { case 'PluginOcsinventoryngNotimportedcomputer' : - $actions = array(); + $actions = []; $actions['PluginOcsinventoryngNotimportedcomputer' . MassiveAction::CLASS_ACTION_SEPARATOR . "plugin_ocsinventoryng_replayrules"] = __("Restart import", 'ocsinventoryng'); $actions['PluginOcsinventoryngNotimportedcomputer' . MassiveAction::CLASS_ACTION_SEPARATOR . "plugin_ocsinventoryng_import"] = __("Import in the entity", 'ocsinventoryng'); @@ -1571,14 +1557,14 @@ function plugin_ocsinventoryng_MassiveActions($type) { || Session::haveRight("plugin_ocsinventoryng_sync", UPDATE) ) { - return array(// Specific one + return [// Specific one 'PluginOcsinventoryngOcsServer' . MassiveAction::CLASS_ACTION_SEPARATOR . "plugin_ocsinventoryng_force_ocsng_update" => __('Force synchronization OCSNG', 'ocsinventoryng'), 'PluginOcsinventoryngOcsServer' . MassiveAction::CLASS_ACTION_SEPARATOR . "plugin_ocsinventoryng_lock_ocsng_field" => __('Lock fields', 'ocsinventoryng'), 'PluginOcsinventoryngOcsServer' . MassiveAction::CLASS_ACTION_SEPARATOR . "plugin_ocsinventoryng_unlock_ocsng_field" => __('Unlock fields', - 'ocsinventoryng')); + 'ocsinventoryng')]; } break; @@ -1587,13 +1573,13 @@ function plugin_ocsinventoryng_MassiveActions($type) { if (Session::haveRight("plugin_ocsinventoryng", UPDATE) && Session::haveRight('networking', UPDATE) ) { - return array('PluginOcsinventoryngNetworkPort' . MassiveAction::CLASS_ACTION_SEPARATOR . 'plugin_ocsinventoryng_update_networkport_type' + return ['PluginOcsinventoryngNetworkPort' . MassiveAction::CLASS_ACTION_SEPARATOR . 'plugin_ocsinventoryng_update_networkport_type' => __('Update networkport types', - 'ocsinventoryng')); + 'ocsinventoryng')]; } } - return array(); + return []; } @@ -1604,7 +1590,7 @@ function plugin_ocsinventoryng_MassiveActions($type) { */ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { - $sopt = array(); + $sopt = []; $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng")) { @@ -1616,62 +1602,62 @@ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { $sopt[10002]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('GLPI import date', 'ocsinventoryng'); $sopt[10002]['datatype'] = 'datetime'; $sopt[10002]['massiveaction'] = false; - $sopt[10002]['joinparams'] = array('jointype' => 'child'); + $sopt[10002]['joinparams'] = ['jointype' => 'child']; $sopt[10003]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10003]['field'] = 'last_ocs_update'; $sopt[10003]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('Last OCSNG inventory date', 'ocsinventoryng'); $sopt[10003]['datatype'] = 'datetime'; $sopt[10003]['massiveaction'] = false; - $sopt[10003]['joinparams'] = array('jointype' => 'child'); + $sopt[10003]['joinparams'] = ['jointype' => 'child']; $sopt[10001]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10001]['field'] = 'use_auto_update'; $sopt[10001]['linkfield'] = '_auto_update_ocs'; // update through compter update process $sopt[10001]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('Automatic update OCSNG', 'ocsinventoryng'); $sopt[10001]['datatype'] = 'bool'; - $sopt[10001]['joinparams'] = array('jointype' => 'child'); + $sopt[10001]['joinparams'] = ['jointype' => 'child']; $sopt[10004]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10004]['field'] = 'ocs_agent_version'; $sopt[10004]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('Inventory agent', 'ocsinventoryng'); $sopt[10004]['massiveaction'] = false; - $sopt[10004]['joinparams'] = array('jointype' => 'child'); + $sopt[10004]['joinparams'] = ['jointype' => 'child']; $sopt[10005]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10005]['field'] = 'tag'; $sopt[10005]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('OCSNG TAG', 'ocsinventoryng'); $sopt[10005]['datatype'] = 'string'; $sopt[10005]['massiveaction'] = false; - $sopt[10005]['joinparams'] = array('jointype' => 'child'); + $sopt[10005]['joinparams'] = ['jointype' => 'child']; $sopt[10006]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10006]['field'] = 'ocsid'; $sopt[10006]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('OCSNG ID', 'ocsinventoryng'); $sopt[10006]['datatype'] = 'number'; $sopt[10006]['massiveaction'] = false; - $sopt[10006]['joinparams'] = array('jointype' => 'child'); + $sopt[10006]['joinparams'] = ['jointype' => 'child']; $sopt[10007]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10007]['field'] = 'last_ocs_conn'; $sopt[10007]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('Last OCSNG connection date', 'ocsinventoryng'); $sopt[10007]['datatype'] = 'date'; $sopt[10007]['massiveaction'] = false; - $sopt[10007]['joinparams'] = array('jointype' => 'child'); + $sopt[10007]['joinparams'] = ['jointype' => 'child']; $sopt[10008]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10008]['field'] = 'ip_src'; $sopt[10008]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('IP Source', 'ocsinventoryng'); $sopt[10008]['datatype'] = 'string'; $sopt[10008]['massiveaction'] = false; - $sopt[10008]['joinparams'] = array('jointype' => 'child'); + $sopt[10008]['joinparams'] = ['jointype' => 'child']; $sopt[10009]['table'] = 'glpi_plugin_ocsinventoryng_ocslinks'; $sopt[10009]['field'] = 'uptime'; $sopt[10009]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('Uptime', 'ocsinventoryng'); $sopt[10009]['datatype'] = 'string'; $sopt[10009]['massiveaction'] = false; - $sopt[10009]['joinparams'] = array('jointype' => 'child'); + $sopt[10009]['joinparams'] = ['jointype' => 'child']; //$sopt['registry'] = __('Registry', 'ocsinventoryng'); @@ -1682,7 +1668,7 @@ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { 'ocsinventoryng')); $sopt[10010]['forcegroupby'] = true; $sopt[10010]['massiveaction'] = false; - $sopt[10010]['joinparams'] = array('jointype' => 'child'); + $sopt[10010]['joinparams'] = ['jointype' => 'child']; $sopt[10011]['table'] = 'glpi_plugin_ocsinventoryng_registrykeys'; $sopt[10011]['field'] = 'ocs_name'; @@ -1691,7 +1677,7 @@ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { 'ocsinventoryng')); $sopt[10011]['forcegroupby'] = true; $sopt[10011]['massiveaction'] = false; - $sopt[10011]['joinparams'] = array('jointype' => 'child'); + $sopt[10011]['joinparams'] = ['jointype' => 'child']; $sopt[10012]['table'] = 'glpi_plugin_ocsinventoryng_ocsservers'; $sopt[10012]['field'] = 'name'; @@ -1699,9 +1685,9 @@ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { $sopt[10012]['forcegroupby'] = true; $sopt[10012]['massiveaction'] = false; $sopt[10012]['datatype'] = 'dropdown'; - $sopt[10012]['joinparams'] = array('beforejoin' - => array('table' => 'glpi_plugin_ocsinventoryng_ocslinks', - 'joinparams' => array('jointype' => 'child'))); + $sopt[10012]['joinparams'] = ['beforejoin' + => ['table' => 'glpi_plugin_ocsinventoryng_ocslinks', + 'joinparams' => ['jointype' => 'child']]]; $sopt[10014]['table'] = 'glpi_plugin_ocsinventoryng_proxysettings'; $sopt[10014]['field'] = 'enabled'; @@ -1709,28 +1695,28 @@ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { $sopt[10014]['forcegroupby'] = true; $sopt[10014]['massiveaction'] = false; //$sopt[10014]['datatype'] = 'dropdown'; - $sopt[10014]['joinparams'] = array('jointype' => 'child'); + $sopt[10014]['joinparams'] = ['jointype' => 'child']; $sopt[10015]['table'] = 'glpi_plugin_ocsinventoryng_proxysettings'; $sopt[10015]['field'] = 'address'; $sopt[10015]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('Proxy address', 'ocsinventoryng'); $sopt[10015]['forcegroupby'] = true; $sopt[10015]['massiveaction'] = false; - $sopt[10015]['joinparams'] = array('jointype' => 'child'); + $sopt[10015]['joinparams'] = ['jointype' => 'child']; $sopt[10016]['table'] = 'glpi_plugin_ocsinventoryng_services'; $sopt[10016]['field'] = 'svcname'; $sopt[10016]['name'] = __('OCSNG', 'ocsinventoryng') . " - " . __('Name of the service', 'ocsinventoryng'); $sopt[10016]['forcegroupby'] = true; $sopt[10016]['massiveaction'] = false; - $sopt[10016]['joinparams'] = array('jointype' => 'child'); + $sopt[10016]['joinparams'] = ['jointype' => 'child']; $sopt[10017]['table'] = 'glpi_plugin_ocsinventoryng_runningprocesses'; $sopt[10017]['field'] = 'processname'; $sopt[10017]['name'] = __('OCSNG', 'ocsinventoryng') . " - " . __('Process name', 'ocsinventoryng'); $sopt[10017]['forcegroupby'] = true; $sopt[10017]['massiveaction'] = false; - $sopt[10017]['joinparams'] = array('jointype' => 'child'); + $sopt[10017]['joinparams'] = ['jointype' => 'child']; } } if (in_array($itemtype, PluginOcsinventoryngSnmpOcslink::$snmptypes)) { @@ -1741,7 +1727,7 @@ function plugin_ocsinventoryng_getAddSearchOptions($itemtype) { $sopt[10013]['name'] = __('OCSNG', 'ocsinventoryng')." - ".__('SNMP Import', 'ocsinventoryng') . " - " . __('GLPI import date', 'ocsinventoryng'); $sopt[10013]['datatype'] = 'datetime'; $sopt[10013]['massiveaction'] = false; - $sopt[10013]['joinparams'] = array('jointype' => 'itemtype_item'); + $sopt[10013]['joinparams'] = ['jointype' => 'itemtype_item']; } } } @@ -1877,7 +1863,7 @@ function plugin_ocsinventoryng_giveItem($type, $id, $data, $num) { * * @return bool */ -function plugin_ocsinventoryng_searchOptionsValues($params = array()) { +function plugin_ocsinventoryng_searchOptionsValues($params = []) { switch ($params['searchoption']['field']) { case "action": @@ -1897,7 +1883,7 @@ function plugin_ocsinventoryng_searchOptionsValues($params = array()) { * @return an array of criteria */ function plugin_ocsinventoryng_getRuleCriteria($params) { - $criteria = array(); + $criteria = []; switch ($params['rule_itemtype']) { case 'RuleImportEntity': @@ -1976,13 +1962,13 @@ function plugin_ocsinventoryng_getRuleCriteria($params) { */ function plugin_ocsinventoryng_getRuleActions($params) { // - $actions = array(); + $actions = []; switch ($params['rule_itemtype']) { case 'RuleImportEntity': $actions['_affect_entity_by_tag']['name'] = __('Entity from TAG'); $actions['_affect_entity_by_tag']['type'] = 'text'; - $actions['_affect_entity_by_tag']['force_actions'] = array('regex_result'); + $actions['_affect_entity_by_tag']['force_actions'] = ['regex_result']; /*$actions['locations_id']['name'] = __('Location'); $actions['locations_id']['type'] = 'dropdown'; @@ -2018,10 +2004,10 @@ function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params) $ocsservers_id = $params['values']['params']['plugin_ocsinventoryng_ocsservers_id']; } - $rule_parameters = array( + $rule_parameters = [ 'ocsservers_id' => $ocsservers_id, 'OCS_SERVER' => $ocsservers_id - ); + ]; if (isset($params['values']['params']['ocsid'])) { $ocsid = $params['values']['params']['ocsid']; @@ -2055,7 +2041,7 @@ function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params) } } } - $ocs_data = array(); + $ocs_data = []; foreach ($fields as $field) { // TODO cleaner way of getting fields @@ -2070,7 +2056,7 @@ function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params) $ocsField = $fieldSql[0]; $glpiField = $fieldSql[count($fieldSql) - 1]; - $section = array(); + $section = []; if (isset($ocsComputer[$table])) { $section = $ocsComputer[$table]; } @@ -2095,7 +2081,7 @@ function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params) } } - return array(); + return []; } /** @@ -2192,7 +2178,7 @@ function plugin_ocsinventoryng_preProcessRulePreviewResults($params) { $item = new Computer; if ($item->getFromDB($output["found_computers"][0])) { echo "" . __('Link with computer', 'ocsinventoryng') . ""; - echo "" . $item->getLink(array('comments' => true)) . ""; + echo "" . $item->getLink(['comments' => true]) . ""; } echo ""; } @@ -2222,8 +2208,8 @@ function plugin_ocsinventoryng_preProcessRuleCollectionPreviewResults($params) { **/ function plugin_ocsinventoryng_getTablesForQuery($rule_itemtype) { - $tables = array(); - $crits = plugin_ocsinventoryng_getRuleCriteria(array('rule_itemtype' => $rule_itemtype)); + $tables = []; + $crits = plugin_ocsinventoryng_getRuleCriteria(['rule_itemtype' => $rule_itemtype]); foreach ($crits as $criteria) { if ((!isset($criteria['virtual']) @@ -2248,8 +2234,8 @@ function plugin_ocsinventoryng_getTablesForQuery($rule_itemtype) { */ function plugin_ocsinventoryng_getFieldsForQuery($rule_itemtype, $withouttable = 0) { - $fields = array(); - foreach (plugin_ocsinventoryng_getRuleCriteria(array('rule_itemtype' => $rule_itemtype)) as $key => $criteria) { + $fields = []; + foreach (plugin_ocsinventoryng_getRuleCriteria(['rule_itemtype' => $rule_itemtype]) as $key => $criteria) { if ($withouttable) { if (strcasecmp($key, $criteria['field']) != 0) { $fields[] = $key; @@ -2290,9 +2276,9 @@ function plugin_ocsinventoryng_getFieldsForQuery($rule_itemtype, $withouttable = **/ function plugin_ocsinventoryng_getFKFieldsForQuery() { - $fields = array(); - foreach (plugin_ocsinventoryng_getRuleCriteria(array('rule_itemtype' - => 'RuleImportEntity')) as $criteria) { + $fields = []; + foreach (plugin_ocsinventoryng_getRuleCriteria(['rule_itemtype' + => 'RuleImportEntity']) as $criteria) { //If the field name is not null AND a table name is provided if ((!isset($criteria['virtual']) || !$criteria['virtual']) && $criteria['linkfield'] != '' @@ -2313,7 +2299,7 @@ function plugin_ocsinventoryng_getFKFieldsForQuery() { * @return the array including plugin's criteria */ function plugin_ocsinventoryng_ruleImportComputer_addGlobalCriteria($global_criteria) { - return array_merge($global_criteria, array('IPADDRESS', 'IPSUBNET', 'MACADDRESS')); + return array_merge($global_criteria, ['IPADDRESS', 'IPSUBNET', 'MACADDRESS']); } /** @@ -2326,7 +2312,7 @@ function plugin_ocsinventoryng_ruleImportComputer_addGlobalCriteria($global_crit * @internal param necessary $params parameters to build SQL restrict requests * @since 1.0 */ -function plugin_ocsinventoryng_ruleImportComputer_getSqlRestriction($params = array()) { +function plugin_ocsinventoryng_ruleImportComputer_getSqlRestriction($params = []) { global $CFG_GLPI; // Search computer, in entity, not already linked @@ -2347,7 +2333,7 @@ function plugin_ocsinventoryng_ruleImportComputer_getSqlRestriction($params = ar case 'IPADDRESS' : $ips = $params['input']["IPADDRESS"]; if (!is_array($ips)) { - $ips = array($params['input']["IPADDRESS"]); + $ips = [$params['input']["IPADDRESS"]]; } if (count($ips)) { $needport = true; @@ -2363,7 +2349,7 @@ function plugin_ocsinventoryng_ruleImportComputer_getSqlRestriction($params = ar case 'MACADDRESS' : $macs = $params['input']["MACADDRESS"]; if (!is_array($macs)) { - $macs = array($params['input']["MACADDRESS"]); + $macs = [$params['input']["MACADDRESS"]]; } if (count($macs)) { $needport = true; @@ -2402,7 +2388,7 @@ function plugin_ocsinventoryng_ruleImportComputer_getSqlRestriction($params = ar * * @return an array */ -function plugin_ocsinventoryng_showLocksForItem($params = array()) { +function plugin_ocsinventoryng_showLocksForItem($params = []) { $comp = $params['item']; $header = $params['header']; $ID = $comp->getID(); @@ -2444,7 +2430,7 @@ function plugin_ocsinventoryng_showLocksForItem($params = array()) { * * @internal param array $_POST */ -function plugin_ocsinventoryng_unlockFields($params = array()) { +function plugin_ocsinventoryng_unlockFields($params = []) { $computer = new Computer(); $computer->check($_POST['id'], UPDATE); if (isset($_POST["lockfield"]) && count($_POST["lockfield"])) { @@ -2465,7 +2451,7 @@ function plugin_ocsinventoryng_unlockFields($params = array()) { * * @return bool */ -function plugin_ocsinventoryng_item_transfer($options = array()) { +function plugin_ocsinventoryng_item_transfer($options = []) { global $DB; if ($options['type'] == 'Computer') { @@ -2498,12 +2484,12 @@ function plugin_ocsinventoryng_migrateComputerLocks(Migration $migration) { ini_set("memory_limit", "-1"); ini_set("max_execution_time", "0"); - $import = array('import_printer' => 'Printer', + $import = ['import_printer' => 'Printer', 'import_monitor' => 'Monitor', - 'import_peripheral' => 'Peripheral'); + 'import_peripheral' => 'Peripheral']; foreach ($import as $field => $itemtype) { - foreach ($DB->request('ocs_glpi_ocslinks', array('FIELDS' => array('computers_id', $field))) as $data) { + foreach ($DB->request('ocs_glpi_ocslinks', ['FIELDS' => ['computers_id', $field]]) as $data) { if ($DB->fieldExists('ocs_glpi_ocslinks', $field)) { $import_field = importArrayFromDB($data[$field]); @@ -2520,14 +2506,14 @@ function plugin_ocsinventoryng_migrateComputerLocks(Migration $migration) { $migration->dropField('ocs_glpi_ocslinks', $field); } //Migration disks and vms - $import = array('import_disk' => 'glpi_computerdisks', + $import = ['import_disk' => 'glpi_computerdisks', 'import_vm' => 'glpi_computervirtualmachines', 'import_software' => 'glpi_computers_softwareversions', - 'import_ip' => 'glpi_networkports'); + 'import_ip' => 'glpi_networkports']; foreach ($import as $field => $table) { if ($DB->fieldExists('ocs_glpi_ocslinks', $field)) { - foreach ($DB->request('ocs_glpi_ocslinks', array('FIELDS' => array('computers_id', $field))) as $data) { + foreach ($DB->request('ocs_glpi_ocslinks', ['FIELDS' => ['computers_id', $field]]) as $data) { $import_field = importArrayFromDB($data[$field]); //If array is not empty @@ -2563,14 +2549,14 @@ function plugin_ocsinventoryng_migrateComputerLocks(Migration $migration) { } if ($DB->fieldExists('ocs_glpi_ocslinks', 'import_device')) { - foreach ($DB->request('ocs_glpi_ocslinks', array('FIELDS' => array('computers_id', 'import_device'))) + foreach ($DB->request('ocs_glpi_ocslinks', ['FIELDS' => ['computers_id', 'import_device']]) as $data) { $import_device = importArrayFromDB($data['import_device']); if (!in_array('_version_078_', $import_device)) { $import_device = plugin_ocsinventoryng_migrateImportDevice($import_device); } - $devices = array(); + $devices = []; $types = $CFG_GLPI['ocsinventoryng_devices_index']; foreach ($import_device as $key => $val) { if (!$key) { // OcsServer::IMPORT_TAG_078 @@ -2609,9 +2595,9 @@ function plugin_ocsinventoryng_migrateComputerLocks(Migration $migration) { * * @return import_device array migrated in post 0.78 scheme **/ -function plugin_ocsinventoryng_migrateImportDevice($import_device = array()) { +function plugin_ocsinventoryng_migrateImportDevice($import_device = []) { - $new_import_device = array('_version_078_'); + $new_import_device = ['_version_078_']; if (count($import_device)) { foreach ($import_device as $key => $val) { $tmp = explode('$$$$$', $val); @@ -2738,11 +2724,11 @@ function plugin_ocsinventoryng_upgrademassocsimport121to13() { $migration = new Migration(13); if ($DB->tableExists("glpi_plugin_mass_ocs_import_config")) { - $tables = array("glpi_plugin_massocsimport_servers" => "glpi_plugin_mass_ocs_import_servers", + $tables = ["glpi_plugin_massocsimport_servers" => "glpi_plugin_mass_ocs_import_servers", "glpi_plugin_massocsimport" => "glpi_plugin_mass_ocs_import", "glpi_plugin_massocsimport_config" => "glpi_plugin_mass_ocs_import_config", "glpi_plugin_massocsimport_not_imported" - => "glpi_plugin_mass_ocs_import_not_imported"); + => "glpi_plugin_mass_ocs_import_not_imported"]; foreach ($tables as $new => $old) { $migration->renameTable($old, $new); @@ -2771,12 +2757,12 @@ function plugin_ocsinventoryng_upgrademassocsimport121to13() { $DB->queryOrDie($query, "1.2.1 to 1.3 " . $DB->error()); } - $drop_fields = array(//Was not used, debug only... + $drop_fields = [//Was not used, debug only... "glpi_plugin_massocsimport_config" => "warn_if_not_imported", "glpi_plugin_massocsimport_config" => "not_imported_threshold", //Logging must always be enable ! "glpi_plugin_massocsimport_config" => "enable_logging", - "glpi_plugin_massocsimport_config" => "delete_empty_frequency"); + "glpi_plugin_massocsimport_config" => "delete_empty_frequency"]; foreach ($drop_fields as $table => $field) { $migration->dropField($table, $field); @@ -2796,7 +2782,7 @@ function plugin_ocsinventoryng_upgrademassocsimport13to14() { $migration->changeField("glpi_plugin_massocsimport_threads", "thread_id", "threadid", 'integer'); $migration->changeField("glpi_plugin_massocsimport_threads", "status", "status", 'integer'); $migration->changeField("glpi_plugin_massocsimport_threads", "ocs_server_id", "ocsservers_id", - 'integer', array('value' => 1)); + 'integer', ['value' => 1]); $migration->changeField("glpi_plugin_massocsimport_threads", "process_id", "processid", 'integer'); $migration->changeField("glpi_plugin_massocsimport_threads", "noupdate_machines_number", @@ -2804,10 +2790,9 @@ function plugin_ocsinventoryng_upgrademassocsimport13to14() { $migration->migrationOneTable("glpi_plugin_massocsimport_threads"); - $migration->addKey("glpi_plugin_massocsimport_threads", array("processid", "threadid"), + $migration->addKey("glpi_plugin_massocsimport_threads", ["processid", "threadid"], "process_thread"); - $migration->renameTable("glpi_plugin_massocsimport_config", "glpi_plugin_massocsimport_configs"); $migration->dropField("glpi_plugin_massocsimport_configs", "delete_frequency"); @@ -2818,16 +2803,15 @@ function plugin_ocsinventoryng_upgrademassocsimport13to14() { $migration->changeField("glpi_plugin_massocsimport_configs", "ID", "id", 'autoincrement'); $migration->changeField("glpi_plugin_massocsimport_configs", "thread_log_frequency", - "thread_log_frequency", 'integer', array('value' => 10)); + "thread_log_frequency", 'integer', ['value' => 10]); $migration->changeField("glpi_plugin_massocsimport_configs", "display_empty", "is_displayempty", 'int(1) NOT NULL default 1'); $migration->changeField("glpi_plugin_massocsimport_configs", "default_ocs_server", - "ocsservers_id", 'integer', array('value' => -1)); + "ocsservers_id", 'integer', ['value' => -1]); $migration->changeField("glpi_plugin_massocsimport_configs", "delay_refresh", "delay_refresh", 'integer'); $migration->changeField("glpi_plugin_massocsimport_configs", "comments", "comment", 'text'); - $migration->changeField("glpi_plugin_massocsimport_details", "ID", "id", 'autoincrement'); $migration->changeField("glpi_plugin_massocsimport_details", "process_id", "plugin_massocsimport_threads_id", 'integer'); @@ -2836,12 +2820,11 @@ function plugin_ocsinventoryng_upgrademassocsimport13to14() { $migration->changeField("glpi_plugin_massocsimport_details", "glpi_id", "computers_id", 'integer'); $migration->changeField("glpi_plugin_massocsimport_details", "ocs_server_id", - "ocsservers_id", 'integer', array('value' => 1)); + "ocsservers_id", 'integer', ['value' => 1]); $migration->migrationOneTable('glpi_plugin_massocsimport_details'); $migration->addKey("glpi_plugin_massocsimport_details", - array("plugin_massocsimport_threads_id", "threadid"), "process_thread"); - + ["plugin_massocsimport_threads_id", "threadid"], "process_thread"); $migration->renameTable("glpi_plugin_massocsimport_not_imported", "glpi_plugin_massocsimport_notimported"); @@ -2853,7 +2836,6 @@ function plugin_ocsinventoryng_upgrademassocsimport13to14() { $migration->changeField("glpi_plugin_massocsimport_notimported", "deviceid", "ocs_deviceid", 'string'); - $migration->changeField("glpi_plugin_massocsimport_servers", "ID", "id", 'autoincrement'); $migration->changeField("glpi_plugin_massocsimport_servers", "ocs_server_id", "ocsservers_id", 'integer'); @@ -2892,7 +2874,7 @@ function plugin_ocsinventoryng_upgrademassocsimport14to15() { } $migration->addField("glpi_plugin_massocsimport_notimported", "serial", 'string', - array('value' => '')); + ['value' => '']); $migration->addField("glpi_plugin_massocsimport_notimported", "comment", "TEXT NOT NULL"); $migration->addField("glpi_plugin_massocsimport_notimported", "rules_id", 'text'); $migration->addField("glpi_plugin_massocsimport_notimported", "entities_id", 'integer'); @@ -2942,4 +2924,4 @@ function plugin_ocsinventoryng_upgrademassocsimport14to15() { $DB->query($query); } $migration->executeMigration(); -} \ No newline at end of file +} diff --git a/inc/config.class.php b/inc/config.class.php index 6a5e8bac..5152ad32 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -60,7 +60,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { switch ($item->getType()) { case __CLASS__ : //If connection to the OCS DB is ok, and all rights are ok too - return array('1' => __('Check OCSNG import script', 'ocsinventoryng')); + return ['1' => __('Check OCSNG import script', 'ocsinventoryng')]; } } @@ -92,9 +92,9 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem * * @return array */ - function defineTabs($options = array()) { + function defineTabs($options = []) { - $ong = array(); + $ong = []; $this->addDefaultFormTab($ong); $this->addStandardTab(__CLASS__, $ong, $options); return $ong; @@ -152,12 +152,12 @@ function showForm() { echo ""; echo " " . __('Refresh information of a process every', 'ocsinventoryng') . " "; - Html::autocompletionTextField($this, "delay_refresh", array('size' => 5)); + Html::autocompletionTextField($this, "delay_refresh", ['size' => 5]); echo " " . _n('second', 'seconds', 2, 'ocsinventoryng') . ""; echo ""; - $this->showFormButtons(array('canedit' => $canedit, - 'candel' => false)); + $this->showFormButtons(['canedit' => $canedit, + 'candel' => false]); return true; } @@ -262,8 +262,8 @@ static function canUpdateOCS() { function showDebug() { NotificationEvent::debugEvent(new PluginOcsinventoryngNotimportedcomputer(), - array('entities_id' => 0, - 'notimported' => array())); + ['entities_id' => 0, + 'notimported' => []]); } -} \ No newline at end of file +} diff --git a/inc/dashboard.class.php b/inc/dashboard.class.php index f2e6dcee..71d97812 100644 --- a/inc/dashboard.class.php +++ b/inc/dashboard.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -33,7 +33,7 @@ */ class PluginOcsinventoryngDashboard extends CommonGLPI { - public $widgets = array(); + public $widgets = []; private $options; private $form; @@ -42,24 +42,23 @@ class PluginOcsinventoryngDashboard extends CommonGLPI { * * @param array $options */ - function __construct($options = array()) { + function __construct($options = []) { $this->options = $options; $this->interfaces = ["central"]; } function init() { - } /** * @return array */ function getWidgetsForItem() { - return array( + return [ $this->getType() . "1" => __("Last synchronization of computers by month", "ocsinventoryng") . " ", $this->getType() . "2" => __("Detail of imported computers", "ocsinventoryng") . " ", - ); + ]; } /** @@ -70,8 +69,9 @@ function getWidgetsForItem() { function getWidgetContentForItem($widgetId) { global $DB, $CFG_GLPI; - if (empty($this->form)) + if (empty($this->form)) { $this->init(); + } switch ($widgetId) { case $this->getType() . "1": @@ -249,7 +249,6 @@ function () { //$query .= getEntitiesRestrictRequest("AND", Computer::getTable()) $query .= " AND ( `glpi_plugin_fusioninventory_inventorycomputercomputers`.`last_fusioninventory_update` NOT LIKE '' )"; - $result = $DB->query($query); $nb = $DB->numrows($result); @@ -292,12 +291,12 @@ function () { $title = __("Detail of imported computers", "ocsinventoryng"); $widget->setWidgetTitle($title); - $colors = array( + $colors = [ "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", // "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", // "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5" - ); + ]; $dataPieset = json_encode($counts); $backgroundPieColor = json_encode($colors); $labelsPie = json_encode($name); @@ -372,4 +371,4 @@ function() { break; } } -} \ No newline at end of file +} diff --git a/inc/dbocs.class.php b/inc/dbocs.class.php index d5b89eeb..0d66d3e3 100644 --- a/inc/dbocs.class.php +++ b/inc/dbocs.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,8 +46,7 @@ class PluginOcsinventoryngDBocs extends DBmysql * @param $dbdefault * @internal param ID $ID of the ocs server ID */ - function __construct($dbhost, $dbuser, $dbpassword, $dbdefault) - { + function __construct($dbhost, $dbuser, $dbpassword, $dbdefault) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; @@ -56,4 +55,4 @@ function __construct($dbhost, $dbuser, $dbpassword, $dbdefault) parent::__construct(); } -} \ No newline at end of file +} diff --git a/inc/detail.class.php b/inc/detail.class.php index 17be74eb..132ca225 100644 --- a/inc/detail.class.php +++ b/inc/detail.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -38,10 +38,9 @@ class PluginOcsinventoryngDetail extends CommonDBTM /** * @return array */ - function getSearchOptions() - { + function getSearchOptions() { - $tab = array(); + $tab = []; $tab['common'] = _n('Computer not imported', 'Computers not imported', 2, 'ocsinventoryng'); @@ -101,8 +100,7 @@ function getSearchOptions() * @param $threadid * @param $threads_id **/ - function logProcessedComputer($ocsid, $ocsservers_id, $action, $threadid, $threads_id) - { + function logProcessedComputer($ocsid, $ocsservers_id, $action, $threadid, $threads_id) { $input["ocsid"] = $ocsid; if (isset($action["rule_matched"])) { @@ -135,11 +133,10 @@ function logProcessedComputer($ocsid, $ocsservers_id, $action, $threadid, $threa /** * @param $threads_id **/ - static function deleteThreadDetailsByProcessID($threads_id) - { + static function deleteThreadDetailsByProcessID($threads_id) { $temp = new self(); - $temp->deleteByCriteria(array('plugin_ocsinventoryng_threads_id' => $threads_id)); + $temp->deleteByCriteria(['plugin_ocsinventoryng_threads_id' => $threads_id]); } @@ -148,8 +145,7 @@ static function deleteThreadDetailsByProcessID($threads_id) * * @return mixed|string */ - static function giveActionNameByActionID($action) - { + static function giveActionNameByActionID($action) { $actions = self::getActions(); if (isset($actions[$action])) { @@ -162,10 +158,9 @@ static function giveActionNameByActionID($action) /** * @return array */ - static function getActions() - { + static function getActions() { - return array(PluginOcsinventoryngOcsServer::COMPUTER_FAILED_IMPORT + return [PluginOcsinventoryngOcsServer::COMPUTER_FAILED_IMPORT => _n('Computer not imported', 'Computers not imported', 2, 'ocsinventoryng'), @@ -185,7 +180,7 @@ static function getActions() => __('Computers not unique', 'ocsinventoryng'), PluginOcsinventoryngOcsServer::COMPUTER_LINK_REFUSED - => __('Import refused by rule')); + => __('Import refused by rule')]; } @@ -193,11 +188,10 @@ static function getActions() * @param $name * @param $value (default 0) **/ - static function showActions($name, $value = 0) - { + static function showActions($name, $value = 0) { $actions = self::getActions(); - Dropdown::showFromArray($name, $actions, array('value' => $value)); + Dropdown::showFromArray($name, $actions, ['value' => $value]); } -} \ No newline at end of file +} diff --git a/inc/ipdiscoverocslink.class.php b/inc/ipdiscoverocslink.class.php index e50e6715..9c0ca21f 100644 --- a/inc/ipdiscoverocslink.class.php +++ b/inc/ipdiscoverocslink.class.php @@ -38,14 +38,13 @@ class PluginOcsinventoryngIpdiscoverOcslink extends CommonDBTM { - static $hardwareItemTypes = array('Computer', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'); + static $hardwareItemTypes = ['Computer', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer']; /** * @param int $nb * @return string|translated */ - static function getTypeName($nb = 0) - { + static function getTypeName($nb = 0) { return __('IPDiscover Import', 'ocsinventoryng'); } @@ -55,8 +54,7 @@ static function getTypeName($nb = 0) * @param array|type $array * @return string $ */ - public static function parseArrayToString($array = array()) - { + public static function parseArrayToString($array = []) { $token = ""; if (sizeof($array) == 0) { return "''"; @@ -76,8 +74,7 @@ public static function parseArrayToString($array = array()) * @param type $inputs array * @param type $outputs array */ - public static function getSubnetsName($inputs, &$outputs) - { + public static function getSubnetsName($inputs, &$outputs) { foreach ($inputs as $subnets) { if (isset($subnets["NAME"])) { @@ -92,8 +89,7 @@ public static function getSubnetsName($inputs, &$outputs) * get all the subnets ID * @param type outputs array */ - public static function getAllSubnetsID(&$outputs) - { + public static function getAllSubnetsID(&$outputs) { $ocsClient = new PluginOcsinventoryngOcsServer(); $DBOCS = $ocsClient->getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"])->getDB(); $query = "SELECT `config`.`TVALUE` @@ -111,8 +107,7 @@ public static function getAllSubnetsID(&$outputs) * @param $inputs * @param $outputs */ - public static function getSubnetsID($inputs, &$outputs) - { + public static function getSubnetsID($inputs, &$outputs) { foreach ($inputs as $subnets) { if (isset($subnets["ID"])) { if ($subnets["ID"] != null @@ -128,8 +123,7 @@ public static function getSubnetsID($inputs, &$outputs) * @param $ipAdress * @return int|mixed */ - static function getSubnetIDbyIP($ipAdress) - { + static function getSubnetIDbyIP($ipAdress) { $subnet = -1; $ocsClient = new PluginOcsinventoryngOcsServer(); @@ -153,8 +147,7 @@ static function getSubnetIDbyIP($ipAdress) * @param $ipAdress * @return string */ - static function getSubnetNamebyIP($ipAdress) - { + static function getSubnetNamebyIP($ipAdress) { $name = ""; $ocsClient = new PluginOcsinventoryngOcsServer(); @@ -176,8 +169,7 @@ static function getSubnetNamebyIP($ipAdress) /** * @param $count */ - public static function countSubnetsID(&$count) - { + public static function countSubnetsID(&$count) { $ocsClient = new PluginOcsinventoryngOcsServer(); $DBOCS = $ocsClient->getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"])->getDB(); $query = "SELECT MAX(`config`.`IVALUE`) as MAX @@ -195,8 +187,7 @@ public static function countSubnetsID(&$count) * get the OCS types from DB * @param type $out array */ - public static function getOCSTypes(&$out) - { + public static function getOCSTypes(&$out) { $ocsClient = new PluginOcsinventoryngOcsServer(); $DBOCS = $ocsClient->getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"])->getDB(); $query = "SELECT `devicetype`.`id` , `devicetype`.`name` @@ -215,13 +206,12 @@ public static function getOCSTypes(&$out) * @param type $plugin_ocsinventoryng_ocsservers_id * @return array with All Subnets , Known Subnets, Unknown Subnets, knownIP, unknownIP */ - public static function getSubnets($plugin_ocsinventoryng_ocsservers_id) - { - $subnets = array(); - $unknown = array(); - $known = array(); - $unknownIP = array(); - $knownIP = array(); + public static function getSubnets($plugin_ocsinventoryng_ocsservers_id) { + $subnets = []; + $unknown = []; + $known = []; + $unknownIP = []; + $knownIP = []; //$IP = array(); $query = "SELECT DISTINCT `networks`.`IPSUBNET`,`subnet`.`NAME`,`subnet`.`ID` FROM `networks` @@ -248,11 +238,11 @@ public static function getSubnets($plugin_ocsinventoryng_ocsservers_id) $knownIP[] = $subnets[$i]["IPSUBNET"]; } } - return array("All Subnets" => $subnets, + return ["All Subnets" => $subnets, "Known Subnets" => $known, "Unknown Subnets" => $unknown, "knownIP" => $knownIP, - "unknownIP" => $unknownIP); + "unknownIP" => $unknownIP]; } @@ -263,10 +253,9 @@ public static function getSubnets($plugin_ocsinventoryng_ocsservers_id) * @param string $option * @return array */ - public static function showSubnets($plugin_ocsinventoryng_ocsservers_id, $subnets, $knownMacAdresses, $option = "") - { + public static function showSubnets($plugin_ocsinventoryng_ocsservers_id, $subnets, $knownMacAdresses, $option = "") { //this query displays all the elements on the the networks we found : - $subnetsDetails = array(); + $subnetsDetails = []; $knownNets = ""; $unknownNets = ""; $Nets = ""; @@ -285,7 +274,7 @@ public static function showSubnets($plugin_ocsinventoryng_ocsservers_id, $subnet } else { if ($option != "") { - $theSubnet = array(); + $theSubnet = []; $getKnownSubnet = "SELECT `subnet`.`NETID` FROM `subnet` WHERE `ID` LIKE '$option'"; @@ -301,7 +290,7 @@ public static function showSubnets($plugin_ocsinventoryng_ocsservers_id, $subnet } } if ($Nets == "") { - return array(); + return []; } else { $macAdresses = self::parseArrayToString($knownMacAdresses); $percentQuery = " SELECT * from (select inv.RSX as IP, inv.c as 'INVENTORIED', non_ident.c as 'NON_INVENTORIED', ipdiscover.c as 'IPDISCOVER', ident.c as 'IDENTIFIED', inv.name as 'NAME', CASE WHEN ident.c IS NULL and ipdiscover.c IS NULL THEN 100 WHEN ident.c IS NULL THEN 0 WHEN non_ident.c IS NULL THEN 0 ELSE round(100-(non_ident.c*100/(ident.c+non_ident.c)), 1) END as 'PERCENT' @@ -334,10 +323,9 @@ public static function showSubnets($plugin_ocsinventoryng_ocsservers_id, $subnet } } - static function ipDiscoverMenu() - { + static function ipDiscoverMenu() { global $CFG_GLPI, $DB; - $ocsservers = array(); + $ocsservers = []; //echo "
"; //echo ""; @@ -361,10 +349,10 @@ static function ipDiscoverMenu() foreach ($DB->request($query) as $data) { $ocsservers[] = $data['id']; } - Dropdown::show('PluginOcsinventoryngOcsServer', array("condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", + Dropdown::show('PluginOcsinventoryngOcsServer', ["condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", "value" => $_SESSION["plugin_ocsinventoryng_ocsservers_id"], "on_change" => "this.form.submit()", - "display_emptychoice" => false)); + "display_emptychoice" => false]); echo ""; echo ""; @@ -386,8 +374,7 @@ static function ipDiscoverMenu() /** * @param $action */ - static function showSubnetSearchForm($action) - { + static function showSubnetSearchForm($action) { global $CFG_GLPI; echo "
\n"; echo "" . __('Subnet') . ""; echo ""; - $tab = array('0' => Dropdown::EMPTY_VALUE, + $tab = ['0' => Dropdown::EMPTY_VALUE, '1' => __('All Subnets', 'ocsinventoryng'), '2' => __('Known Subnets', 'ocsinventoryng'), - '3' => __('Unknown Subnets', 'ocsinventoryng')); + '3' => __('Unknown Subnets', 'ocsinventoryng')]; $subnets = self::getSubnets($_SESSION["plugin_ocsinventoryng_ocsservers_id"]); self::getSubnetsID($subnets["All Subnets"], $tab); $_SESSION["subnets"] = $tab; - Dropdown::showFromArray("subnetsChoice", $tab, array("on_change" => "this.form.submit()", "display_emptychoice" => false)); + Dropdown::showFromArray("subnetsChoice", $tab, ["on_change" => "this.form.submit()", "display_emptychoice" => false]); echo ""; /*echo ""; echo " @@ -456,8 +443,7 @@ static function showSubnetSearchForm($action) * @param int $iterator * @return string */ - static function showItem($value, $linkto = "", $id = "", $type = "", $checkbox = false, $check = "", $iterator = 0) - { + static function showItem($value, $linkto = "", $id = "", $type = "", $checkbox = false, $check = "", $iterator = 0) { $out = ""; if ($checkbox) { $out .= "" . __('Check all') . @@ -510,10 +495,9 @@ static function checkBox($target) * @return array with mac addresses */ - static function getKnownMacAdresseFromGlpi() - { + static function getKnownMacAdresseFromGlpi() { global $DB; - $macAdresses = array(); + $macAdresses = []; $query = "SELECT `glpi_plugin_ocsinventoryng_ipdiscoverocslinks`.`macaddress` FROM `glpi_plugin_ocsinventoryng_ipdiscoverocslinks`"; $result = $DB->query($query); @@ -530,8 +514,7 @@ static function getKnownMacAdresseFromGlpi() * @param type $macAdresses array * @return none */ - static function deleteMACFromOCS($plugin_ocsinventoryng_ocsservers_id, $macAdresses) - { + static function deleteMACFromOCS($plugin_ocsinventoryng_ocsservers_id, $macAdresses) { $ocsClient = new PluginOcsinventoryngOcsServer(); $DBOCS = $ocsClient->getDBocs($plugin_ocsinventoryng_ocsservers_id)->getDB(); @@ -554,14 +537,13 @@ static function deleteMACFromOCS($plugin_ocsinventoryng_ocsservers_id, $macAdres * @internal param type $plugin_ocsinventoryng_ocsservers_id string * @internal param type $ids array */ - static function deleteLink($id_links) - { + static function deleteLink($id_links) { $ids = self::getMacAdressKeyVal($id_links); foreach ($ids as $key => $id) { $disc = new self(); - $disc->deleteByCriteria(array('id' => $id)); + $disc->deleteByCriteria(['id' => $id]); } } @@ -572,11 +554,12 @@ static function deleteLink($id_links) * @param $val * @return bool */ - static function findInArray($array, $key, $val) - { - foreach ($array as $item) - if (isset($item[$key]) && $item[$key] == $val) + static function findInArray($array, $key, $val) { + foreach ($array as $item) { + if (isset($item[$key]) && $item[$key] == $val) { return true; + } + } return false; } @@ -588,8 +571,7 @@ static function findInArray($array, $key, $val) * @param array|type $knownMacAdresses array * @return array */ - static function getHardware($ipAdress, $plugin_ocsinventoryng_ocsservers_id, $status, $knownMacAdresses = array()) - { + static function getHardware($ipAdress, $plugin_ocsinventoryng_ocsservers_id, $status, $knownMacAdresses = []) { global $DB; $ocsClient = new PluginOcsinventoryngOcsServer(); @@ -636,7 +618,7 @@ static function getHardware($ipAdress, $plugin_ocsinventoryng_ocsservers_id, $st } if ($status == "imported") { $result = $DB->query($query); - $hardware = array(); + $hardware = []; while ($res = $DBOCS->fetch_assoc($result)) { if (!isset($res["mac"])) { $hardware[] = $res; @@ -646,7 +628,7 @@ static function getHardware($ipAdress, $plugin_ocsinventoryng_ocsservers_id, $st } } else { $result = $DBOCS->query($query); - $hardware = array(); + $hardware = []; while ($res = $DBOCS->fetch_assoc($result)) { if (!isset($res["mac"])) { @@ -662,11 +644,10 @@ static function getHardware($ipAdress, $plugin_ocsinventoryng_ocsservers_id, $st /** * this function load in memory the mac address constructor */ - static function loadMacConstructor() - { + static function loadMacConstructor() { $macFile = GLPI_ROOT . "/plugins/ocsinventoryng/files/macManufacturers.txt"; $result = ""; - $macs = array(); + $macs = []; if ($file = @fopen($macFile, "r")) { while (!feof($file)) { $line = fgets($file, 4096); @@ -684,11 +665,11 @@ static function loadMacConstructor() static function getInventoriedComputers($ipAdress, $plugin_ocsinventoryng_ocsservers_id) { $ocsClient = new PluginOcsinventoryngOcsServer(); $DBOCS = $ocsClient->getDBocs($plugin_ocsinventoryng_ocsservers_id)->getDB(); - $query = " SELECT `hardware`.`lastdate`, `hardware`.`name`, `hardware`.`userid`, `hardware`.`osname`, `hardware`.`workgroup`, `hardware`.`osversion`, `hardware`.`ipaddr`, `hardware`.`userdomain` - FROM `hardware` - LEFT JOIN `networks` ON `networks`.`hardware_id`=`hardware`.`id` - WHERE `networks`.`ipsubnet`='$ipAdress' - AND status='Up' + $query = " SELECT `hardware`.`lastdate`, `hardware`.`name`, `hardware`.`userid`, `hardware`.`osname`, `hardware`.`workgroup`, `hardware`.`osversion`, `hardware`.`ipaddr`, `hardware`.`userdomain` + FROM `hardware` + LEFT JOIN `networks` ON `networks`.`hardware_id`=`hardware`.`id` + WHERE `networks`.`ipsubnet`='$ipAdress' + AND status='Up' ORDER BY `hardware`.`lastdate`"; $result = $DBOCS->query($query); $inv = array(); @@ -702,12 +683,12 @@ static function getNonInventoriedHardware($ipAdress, $plugin_ocsinventoryng_ocss $ocsClient = new PluginOcsinventoryngOcsServer(); $DBOCS = $ocsClient->getDBocs($plugin_ocsinventoryng_ocsservers_id)->getDB(); $query = " SELECT `netmap`.`ip`, `netmap`.`mac`, `netmap`.`mask`, `netmap`.`date`, `netmap`.`name` as DNS - FROM `netmap` - LEFT JOIN `networks` - ON `netmap`.`mac` =`networks`.`macaddr` - WHERE `netmap`.`netid`='$ipAdress' - AND (`networks`.`macaddr` IS NULL OR `networks`.`ipsubnet` <> `netmap`.`netid`) - AND `netmap`.`mac` NOT IN ( SELECT DISTINCT(`network_devices`.`macaddr`) + FROM `netmap` + LEFT JOIN `networks` + ON `netmap`.`mac` =`networks`.`macaddr` + WHERE `netmap`.`netid`='$ipAdress' + AND (`networks`.`macaddr` IS NULL OR `networks`.`ipsubnet` <> `netmap`.`netid`) + AND `netmap`.`mac` NOT IN ( SELECT DISTINCT(`network_devices`.`macaddr`) FROM `network_devices`) ORDER BY `netmap`.`ip`"; $result = $DBOCS->query($query); $nonInv = array(); @@ -722,9 +703,9 @@ static function getIdentifieddHardware($ipAdress, $plugin_ocsinventoryng_ocsserv $DBOCS = $ocsClient->getDBocs($plugin_ocsinventoryng_ocsservers_id)->getDB(); $query = "SELECT `network_devices`.`ID`,`network_devices`.`TYPE`,`network_devices`.`DESCRIPTION`,`network_devices`.`USER`,`netmap`.`IP`,`netmap`.`MAC`,`netmap`.`MASK`,`netmap`.`NETID`,`netmap`.`NAME`,`netmap`.`DATE` FROM `network_devices` - LEFT JOIN `netmap` - ON `network_devices`.`MACADDr`=`netmap`.`MAC` - WHERE `netmap`.`NETID`='$ipAdress' + LEFT JOIN `netmap` + ON `network_devices`.`MACADDr`=`netmap`.`MAC` + WHERE `netmap`.`NETID`='$ipAdress' ORDER BY `network_devices`.`TYPE` asc"; $result = $DBOCS->query($query); $identifiedHardware = array(); @@ -742,8 +723,7 @@ static function getIdentifieddHardware($ipAdress, $plugin_ocsinventoryng_ocsserv * @param string $action * @global type $CFG_GLPI */ - static function showSubnetsDetails($subnetsArray, $lim = 0, $start = 0, $action = "import") - { + static function showSubnetsDetails($subnetsArray, $lim = 0, $start = 0, $action = "import") { global $CFG_GLPI, $DB; $output_type = Search::HTML_OUTPUT; //0 $return = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ocsng.php"; @@ -819,8 +799,7 @@ static function showSubnetsDetails($subnetsArray, $lim = 0, $start = 0, $action * @global type $CFG_GLPI */ - static function modifyNetworkForm($ipAdress, $values = array()) - { + static function modifyNetworkForm($ipAdress, $values = []) { global $CFG_GLPI; $ocsClient = new PluginOcsinventoryngOcsServer(); $ocsdb = $ocsClient->getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"]); @@ -865,9 +844,9 @@ static function modifyNetworkForm($ipAdress, $values = array()) echo " "; echo "" . __('Choose ID', 'ocsinventoryng') . ""; echo ""; - $sbnts = array(Dropdown::EMPTY_VALUE); + $sbnts = [Dropdown::EMPTY_VALUE]; self::getAllSubnetsID($sbnts); - Dropdown::showFromArray('subnetChoice', $sbnts, array('value' => $idValue)); + Dropdown::showFromArray('subnetChoice', $sbnts, ['value' => $idValue]); echo ""; echo "" . __('IP address') . ""; @@ -884,9 +863,9 @@ static function modifyNetworkForm($ipAdress, $values = array()) echo " "; echo "" . __('Choose ID', 'ocsinventoryng') . ""; echo ""; - $sbnts = array(Dropdown::EMPTY_VALUE); + $sbnts = [Dropdown::EMPTY_VALUE]; self::getAllSubnetsID($sbnts); - Dropdown::showFromArray('subnetChoice', $sbnts, array('on_change' => 'FillInput();')); + Dropdown::showFromArray('subnetChoice', $sbnts, ['on_change' => 'FillInput();']); echo ""; echo "" . __('IP address') . ""; @@ -913,8 +892,7 @@ static function modifyNetworkForm($ipAdress, $values = array()) * @return type array with the status of the import or update process * @global type $DB */ - static function processIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocsservers_id, $subnet) - { + static function processIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocsservers_id, $subnet) { global $DB; $ocsClient = new PluginOcsinventoryngOcsServer(); $ocsClient->checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); @@ -941,8 +919,7 @@ static function processIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocs * @param $subnet * @return array */ - static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocsservers_id, $subnet) - { + static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocsservers_id, $subnet) { global $DB; $id = null; @@ -952,10 +929,10 @@ static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocss if (isset($ipDiscoveryObject["ocsItemType"]) && $ipDiscoveryObject["ocsItemType"] == Dropdown::EMPTY_VALUE ) { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT]; } if ($ipDiscoveryObject["itemDescription"] == '') { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT]; } if ($ipDiscoveryObject["itemName"] == "") { @@ -965,7 +942,7 @@ static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocss switch ($ipDiscoveryObject["glpiItemType"]) { //empty dropdown value case '0' : - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT]; } if (isset($ipDiscoveryObject["ocsItemType"])) { @@ -977,17 +954,17 @@ static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocss $netPort->getFromDBByQuery("WHERE `mac` = '$mac' "); if (count($netPort->fields) < 1) { - $input = array( + $input = [ 'is_dynamic' => 1, 'locations_id' => 0, 'domains_id' => 0, 'entities_id' => $ipDiscoveryObject["entity"], 'name' => $ipDiscoveryObject["itemName"], - 'comment' => $ipDiscoveryObject["itemDescription"]); + 'comment' => $ipDiscoveryObject["itemDescription"]]; $device = new $ipDiscoveryObject["glpiItemType"](); - $id = $device->add($input, array(), $cfg_ocs['history_devices']); + $id = $device->add($input, [], $cfg_ocs['history_devices']); //ipdiscover link $date = date("Y-m-d H:i:s"); @@ -1000,18 +977,18 @@ static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocss $DB->query($glpiQuery); //add port - $port_input = array('name' => $ipDiscoveryObject["itemName"] . "-" . $ip, + $port_input = ['name' => $ipDiscoveryObject["itemName"] . "-" . $ip, 'mac' => $mac, 'items_id' => $id, 'itemtype' => $glpiType, 'instantiation_type' => "NetworkPortEthernet", "entities_id" => $ipDiscoveryObject["entity"], - "NetworkName__ipaddresses" => array("-100" => $ip), + "NetworkName__ipaddresses" => ["-100" => $ip], '_create_children' => 1, //'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; - $netPort->add($port_input, array(), $cfg_ocs['history_network']); + $netPort->add($port_input, [], $cfg_ocs['history_network']); /* $netPortInput = array( "itemtype" => $glpiType, @@ -1064,10 +1041,10 @@ static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocss } if ($id) { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_IMPORTED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_IMPORTED]; } else { Session::addMessageAfterRedirect($mac . " : " . __('Unable to add. an object with same MAC address already exists.', 'ocsinventoryng'), false, ERROR); - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT]; } } @@ -1085,14 +1062,13 @@ static function importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocss * @return type array * @internal param type $ipDiscoveryObject array */ - static function linkIpDiscover($plugin_ocsinventoryng_ocsservers_id, $itemtypes, $items_id, $macAdresses, $ocsItemstypes, $itemsDescription, $subnet, $identify = 0) - { + static function linkIpDiscover($plugin_ocsinventoryng_ocsservers_id, $itemtypes, $items_id, $macAdresses, $ocsItemstypes, $itemsDescription, $subnet, $identify = 0) { global $DB; /*$id = null; $identify = false; - - if (isset($ipDiscoveryObject["ocsItemType"]) + + if (isset($ipDiscoveryObject["ocsItemType"]) && $ipDiscoveryObject["ocsItemType"] == Dropdown::EMPTY_VALUE) { return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_FAILED_IMPORT); } @@ -1115,14 +1091,14 @@ static function linkIpDiscover($plugin_ocsinventoryng_ocsservers_id, $itemtypes, }*/ //ipdiscover link - $objs = array(); + $objs = []; $macs = self::getMacAdressKeyVal($macAdresses); foreach ($itemtypes as $key => $type) { - $objs[$items_id[$key]] = array("itemtype" => $type, + $objs[$items_id[$key]] = ["itemtype" => $type, "mac" => $macs[$key], "description" => (isset($itemsDescription[$key]) ? $itemsDescription[$key] : 0), - "ocsType" => (isset($ocsItemstypes[$key]) ? $ocsItemstypes[$key] : 0)); + "ocsType" => (isset($ocsItemstypes[$key]) ? $ocsItemstypes[$key] : 0)]; } foreach ($objs as $id => $tab) { @@ -1133,9 +1109,9 @@ static function linkIpDiscover($plugin_ocsinventoryng_ocsservers_id, $itemtypes, VALUES('$id','" . $tab["itemtype"] . "','" . $tab["mac"] . "','$date','$subnet','$plugin_ocsinventoryng_ocsservers_id')"; $DB->query($glpiQuery); - $input = array( + $input = [ 'is_dynamic' => 1, - 'id' => $id); + 'id' => $id]; $device = new $tab["itemtype"](); $device->update($input); @@ -1163,7 +1139,6 @@ static function linkIpDiscover($plugin_ocsinventoryng_ocsservers_id, $itemtypes, } } - /*if ($id) { return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_IMPORTED); } else { @@ -1181,16 +1156,15 @@ static function linkIpDiscover($plugin_ocsinventoryng_ocsservers_id, $itemtypes, * @param type $plugin_ocsinventoryng_ocsservers_id integer * @return array */ - static function updateIpDiscover($ipDiscoveryObject, $datas, $plugin_ocsinventoryng_ocsservers_id) - { + static function updateIpDiscover($ipDiscoveryObject, $datas, $plugin_ocsinventoryng_ocsservers_id) { global $DB; $res = null; if (isset($ipDiscoveryObject["ocsItemType"]) && $ipDiscoveryObject["ocsItemType"] == Dropdown::EMPTY_VALUE) { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED]; } if ($ipDiscoveryObject["itemDescription"] == '') { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED]; } if ($ipDiscoveryObject["itemName"] == "") { @@ -1200,7 +1174,7 @@ static function updateIpDiscover($ipDiscoveryObject, $datas, $plugin_ocsinventor switch ($ipDiscoveryObject["glpiItemType"]) { //empty dropdown value case '0' : - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED]; } $itemType1 = new $ipDiscoveryObject["glpiItemType"](); @@ -1209,23 +1183,22 @@ static function updateIpDiscover($ipDiscoveryObject, $datas, $plugin_ocsinventor //same type of object //simple data update if ($itemType1 == $itemType2) { - $input = array("id" => $datas["id"], + $input = ["id" => $datas["id"], 'entities_id' => $ipDiscoveryObject["entity"], 'name' => $ipDiscoveryObject["itemName"], - 'comment' => $ipDiscoveryObject["itemDescription"]); + 'comment' => $ipDiscoveryObject["itemDescription"]]; $res = $itemType1->update($input); $date = date("Y-m-d H:i:s"); $glpiQuery = "UPDATE `glpi_plugin_ocsinventoryng_ipdiscoverocslinks` SET `last_update` = '$date'"; $DB->query($glpiQuery); - } - //not same type + } //not same type //delete old object and create a new one else { //delete old object $id = $datas["items_id"]; $mac = $datas["macaddress"]; - $result = $itemType2->delete(array("id" => $id)); + $result = $itemType2->delete(["id" => $id]); if ($result) { //delete ipdiscoverocslink @@ -1235,14 +1208,14 @@ static function updateIpDiscover($ipDiscoveryObject, $datas, $plugin_ocsinventor //add new ipdiscover object $action = self::importIpDiscover($ipDiscoveryObject, $plugin_ocsinventoryng_ocsservers_id); if ($action["status"] == 15) { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_SYNCHRONIZED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_SYNCHRONIZED]; } } } if ($res) { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_SYNCHRONIZED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_SYNCHRONIZED]; } else { - return array('status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED); + return ['status' => PluginOcsinventoryngOcsServer::IPDISCOVER_NOTUPDATED]; } } @@ -1258,27 +1231,26 @@ static function updateIpDiscover($ipDiscoveryObject, $datas, $plugin_ocsinventor * @return array */ - static function getIpDiscoverobject($macAdresses, $entities = array(), $glpiItemsTypes, $itemsNames = "", $itemsDescription, $itempsIp, $ocsItemsTypes = array()) - { - $objectToImport = array(); + static function getIpDiscoverobject($macAdresses, $entities = [], $glpiItemsTypes, $itemsNames = "", $itemsDescription, $itempsIp, $ocsItemsTypes = []) { + $objectToImport = []; $macs = self::getMacAdressKeyVal($macAdresses); if (!empty($entities)) { foreach ($macs as $key => $mac) { if (!empty($ocsItemsTypes)) { - $objectToImport[] = array("macAdress" => $mac, + $objectToImport[] = ["macAdress" => $mac, "entity" => $entities[$key], "glpiItemType" => $glpiItemsTypes[$key], "ocsItemType" => $ocsItemsTypes[$key], "itemName" => $itemsNames[$key], "itemDescription" => $itemsDescription[$key], - "itemIp" => $itempsIp[$key]); + "itemIp" => $itempsIp[$key]]; } else { - $objectToImport[] = array("macAdress" => $mac, + $objectToImport[] = ["macAdress" => $mac, "entity" => $entities[$key], "glpiItemType" => $glpiItemsTypes[$key], "itemName" => $itemsNames[$key], "itemDescription" => $itemsDescription[$key], - "itemIp" => $itempsIp[$key]); + "itemIp" => $itempsIp[$key]]; } } } else { @@ -1288,20 +1260,20 @@ static function getIpDiscoverobject($macAdresses, $entities = array(), $glpiItem $ent = $eval; } if (!empty($ocsItemsTypes)) { - $objectToImport[] = array("macAdress" => $mac, + $objectToImport[] = ["macAdress" => $mac, "entity" => $ent, "glpiItemType" => $glpiItemsTypes[$key], "ocsItemType" => $ocsItemsTypes[$key], "itemName" => $itemsNames[$key], "itemDescription" => $itemsDescription[$key], - "itemIp" => $itempsIp[$key]); + "itemIp" => $itempsIp[$key]]; } else { - $objectToImport[] = array("macAdress" => $mac, + $objectToImport[] = ["macAdress" => $mac, "entity" => $ent, "glpiItemType" => $glpiItemsTypes[$key], "itemName" => $itemsNames[$key], "itemDescription" => $itemsDescription[$key], - "itemIp" => $itempsIp[$key]); + "itemIp" => $itempsIp[$key]]; } } } @@ -1312,8 +1284,7 @@ static function getIpDiscoverobject($macAdresses, $entities = array(), $glpiItem * @param $status * @return string */ - static function showPercentBar($status) - { + static function showPercentBar($status) { if (!is_numeric($status)) { return $status; } @@ -1337,8 +1308,7 @@ static function showPercentBar($status) * @param $action * @global type $CFG_GLPI */ - static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $subnet, $action) - { + static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $subnet, $action) { global $CFG_GLPI, $DB; $output_type = Search::HTML_OUTPUT; //0 @@ -1350,9 +1320,9 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s if ($status == "inventoried") { $status_name = __('Inventoried', 'ocsinventoryng'); - } elseif ($status == "imported") { + } else if ($status == "imported") { $status_name = __('Imported / Linked', 'ocsinventoryng'); - } elseif ($status == "noninventoried") { + } else if ($status == "noninventoried") { $status_name = __('Non Inventoried', 'ocsinventoryng'); } else { $status_name = __('Identified', 'ocsinventoryng'); @@ -1363,7 +1333,7 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s echo "

" . __('Subnet') . " " . $subnet_name . " (" . $ipAdress . ") - " . $status_name; echo " "; $refresh = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php?" . $reload; - Html::showSimpleForm($refresh, 'refresh', _sx('button', 'Refresh'), array(), $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/pics/synchro.png"); + Html::showSimpleForm($refresh, 'refresh', _sx('button', 'Refresh'), [], $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/pics/synchro.png"); echo "

"; echo "
"; @@ -1437,12 +1407,12 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s $iplist = ""; $ip = new IPAddress(); // Update IPAddress - foreach ($DB->request('glpi_networkports', array('itemtype' => $hardware[$i]["itemtype"], - 'items_id' => $hardware[$i]["items_id"])) as $netname) { - foreach ($DB->request('glpi_networknames', array('itemtype' => 'NetworkPort', - 'items_id' => $netname['id'])) as $dataname) { - foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', - 'items_id' => $dataname['id'])) as $data) { + foreach ($DB->request('glpi_networkports', ['itemtype' => $hardware[$i]["itemtype"], + 'items_id' => $hardware[$i]["items_id"]]) as $netname) { + foreach ($DB->request('glpi_networknames', ['itemtype' => 'NetworkPort', + 'items_id' => $netname['id']]) as $dataname) { + foreach ($DB->request('glpi_ipaddresses', ['itemtype' => 'NetworkName', + 'items_id' => $dataname['id']]) as $data) { $ip->getFromDB($data['id']); $iplist .= $ip->getName() . "
"; } @@ -1471,7 +1441,7 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s break; case "noninventoried" : - $ocsTypes = array("id" => array(Dropdown::EMPTY_VALUE), "name" => array(Dropdown::EMPTY_VALUE)); + $ocsTypes = ["id" => [Dropdown::EMPTY_VALUE], "name" => [Dropdown::EMPTY_VALUE]]; $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; $macConstructor = ""; @@ -1508,11 +1478,11 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; - $ocstypes = array(); + $ocstypes = []; foreach ($ocsTypes["name"] as $items) { $ocstypes[$items] = $items; } - $itemstypes = array(Dropdown::EMPTY_VALUE); + $itemstypes = [Dropdown::EMPTY_VALUE]; foreach (self::$hardwareItemTypes as $items) { $class = getItemForItemtype($items); $itemstypes[$items] = $class->getTypeName(); @@ -1546,7 +1516,7 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s echo ""; if (Session::isMultiEntitiesMode()) { echo ""; - Entity::dropdown(array('name' => "entities[$i]", 'entity' => $_SESSION["glpiactiveentities"])); + Entity::dropdown(['name' => "entities[$i]", 'entity' => $_SESSION["glpiactiveentities"]]); echo ""; } @@ -1561,14 +1531,13 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s $mynamei = "itemtype"; $myname = "tolink_items[" . $i . "]"; - $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand)); + $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, ['rand' => $mtrand]); - - $p = array('itemtype' => '__VALUE__', + $p = ['itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, - 'myname' => $myname); + 'myname' => $myname]; //print_r($p); Ajax::updateItemOnSelectEvent("dropdown_$mynamei$rand", "results_$mynamei$rand", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "\n"; @@ -1632,7 +1601,7 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; - $itemstypes = array(Dropdown::EMPTY_VALUE); + $itemstypes = [Dropdown::EMPTY_VALUE]; foreach (self::$hardwareItemTypes as $items) { $class = getItemForItemtype($items); $itemstypes[$items] = $class->getTypeName(); @@ -1660,7 +1629,7 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s if ($action == "import") { if (Session::isMultiEntitiesMode()) { echo ""; - Entity::dropdown(array('name' => "entities[$i]", 'entity' => $_SESSION["glpiactiveentities"])); + Entity::dropdown(['name' => "entities[$i]", 'entity' => $_SESSION["glpiactiveentities"]]); echo ""; } @@ -1676,14 +1645,13 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s $mynamei = "itemtype"; $myname = "tolink_items[" . $i . "]"; - $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand)); - + $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, ['rand' => $mtrand]); - $p = array('itemtype' => '__VALUE__', + $p = ['itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, - 'myname' => $myname); + 'myname' => $myname]; Ajax::updateItemOnSelectEvent("dropdown_$mynamei$rand", "results_$mynamei$rand", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "\n"; @@ -1726,9 +1694,8 @@ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $s * @param $macAdresses * @return array with the keys(positions) */ - static function getMacAdressKeyVal($macAdresses) - { - $keys = array(); + static function getMacAdressKeyVal($macAdresses) { + $keys = []; foreach ($macAdresses as $key => $val) { foreach ($val as $mac => $on) { $keys[$key] = $mac; @@ -1737,4 +1704,4 @@ static function getMacAdressKeyVal($macAdresses) return $keys; } -} \ No newline at end of file +} diff --git a/inc/menu.class.php b/inc/menu.class.php index 218ced4f..dfc710b0 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -50,7 +50,7 @@ static function getMenuName() { */ static function getMenuContent() { - $menu = array(); + $menu = []; $menu['title'] = self::getMenuName(); $menu['page'] = "/plugins/ocsinventoryng/front/ocsng.php"; $menu['links']['search'] = "/plugins/ocsinventoryng/front/ocsng.php"; @@ -69,7 +69,6 @@ static function getMenuContent() { $menu['options']['ocsserver']['links']['add'] = '/plugins/ocsinventoryng/front/ocsserver.form.php'; $menu['options']['ocsserver']['links']['search'] = '/plugins/ocsinventoryng/front/ocsserver.php'; - // Import $menu['options']['import']['title'] = __s('Import new computers', 'ocsinventoryng'); $menu['options']['import']['page'] = '/plugins/ocsinventoryng/front/ocsng.import.php'; @@ -166,7 +165,6 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $ong[2] = __('IPDiscover Import', 'ocsinventoryng'); - //if (isset($_POST["plugin_ocsinventoryng_ocsservers_id"])) { // $_SESSION["plugin_ocsinventoryng_ocsservers_id"] = $_POST["plugin_ocsinventoryng_ocsservers_id"]; //} else { @@ -188,9 +186,9 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { } } } else { - $ong = array(); + $ong = []; echo "
"; - echo Html::image($CFG_GLPI["root_doc"] . "/pics/warning.png", array('alt' => __('Warning'))); + echo Html::image($CFG_GLPI["root_doc"] . "/pics/warning.png", ['alt' => __('Warning')]); echo "
"; echo "
"; echo __('No OCSNG server defined', 'ocsinventoryng'); @@ -248,9 +246,9 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 0, $withtem * * @return array */ - function defineTabs($options = array()) { + function defineTabs($options = []) { - $ong = array(); + $ong = []; $this->addStandardTab(__CLASS__, $ong, $options); diff --git a/inc/ministat.class.php b/inc/ministat.class.php index 3edcfeed..8eeb4572 100644 --- a/inc/ministat.class.php +++ b/inc/ministat.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -54,56 +54,49 @@ class PluginOcsinventoryngMiniStat /** * */ - function Reset() - { + function Reset() { $this->Min = $this->Max = $this->Tot = $this->Nb = 0; } /** * @return int */ - function GetMinimum() - { + function GetMinimum() { return $this->Min; } /** * @return int */ - function GetMaximum() - { + function GetMaximum() { return $this->Max; } /** * @return int */ - function GetTotal() - { + function GetTotal() { return $this->Tot; } /** * @return int */ - function GetCount() - { + function GetCount() { return $this->Nb; } /** * @return float|int */ - function GetAverage() - { + function GetAverage() { return $this->Nb > 0 ? $this->Tot / $this->Nb : 0; } /** * @param $Value */ - function AddValue($Value) - { + function AddValue($Value) { if ($this->Nb > 0) { if ($Value < $this->Min) { @@ -120,4 +113,4 @@ function AddValue($Value) } } -} \ No newline at end of file +} diff --git a/inc/networkport.class.php b/inc/networkport.class.php index e1e372ee..a8643c00 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -91,7 +91,7 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia $ports = $DB->request($query); if ($ports->numrows() == 0) { - $port_input = array('name' => $name, + $port_input = ['name' => $name, 'mac' => $mac, 'items_id' => $computers_id, 'itemtype' => 'Computer', @@ -99,9 +99,9 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia 'instantiation_type' => $instantiation_type, '_create_children' => 1, 'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; - $networkports_id = $network_port->add($port_input, array(), $dohistory); + $networkports_id = $network_port->add($port_input, [], $dohistory); if ($networkports_id === false) { return -1; } @@ -115,9 +115,9 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia $networkports_id = $line['id']; $network_port->getFromDB($networkports_id); if ((!$check_name) && ($network_port->fields['name'] != $name)) { - $port_input = array('id' => $network_port->getID(), + $port_input = ['id' => $network_port->getID(), 'name' => $name, - 'is_dynamic' => 1); + 'is_dynamic' => 1]; $network_port->update($port_input); } if (($network_port->fields['instantiation_type'] != $instantiation_type) @@ -156,12 +156,12 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia } else { $names = $DB->request($query); if ($names->numrows() == 0) { - $name_input = array('itemtype' => 'NetworkPort', + $name_input = ['itemtype' => 'NetworkPort', 'items_id' => $networkports_id, 'is_dynamic' => 1, 'is_deleted' => 0, '_no_history' => !$dohistory, - 'name' => 'OCS-INVENTORY-NG'); + 'name' => 'OCS-INVENTORY-NG']; $networknames_id = $network_name->add($name_input); } else { $line = $names->next(); @@ -174,7 +174,7 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia } $ip_address = new IPAddress(); - $already_known_addresses = array(); + $already_known_addresses = []; $query = "SELECT `id`, `name`, `is_dynamic`, `mainitems_id` FROM `glpi_ipaddresses` WHERE `itemtype` = 'NetworkName' @@ -184,8 +184,8 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia if (in_array($line['name'], $ips) && !empty($line['mainitems_id'])) { $already_known_addresses[] = $line['id']; - $ips = array_diff($ips, array($line['name'])); - } elseif ($line['is_dynamic'] == 1) { + $ips = array_diff($ips, [$line['name']]); + } else if ($line['is_dynamic'] == 1) { $ip_address->delete($line, true, $dohistory); } } @@ -202,7 +202,7 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia AND `gateway`='" . $gateway . "' AND `entities_id`='" . $entities_id . "'") == 0) { - $input = array( + $input = [ 'name' => $subnet . '/' . $mask . ' - ' . $gateway, @@ -211,21 +211,21 @@ static private function updateNetworkPort($mac, $name, $computers_id, $instantia 'gateway' => $gateway, 'addressable' => 1, 'entities_id' => $entities_id - ); + ]; $IPNetwork->networkUpdate = true; - $IPNetwork->add($input, array(), !$dohistory); + $IPNetwork->add($input, [], !$dohistory); } } if ($ips) { foreach ($ips as $ip) { - $ip_input = array('name' => $ip, + $ip_input = ['name' => $ip, 'itemtype' => 'NetworkName', 'items_id' => $networknames_id, '_no_history' => !$dohistory, 'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; $ip_address->add($ip_input); } } @@ -245,26 +245,26 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i // Group by DESCRIPTION, MACADDR, TYPE, TYPEMIB, SPEED, VIRTUALDEV // to get an array in IPADDRESS - $ocsNetworks = array(); + $ocsNetworks = []; foreach ($ocsComputer as $ocsNetwork) { $key = $ocsNetwork['DESCRIPTION'] . $ocsNetwork['MACADDR'] . $ocsNetwork['TYPE'] . $ocsNetwork['TYPEMIB'] . $ocsNetwork['SPEED'] . $ocsNetwork['VIRTUALDEV']; if (!isset($ocsNetworks[$key])) { $ocsNetworks[$key] = $ocsNetwork; - $ocsNetworks[$key]['IPADDRESS'] = array($ocsNetwork['IPADDRESS']); + $ocsNetworks[$key]['IPADDRESS'] = [$ocsNetwork['IPADDRESS']]; } else { $ocsNetworks[$key]['IPADDRESS'] [] = $ocsNetwork['IPADDRESS']; } } - $network_ports = array(); - $network_ifaces = array(); + $network_ports = []; + $network_ifaces = []; foreach ($ocsNetworks as $line) { $line = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line)); $mac = $line['MACADDR']; if (!isset($network_ports[$mac])) { - $network_ports[$mac] = array('virtual' => array()); + $network_ports[$mac] = ['virtual' => []]; } $name = PluginOcsinventoryngOcsServer::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $line['DESCRIPTION']); @@ -281,10 +281,10 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i $networkport_type->fields['speed'] = $speed; } - $values = array('name' => $name, + $values = ['name' => $name, 'type' => (array_push($network_ifaces, $networkport_type) - 1), 'ip' => $ip, - 'result' => $line); + 'result' => $line]; // Virtual dev can be : // 1°) specifically defined from OCS @@ -299,8 +299,8 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i } } - $already_known_ports = array(); - $already_known_ifaces = array(); + $already_known_ports = []; + $already_known_ifaces = []; foreach ($network_ports as $mac => $ports) { if (isset($ports['main'])) { $main = $ports['main']; @@ -318,21 +318,21 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i // If not found, then, create it if ($item_device->isNewItem()) { $deviceNetworkCard = new DeviceNetworkCard(); - $device_input = array('designation' => $main['name'], + $device_input = ['designation' => $main['name'], 'bandwidth' => $type->fields['speed'], - 'entities_id' => $entities_id); + 'entities_id' => $entities_id]; $net_id = $deviceNetworkCard->import($device_input); if ($net_id) { - $item_device->add(array('items_id' => $computers_id, + $item_device->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicenetworkcards_id' => $net_id, 'mac' => $mac, '_no_history' => !$cfg_ocs['history_network'], 'is_dynamic' => 1, - 'is_deleted' => 0)); + 'is_deleted' => 0]); } } if (!$item_device->isNewItem()) { @@ -341,13 +341,13 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i if ($type->fields['instantiation_type'] == __CLASS__) { $result = $main['result']; - $inst_input = array('TYPE' => $result['TYPE'], + $inst_input = ['TYPE' => $result['TYPE'], 'TYPEMIB' => $result['TYPEMIB'], - 'speed' => $result['SPEED']); + 'speed' => $result['SPEED']]; } else { $inst_input = $type->fields; - foreach (array('id', 'name', 'OCS_TYPE', 'OCS_TYPEMIB', - 'instantiation_type', 'comment') as $field) { + foreach (['id', 'name', 'OCS_TYPE', 'OCS_TYPEMIB', + 'instantiation_type', 'comment'] as $field) { unset($inst_input[$field]); } } @@ -377,7 +377,7 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i $gateway = $port['result']['IPGATEWAY']; $subnet = $port['result']['IPSUBNET']; - $inst_input = array('networkports_id_alias' => $networkports_id); + $inst_input = ['networkports_id_alias' => $networkports_id]; $id = self::updateNetworkPort($mac, $port['name'], $computers_id, 'NetworkPortAlias', $inst_input, $port['ip'], true, $cfg_ocs['history_network'], $already_known_ports, $mask, $gateway, $subnet, $entities_id); @@ -420,7 +420,7 @@ static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_i * @param array $options * @param list $recursiveItems */ - function showInstantiationForm(NetworkPort $netport, $options = array(), $recursiveItems) { + function showInstantiationForm(NetworkPort $netport, $options = [], $recursiveItems) { if (!$options['several']) { echo "\n"; @@ -456,11 +456,11 @@ function showInstantiationForm(NetworkPort $netport, $options = array(), $recurs * @return null|the */ function getInstantiationHTMLTableHeaders(HTMLTableGroup $group, HTMLTableSuperHeader $super, - HTMLTableSuperHeader $internet_super = NULL, - HTMLTableHeader $father = NULL, - array $options = array()) { + HTMLTableSuperHeader $internet_super = null, + HTMLTableHeader $father = null, + array $options = []) { - DeviceNetworkCard::getHTMLTableHeader('NetworkPortWifi', $group, $super, NULL, + DeviceNetworkCard::getHTMLTableHeader('NetworkPortWifi', $group, $super, null, $options); $group->addHeader('TYPE', __('OCS TYPE', 'ocsinventoryng'), $super); @@ -468,7 +468,7 @@ function getInstantiationHTMLTableHeaders(HTMLTableGroup $group, HTMLTableSuperH $group->addHeader('Generate', __('Create a mapping', 'ocsinventoryng'), $super); parent::getInstantiationHTMLTableHeaders($group, $super, $internet_super, $father, $options); - return NULL; + return null; } @@ -483,9 +483,9 @@ function getInstantiationHTMLTableHeaders(HTMLTableGroup $group, HTMLTableSuperH * @return null|the */ function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, - HTMLTableCell $father = NULL, array $options = array()) { + HTMLTableCell $father = null, array $options = []) { - DeviceNetworkCard::getHTMLTableCellsForItem($row, $this, NULL, $options); + DeviceNetworkCard::getHTMLTableCellsForItem($row, $this, null, $options); $row->addCell($row->getHeaderByName('Instantiation', 'TYPE'), $this->fields['TYPE']); $row->addCell($row->getHeaderByName('Instantiation', 'TYPEMIB'), $this->fields['TYPEMIB']); @@ -494,7 +494,7 @@ function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, $row->addCell($row->getHeaderByName('Instantiation', 'Generate'), $value); parent::getInstantiationHTMLTable($netport, $row, $father, $options); - return NULL; + return null; } @@ -513,7 +513,7 @@ function transformAccordingTypes() { $instantiation = $networkport->getInstantiation(); $input2 = $networkport_type->fields; unset($input2['id']); - foreach (array('networkports_id', 'items_devicenetworkcards_id') as $field) { + foreach (['networkports_id', 'items_devicenetworkcards_id'] as $field) { if (isset($this->fields[$field])) { $input2[$field] = $this->fields[$field]; } @@ -523,7 +523,7 @@ function transformAccordingTypes() { ['speed'], false); } if ($instantiation->add($input2)) { - $this->delete(array(static::getIndexName() => $this->getID())); + $this->delete([static::getIndexName() => $this->getID()]); return true; } } @@ -563,18 +563,18 @@ static function displayInvalidList() { echo ""; echo "" . self::getTextualType($type['TYPE']) . ""; - $first = True; + $first = true; foreach ($typemib_results as $typemib) { if (!$first) { echo ""; } else { - $first = False; + $first = false; } echo "" . self::getTextualType($typemib['TYPEMIB']) . ""; // Normalize speeds ... - $speeds = array(); + $speeds = []; foreach (explode('#', $typemib['speed']) as $speed) { $speed = NetworkPortEthernet::transformPortSpeed($speed, false); if (($speed !== false) and (!in_array($speed, $speeds))) { @@ -582,7 +582,7 @@ static function displayInvalidList() { } } asort($speeds); - $printable_speeds = array(); + $printable_speeds = []; foreach ($speeds as $speed) { $printable_speeds[] = NetworkPortEthernet::transformPortSpeed($speed, true); } @@ -612,7 +612,7 @@ static function displayInvalidList() { * * @return an */ - function getSpecificMassiveActions($checkitem = NULL) { + function getSpecificMassiveActions($checkitem = null) { $actions = parent::getSpecificMassiveActions($checkitem); @@ -643,7 +643,7 @@ static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { case 'plugin_ocsinventoryng_update_networkport_type': echo " " . - Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; } return parent::showMassiveActionsSubForm($ma); @@ -684,4 +684,4 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); } -} \ No newline at end of file +} diff --git a/inc/networkporttype.class.php b/inc/networkporttype.class.php index 5204629e..9155919e 100644 --- a/inc/networkporttype.class.php +++ b/inc/networkporttype.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -44,8 +44,7 @@ class PluginOcsinventoryngNetworkPortType extends CommonDropdown * @param int $nb * @return translated */ - static function getTypeName($nb = 0) - { + static function getTypeName($nb = 0) { return _n('Network port type', 'Network port types', $nb, 'ocsinventoryng'); } @@ -53,8 +52,7 @@ static function getTypeName($nb = 0) /** * @return bool|booleen */ - function canUpdateItem() - { + function canUpdateItem() { if ((isset($this->fields['OCS_TYPE'])) && ($this->fields['OCS_TYPE'] == '*') && (isset($this->fields['OCS_TYPEMIB'])) && ($this->fields['OCS_TYPEMIB'] == '*') ) { @@ -67,8 +65,7 @@ function canUpdateItem() /** * @return bool|booleen */ - function canDeleteItem() - { + function canDeleteItem() { if ((isset($this->fields['OCS_TYPE'])) && ($this->fields['OCS_TYPE'] == '*') && (isset($this->fields['OCS_TYPEMIB'])) && ($this->fields['OCS_TYPEMIB'] == '*') ) { @@ -82,8 +79,7 @@ function canDeleteItem() /** * */ - function post_addItem() - { + function post_addItem() { global $DB; if (isset($this->input['transform_unknown_ports_that_match']) && @@ -109,19 +105,18 @@ function post_addItem() * @param $ID * @param array $field */ - function displaySpecificTypeField($ID, $field = array()) - { + function displaySpecificTypeField($ID, $field = []) { switch ($field['type']) { case 'instantiation_type' : Dropdown::showFromArray($field['name'], NetworkPort::getNetworkPortInstantiationsWithNames(), - array('value' => $this->fields[$field['name']])); + ['value' => $this->fields[$field['name']]]); break; case 'type' : Dropdown::showFromArray('type', NetworkPortEthernet::getPortTypeName(), - array('value' => $this->fields[$field['name']])); + ['value' => $this->fields[$field['name']]]); break; case 'readonly_text' : $value = $this->fields[$field['name']]; @@ -131,9 +126,9 @@ function displaySpecificTypeField($ID, $field = array()) case 'MIB or wildcard': $name = $field['name']; $value = $this->fields[$name]; - $values = array($value => $value, - '*' => __('Any kind', 'ocsinventoryng')); - Dropdown::showFromArray($name, $values, array('value' => $value)); + $values = [$value => $value, + '*' => __('Any kind', 'ocsinventoryng')]; + Dropdown::showFromArray($name, $values, ['value' => $value]); break; case 'speed' : $standard_speeds = NetworkPortEthernet::getPortSpeed(); @@ -145,13 +140,13 @@ function displaySpecificTypeField($ID, $field = array()) $speed = true; } Dropdown::showFromArray('speed', $standard_speeds, - array('value' => $this->fields['speed'], - 'other' => $speed)); + ['value' => $this->fields['speed'], + 'other' => $speed]); break; case 'version' : Dropdown::showFromArray('version', WifiNetwork::getWifiCardVersion(), - array('value' => $this->fields['version'])); + ['value' => $this->fields['version']]); break; } @@ -161,33 +156,32 @@ function displaySpecificTypeField($ID, $field = array()) /** * @return array */ - function getAdditionalFields() - { + function getAdditionalFields() { - $result = array('TYPE' => array('name' => 'OCS_TYPE', + $result = ['TYPE' => ['name' => 'OCS_TYPE', 'label' => __('OCS TYPE', 'ocsinventoryng'), - 'type' => 'text'), - 'TYPEMIB' => array('name' => 'OCS_TYPEMIB', + 'type' => 'text'], + 'TYPEMIB' => ['name' => 'OCS_TYPEMIB', 'label' => __('OCS TYPE MIB', 'ocsinventoryng'), - 'type' => 'text'), - array('name' => 'instantiation_type', + 'type' => 'text'], + ['name' => 'instantiation_type', 'label' => __('Corresponding Network Port type', 'ocsinventoryng'), - 'type' => 'instantiation_type'), - array('name' => 'type', + 'type' => 'instantiation_type'], + ['name' => 'type', 'label' => __('Ethernet medium type', 'ocsinventoryng'), - 'type' => 'type'), - array('name' => 'speed', + 'type' => 'type'], + ['name' => 'speed', 'label' => __('Ethernet medium speed', 'ocsinventoryng'), - 'type' => 'speed'), - array('name' => 'version', + 'type' => 'speed'], + ['name' => 'version', 'label' => __('Wifi card Version', 'ocsinventoryng'), - 'type' => 'version')); + 'type' => 'version']]; if ($this->isNewItem()) { $this->fields['transform_unknown_ports_that_match'] = 1; - $result[] = array('name' => 'transform_unknown_ports_that_match', + $result[] = ['name' => 'transform_unknown_ports_that_match', 'label' => __('Transform unknown ports that match', 'ocsinventoryng'), - 'type' => 'bool'); + 'type' => 'bool']; if (isset($_GET['TYPE']) && isset($_GET['TYPEMIB'])) { $this->fields['OCS_TYPE'] = $_GET['TYPE']; @@ -211,8 +205,7 @@ function getAdditionalFields() * @param array $fields * @return string */ - static function getLinkToCreateFromTypeAndTypeMIB(array $fields = array()) - { + static function getLinkToCreateFromTypeAndTypeMIB(array $fields = []) { $link = static::getFormURL() . '?TYPE=' . $fields['TYPE'] . '&TYPEMIB=' . $fields['TYPEMIB']; if (!empty($fields['speed'])) { $speed = NetworkPortEthernet::transformPortSpeed($fields['speed'], false); @@ -222,7 +215,7 @@ static function getLinkToCreateFromTypeAndTypeMIB(array $fields = array()) } $link .= '&rand=1'; // To reload main window - Ajax::createIframeModalWindow('create_network', $link, array('title' => __('Create', 'ocsinventoryng'))); + Ajax::createIframeModalWindow('create_network', $link, ['title' => __('Create', 'ocsinventoryng')]); return "" . __('Create', 'ocsinventoryng') . ""; } @@ -232,22 +225,21 @@ static function getLinkToCreateFromTypeAndTypeMIB(array $fields = array()) * @param array $fields * @return bool|true */ - function getFromTypeAndTypeMIB(array $fields = array()) - { + function getFromTypeAndTypeMIB(array $fields = []) { $TYPEMIB = (empty($fields['TYPEMIB']) ? '' : $fields['TYPEMIB']); $TYPE = (empty($fields['TYPE']) ? '' : $fields['TYPE']); // First, try with TYPE AND TYPE MIB if ($this->getFromDBByQuery("WHERE `OCS_TYPE`='$TYPE' AND `OCS_TYPEMIB`='$TYPEMIB'")) { - return True; + return true; } // Else, try with TYPE and wildcard as Type MIB if ($this->getFromDBByQuery("WHERE `OCS_TYPE`='$TYPE' AND `OCS_TYPEMIB`='*'")) { - return True; + return true; } // Endly, return the default element return $this->getFromDBByQuery("WHERE `OCS_TYPE`='*' AND `OCS_TYPEMIB`='*'"); } -} \ No newline at end of file +} diff --git a/inc/networkshare.class.php b/inc/networkshare.class.php index 15c02a8f..5bc5655d 100644 --- a/inc/networkshare.class.php +++ b/inc/networkshare.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -110,7 +110,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
"; - if ($result = $DB->request('glpi_plugin_ocsinventoryng_networkshares', array('computers_id' => $ID, 'ORDER' => 'drive'))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_networkshares', ['computers_id' => $ID, 'ORDER' => 'drive'])) { echo ""; $colspan = 6; echo ""; echo ""; echo ""; - $tmp = Toolbox::getSize(str_replace(",",".", $data['size']) * 1024 * 1024 * 1024 * 1024); + $tmp = Toolbox::getSize(str_replace(",", ".", $data['size']) * 1024 * 1024 * 1024 * 1024); echo ""; - $tmp = Toolbox::getSize(str_replace(",",".", $data['freespace']) * 1024 * 1024 * 1024 * 1024); + $tmp = Toolbox::getSize(str_replace(",", ".", $data['freespace']) * 1024 * 1024 * 1024 * 1024); echo ""; echo ""; echo "
" . self::getTypeName($result->numrows()) . @@ -137,15 +137,15 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
" . $data['drive'] . "" . $data['path'] . "" . $tmp . "" . $tmp . ""; $percent = 0; - $total = str_replace(",",".", $data['size']); - $free = str_replace(",",".", $data['freespace']); + $total = str_replace(",", ".", $data['size']); + $free = str_replace(",", ".", $data['freespace']); if ($total > 0) { $percent = round(100*$free/$total); } @@ -165,4 +165,4 @@ static function showForComputer(Computer $comp, $withtemplate = '') { } echo ""; } -} \ No newline at end of file +} diff --git a/inc/notificationtargetnotimportedcomputer.class.php b/inc/notificationtargetnotimportedcomputer.class.php index ae5f5a80..bf0bd9f9 100644 --- a/inc/notificationtargetnotimportedcomputer.class.php +++ b/inc/notificationtargetnotimportedcomputer.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -41,10 +41,9 @@ class PluginOcsinventoryngNotificationTargetNotImportedcomputer extends Notifica /** * @return array */ - function getEvents() - { - return array('not_imported' => __('Computers not imported by automatic actions', - 'ocsinventoryng')); + function getEvents() { + return ['not_imported' => __('Computers not imported by automatic actions', + 'ocsinventoryng')]; } @@ -52,15 +51,14 @@ function getEvents() * @param $event * @param array $options */ - function getDatasForTemplate($event, $options = array()) - { + function getDatasForTemplate($event, $options = []) { global $CFG_GLPI; $this->datas['##notimported.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']); foreach ($options['notimported'] as $id => $item) { - $tmp = array(); + $tmp = []; $tmp['##notimported.name##'] = $item['name']; $tmp['##notimported.serial##'] = $item['serial']; @@ -89,10 +87,9 @@ function getDatasForTemplate($event, $options = array()) /** * */ - function getTags() - { + function getTags() { - $tags = array('notimported.id' => __('ID'), + $tags = ['notimported.id' => __('ID'), 'notimported.url' => __('Web link'), 'notimported.tag' => __('OCSNG TAG', 'ocsinventoryng'), 'notimported.name' => __('Name'), @@ -101,12 +98,12 @@ function getTags() 'notimported.ocsid' => __('OCSNG ID', 'ocsinventoryng'), 'notimported.deviceid' => __('Device ID', 'ocsinventoryng'), 'notimported.reason' => __('Reason of rejection'), - 'notimported.serial' => __('Serial number')); + 'notimported.serial' => __('Serial number')]; foreach ($tags as $tag => $label) { - $this->addTagToList(array('tag' => $tag, 'label' => $label, - 'value' => true)); + $this->addTagToList(['tag' => $tag, 'label' => $label, + 'value' => true]); } asort($this->tag_descriptions); } -} \ No newline at end of file +} diff --git a/inc/notificationtargetruleimportentity.class.php b/inc/notificationtargetruleimportentity.class.php index 7f308fef..71000384 100644 --- a/inc/notificationtargetruleimportentity.class.php +++ b/inc/notificationtargetruleimportentity.class.php @@ -35,38 +35,36 @@ * Class PluginOcsinventoryngNotificationRuleImportEntity */ class PluginOcsinventoryngNotificationTargetRuleImportEntity extends NotificationTarget { - + /** * @param int $nb * @return translated */ - static function getTypeName($nb = 0) - { + static function getTypeName($nb = 0) { return __('Elements not match with the rule', 'ocsinventoryng'); } /** * @see NotificationTarget::getEvents() */ - function getEvents() - { - return array('checkruleimportentity' => __('Elements not match with the rule by automatic actions', 'ocsinventoryng')); + function getEvents() { + return ['checkruleimportentity' => __('Elements not match with the rule by automatic actions', 'ocsinventoryng')]; } /** * @see NotificationTarget::getDatasForTemplate() */ - function getDatasForTemplate($event, $options = array()) { + function getDatasForTemplate($event, $options = []) { global $CFG_GLPI; $this->datas['##checkruleimportentity.date##'] = Html::convDateTime(date('Y-m-d H:i:s')); $this->datas['##checkruleimportentity.title##'] = __('Verification of assignment rules for entities and locations', 'ocsinventoryng'); - $this->datas['##checkruleimportentity.entity##'] = Dropdown::getDropdownName('glpi_entities',$options['entities_id']); + $this->datas['##checkruleimportentity.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']); foreach ($options['items'] as $id => $item) { - if(!empty($item)) { - $tmp = array(); + if (!empty($item)) { + $tmp = []; $tmp['##checkruleimportentity.entity##'] = Dropdown::getDropdownName('glpi_entities', $item['entities_id']); $tmp['##checkruleimportentity.computer##'] = $item['name']; @@ -81,7 +79,7 @@ function getDatasForTemplate($event, $options = array()) { foreach ($item['error'] as $key => $data) { - if($data === PluginOcsinventoryngRuleImportEntity::NO_RULE){ + if ($data === PluginOcsinventoryngRuleImportEntity::NO_RULE) { $tmp['##checkruleimportentity.error##'] .= __('No rules match', 'ocsinventoryng'); } else { $tmp['##checkruleimportentity.error##'] .= __($data) . "\n"; @@ -116,26 +114,26 @@ function getDatasForTemplate($event, $options = array()) { */ function getTags() { - $tags = array('checkruleimportentity.date' => __('Date'), + $tags = ['checkruleimportentity.date' => __('Date'), 'checkruleimportentity.url' => __('Link'), 'checkruleimportentity.entity' => __('Entity'), 'checkruleimportentity.computer' => __('Computer'), 'checkruleimportentity.location' => __('Location'), 'checkruleimportentity.error' => __('Error'), 'checkruleimportentity.name_rule' => __('Rule'), - 'checkruleimportentity.dataerror' => __('Data error', 'ocsinventoryng')); + 'checkruleimportentity.dataerror' => __('Data error', 'ocsinventoryng')]; foreach ($tags as $tag => $label) { - $this->addTagToList(array('tag' => $tag, + $this->addTagToList(['tag' => $tag, 'label' => $label, - 'value' => true)); + 'value' => true]); } - $this->addTagToList(array('tag' => 'checkruleimportentityitems', + $this->addTagToList(['tag' => 'checkruleimportentityitems', 'label' => _n('Item', 'Items', 2), 'value' => false, 'foreach' => true, - 'events' => array('checkruleimportentity'))); + 'events' => ['checkruleimportentity']]); asort($this->tag_descriptions); } -} \ No newline at end of file +} diff --git a/inc/notimportedcomputer.class.php b/inc/notimportedcomputer.class.php index adb9a8ad..9dc21a69 100644 --- a/inc/notimportedcomputer.class.php +++ b/inc/notimportedcomputer.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -45,8 +45,7 @@ class PluginOcsinventoryngNotimportedcomputer extends CommonDropdown * @param int $nb * @return translated */ - static function getTypeName($nb = 0) - { + static function getTypeName($nb = 0) { return _n('Computer not imported', 'Computers not imported', $nb, 'ocsinventoryng'); } @@ -54,44 +53,43 @@ static function getTypeName($nb = 0) /** * @return array */ - function getAdditionalFields() - { + function getAdditionalFields() { $can_update = PluginOcsinventoryngConfig::canUpdateOCS(); - return array(array('name' => 'reason', + return [['name' => 'reason', 'label' => __('Reason of rejection'), - 'type' => 'reason'), - array('name' => 'rules_id', + 'type' => 'reason'], + ['name' => 'rules_id', 'label' => __('Verified rules', 'ocsinventoryng'), - 'type' => 'echo_rule'), - array('name' => 'ocsid', + 'type' => 'echo_rule'], + ['name' => 'ocsid', 'label' => __('OCSNG ID', 'ocsinventoryng'), - 'type' => 'echo'), - array('name' => 'plugin_ocsinventoryng_ocsservers_id', + 'type' => 'echo'], + ['name' => 'plugin_ocsinventoryng_ocsservers_id', 'label' => __('Server'), 'type' => 'echo_dropdown', - 'table' => 'glpi_plugin_ocsinventoryng_ocsservers'), - array('name' => 'ocs_deviceid', + 'table' => 'glpi_plugin_ocsinventoryng_ocsservers'], + ['name' => 'ocs_deviceid', 'label' => __('Device ID', 'ocsinventoryng'), - 'type' => 'echo'), - array('name' => 'serial', + 'type' => 'echo'], + ['name' => 'serial', 'label' => __('Serial number'), - 'type' => ($can_update ? 'text' : 'echo')), - array('name' => 'tag', + 'type' => ($can_update ? 'text' : 'echo')], + ['name' => 'tag', 'label' => __('OCSNG TAG', 'ocsinventoryng'), - 'type' => ($can_update ? 'text' : 'echo')), - array('name' => 'useragent', + 'type' => ($can_update ? 'text' : 'echo')], + ['name' => 'useragent', 'label' => __('Inventory agent', 'ocsinventoryng'), - 'type' => 'echo'), - array('name' => 'ipaddr', + 'type' => 'echo'], + ['name' => 'ipaddr', 'label' => __('IP'), - 'type' => 'echo'), - array('name' => 'domain', + 'type' => 'echo'], + ['name' => 'domain', 'label' => __('Domain'), - 'type' => 'echo'), - array('name' => 'last_inventory', + 'type' => 'echo'], + ['name' => 'last_inventory', 'label' => __('Last OCSNG inventory date', 'ocsinventoryng'), - 'type' => 'echo_datetime')); + 'type' => 'echo_datetime']]; } @@ -101,10 +99,9 @@ function getAdditionalFields() * @internal param array $options * */ - function defineMoreTabs() - { + function defineMoreTabs() { - $ong = array(); + $ong = []; if (PluginOcsinventoryngOcsServer::getComputerLinkToOcsConsole($this->fields['plugin_ocsinventoryng_ocsservers_id'], $this->fields['ocsid'], '', true) != '' @@ -126,8 +123,7 @@ function defineMoreTabs() * @internal param array $field the item's fields * */ - function displaySpecificTypeField($ID, $field = array()) - { + function displaySpecificTypeField($ID, $field = []) { switch ($field['type']) { case 'echo' : @@ -164,10 +160,9 @@ function displaySpecificTypeField($ID, $field = array()) * @return string * @return string */ - static function getRuleMatchedMessage($rule_list) - { + static function getRuleMatchedMessage($rule_list) { - $message = array(); + $message = []; if ($rule_list != '') { foreach (json_decode($rule_list, true) as $key => $value) { if ($rule = getItemForItemtype($key)) { @@ -185,8 +180,7 @@ static function getRuleMatchedMessage($rule_list) } - function displayOcsConsole() - { + function displayOcsConsole() { $url = PluginOcsinventoryngOcsServer::getComputerLinkToOcsConsole($this->fields['plugin_ocsinventoryng_ocsservers_id'], $this->fields['ocsid'], '', @@ -204,8 +198,7 @@ function displayOcsConsole() * * @param $tab **/ - function displayMoreTabs($tab) - { + function displayMoreTabs($tab) { switch ($tab) { case 1 : @@ -231,10 +224,9 @@ function displayMoreTabs($tab) /** * @return array */ - function getSearchOptions() - { + function getSearchOptions() { - $tab = array(); + $tab = []; $tab['common'] = _n('Computer not imported', 'Computers not imported', 2, 'ocsinventoryng'); @@ -311,21 +303,19 @@ function getSearchOptions() * @param $ocsid * @param $reason **/ - function logNotImported($ocsservers_id, $ocsid, $reason) - { + function logNotImported($ocsservers_id, $ocsid, $reason) { global $DB; PluginOcsinventoryngOcsServer::checkOCSconnection($ocsservers_id); $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($ocsservers_id); - $options = array( - "DISPLAY" => array( + $options = [ + "DISPLAY" => [ "CHECKSUM" => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE | PluginOcsinventoryngOcsClient::CHECKSUM_BIOS - ) - ); + ] + ]; $computer = $ocsClient->getComputer($ocsid, $options); - if ((isset($computer["HARDWARE"]) && $computer["HARDWARE"]) && (isset($computer["BIOS"]) && $computer["BIOS"])) { $input["_ocs"] = true; @@ -370,8 +360,7 @@ function logNotImported($ocsservers_id, $ocsid, $reason) * @return int|number * @return int|number */ - function cleanNotImported($ocsservers_id = -1, $ocsid = -1) - { + function cleanNotImported($ocsservers_id = -1, $ocsid = -1) { global $DB; $first = true; @@ -405,8 +394,7 @@ function cleanNotImported($ocsservers_id = -1, $ocsid = -1) * @internal param if $not_imported_id of the computer that is not imported in GLPI * */ - function deleteNotImportedComputer($not_imported_id) - { + function deleteNotImportedComputer($not_imported_id) { if ($this->getFromDB($not_imported_id)) { PluginUninstallUninstall::deleteComputerInOCS($this->fields["ocsid"], @@ -423,8 +411,7 @@ function deleteNotImportedComputer($not_imported_id) * @return string|translated * @return string|translated */ - static function getReason($reason) - { + static function getReason($reason) { switch ($reason) { case PluginOcsinventoryngOcsServer::COMPUTER_FAILED_IMPORT : @@ -445,8 +432,7 @@ static function getReason($reason) /** * @param $notimported PluginOcsinventoryngNotimportedcomputer object **/ - static function showActions(PluginOcsinventoryngNotimportedcomputer $notimported) - { + static function showActions(PluginOcsinventoryngNotimportedcomputer $notimported) { echo "
"; echo ""; @@ -459,7 +445,7 @@ static function showActions(PluginOcsinventoryngNotimportedcomputer $notimported echo ""; echo ""; Dropdown::showForMassiveAction('PluginOcsinventoryngNotimportedcomputer', 0, - array('action' => 'massive')); + ['action' => 'massive']); echo "
"; Html::closeForm(); @@ -473,8 +459,7 @@ static function showActions(PluginOcsinventoryngNotimportedcomputer $notimported * @return bool * @return bool */ - static function computerImport($params = array()) - { + static function computerImport($params = []) { if (isset($params['id'])) { $notimported = new PluginOcsinventoryngNotimportedcomputer; @@ -490,18 +475,17 @@ static function computerImport($params = array()) } if (in_array($result['status'], - array(PluginOcsinventoryngOcsServer::COMPUTER_IMPORTED, + [PluginOcsinventoryngOcsServer::COMPUTER_IMPORTED, PluginOcsinventoryngOcsServer::COMPUTER_LINKED, - PluginOcsinventoryngOcsServer::COMPUTER_SYNCHRONIZED))) { - $notimported->delete(array('id' => $params['id'])); + PluginOcsinventoryngOcsServer::COMPUTER_SYNCHRONIZED])) { + $notimported->delete(['id' => $params['id']]); //If serial has been changed in order to import computer if (in_array('serial', $changes)) { PluginOcsinventoryngOcsServer::mergeOcsArray($result['computers_id'], - array('serial'), "computer_update"); + ['serial'], "computer_update"); } - return true; } else { Session::addMessageAfterRedirect(self::getReason($result['status']), @@ -526,8 +510,7 @@ static function computerImport($params = array()) /** * @param $params array **/ - static function linkComputer($params = array()) - { + static function linkComputer($params = []) { if (isset($params['id'])) { $notimported = new PluginOcsinventoryngNotimportedcomputer; @@ -538,10 +521,10 @@ static function linkComputer($params = array()) $notimported->fields['plugin_ocsinventoryng_ocsservers_id'], $params['computers_id']) ) { - $notimported->delete(array('id' => $params['id'])); + $notimported->delete(['id' => $params['id']]); //If serial has been changed in order to import computer if (in_array('serial', $changes)) { - PluginOcsinventoryngOcsServer::mergeOcsArray($params['id'], array('serial'), + PluginOcsinventoryngOcsServer::mergeOcsArray($params['id'], ['serial'], "computer_update"); } } @@ -555,17 +538,16 @@ static function linkComputer($params = array()) * @return array * @return array */ - static function getOcsComputerInfos($params = array()) - { + static function getOcsComputerInfos($params = []) { PluginOcsinventoryngOcsServer::checkOCSconnection($params['plugin_ocsinventoryng_ocsservers_id']); $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($params['plugin_ocsinventoryng_ocsservers_id']); - $options = array( - "DISPLAY" => array( + $options = [ + "DISPLAY" => [ "CHECKSUM" => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS - ) - ); + ] + ]; $computer = $ocsClient->getComputer($params['ocsid'], $options); - $changes = array(); + $changes = []; if ($computer) { $ocs_serial = $computer["BIOS"]["SSN"]; @@ -587,15 +569,14 @@ static function getOcsComputerInfos($params = array()) /** * @return int */ - static function sendAlert() - { + static function sendAlert() { global $DB, $CFG_GLPI; if (!$CFG_GLPI["notifications_mailing"]) { return 0; } - $items_infos = array(); + $items_infos = []; $query = "SELECT `glpi_plugin_ocsinventoryng_notimportedcomputers`.* FROM `glpi_plugin_ocsinventoryng_notimportedcomputers` @@ -611,8 +592,8 @@ static function sendAlert() foreach ($items_infos as $entity => $items) { if (NotificationEvent::raiseEvent('not_imported', new PluginOcsinventoryngNotimportedcomputer(), - array('entities_id' => $entity, - 'notimported' => $items)) + ['entities_id' => $entity, + 'notimported' => $items]) ) { $alert = new Alert(); $input["itemtype"] = 'PluginOcsinventoryngNotimportedcomputer'; @@ -633,8 +614,7 @@ static function sendAlert() /** * */ - function cleanDBonPurge() - { + function cleanDBonPurge() { global $DB; $query = "DELETE @@ -649,20 +629,18 @@ function cleanDBonPurge() * @param $name * @return array */ - static function cronInfo($name) - { + static function cronInfo($name) { switch ($name) { case "SendAlerts" : - return array('description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Not imported computers alert', 'ocsinventoryng')); + return ['description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Not imported computers alert', 'ocsinventoryng')]; } } /** * @param $task */ - static function cronSendAlerts($task) - { + static function cronSendAlerts($task) { self::sendAlert(); $task->setVolume(1); } @@ -674,8 +652,7 @@ static function cronSendAlerts($task) * @param null $checkitem * @return an */ - function getSpecificMassiveActions($checkitem = NULL) - { + function getSpecificMassiveActions($checkitem = null) { $actions = parent::getSpecificMassiveActions($checkitem); @@ -685,8 +662,7 @@ function getSpecificMassiveActions($checkitem = NULL) /** * @return an|array */ - function getForbiddenStandardMassiveAction() - { + function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; @@ -700,14 +676,13 @@ function getForbiddenStandardMassiveAction() * @param MassiveAction $ma * @return bool|false */ - static function showMassiveActionsSubForm(MassiveAction $ma) - { + static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { case 'plugin_ocsinventoryng_import': - Entity::dropdown(array('name' => 'entity')); + Entity::dropdown(['name' => 'entity']); echo " " . - Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; /*case 'plugin_ocsinventoryng_link': Computer::dropdown(array('name' => 'computers_id')); @@ -717,7 +692,7 @@ static function showMassiveActionsSubForm(MassiveAction $ma) case 'plugin_ocsinventoryng_replayrules': case 'plugin_ocsinventoryng_delete': echo " " . - Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; } return parent::showMassiveActionsSubForm($ma); @@ -734,8 +709,7 @@ static function showMassiveActionsSubForm(MassiveAction $ma) * @return nothing|void */ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, - array $ids) - { + array $ids) { $notimport = new PluginOcsinventoryngNotimportedcomputer(); @@ -744,9 +718,9 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT $input = $ma->getInput(); foreach ($ids as $id) { - if (PluginOcsinventoryngNotimportedcomputer::computerImport(array('id' => $id, + if (PluginOcsinventoryngNotimportedcomputer::computerImport(['id' => $id, 'force' => true, - 'entity' => $input['entity'])) + 'entity' => $input['entity']]) ) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { @@ -758,7 +732,7 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT case "plugin_ocsinventoryng_replayrules" : foreach ($ids as $id) { - if (PluginOcsinventoryngNotimportedcomputer::computerImport(array('id' => $id))) { + if (PluginOcsinventoryngNotimportedcomputer::computerImport(['id' => $id])) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); @@ -778,4 +752,4 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); } -} \ No newline at end of file +} diff --git a/inc/ocsadmininfoslink.class.php b/inc/ocsadmininfoslink.class.php index f94d10eb..53f5baba 100644 --- a/inc/ocsadmininfoslink.class.php +++ b/inc/ocsadmininfoslink.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -40,11 +40,10 @@ class PluginOcsinventoryngOcsAdminInfosLink extends CommonDBTM /** * @param $ID */ - function cleanForOcsServer($ID) - { + function cleanForOcsServer($ID) { $temp = new self(); - $temp->deleteByCriteria(array('plugin_ocsinventoryng_ocsservers_id' => $ID)); + $temp->deleteByCriteria(['plugin_ocsinventoryng_ocsservers_id' => $ID]); } @@ -53,8 +52,7 @@ function cleanForOcsServer($ID) * @param $glpi_column * @return true */ - function getFromDBbyOcsServerIDAndGlpiColumn($plugin_ocsinventoryng_ocsservers_id, $glpi_column) - { + function getFromDBbyOcsServerIDAndGlpiColumn($plugin_ocsinventoryng_ocsservers_id, $glpi_column) { return $this->getFromDBByQuery("WHERE `" . $this->getTable() . "`.`plugin_ocsinventoryng_ocsservers_id` = '$plugin_ocsinventoryng_ocsservers_id' AND `" . $this->getTable() . "`.`glpi_column` = '$glpi_column'"); @@ -66,8 +64,7 @@ function getFromDBbyOcsServerIDAndGlpiColumn($plugin_ocsinventoryng_ocsservers_i * @param $computer_updates * @return array */ - static function addInfocomsForComputer($computers_id, $date, $computer_updates) - { + static function addInfocomsForComputer($computers_id, $date, $computer_updates) { global $DB; $infocom = new Infocom(); @@ -77,11 +74,11 @@ static function addInfocomsForComputer($computers_id, $date, $computer_updates) || $infocom->fields['use_date'] == 'NULL' ) { //add use_date - $infocom->update(array('id' => $infocom->fields['id'], 'use_date' => $use_date)); + $infocom->update(['id' => $infocom->fields['id'], 'use_date' => $use_date]); } } else { //add infocom - $infocom->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'use_date' => $use_date)); + $infocom->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'use_date' => $use_date]); } @@ -100,4 +97,4 @@ static function addInfocomsForComputer($computers_id, $date, $computer_updates) return $computer_updates; } -} \ No newline at end of file +} diff --git a/inc/ocsclient.class.php b/inc/ocsclient.class.php index 7498e86c..ef772137 100644 --- a/inc/ocsclient.class.php +++ b/inc/ocsclient.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -72,15 +72,14 @@ abstract class PluginOcsinventoryngOcsClient const PLUGINS_SERVICE = 0x00010; const PLUGINS_RUNNINGPROCESS = 0x00011; const PLUGINS_ALL = 0x00012; - + private $id; /** * PluginOcsinventoryngOcsClient constructor. * @param $id */ - public function __construct($id) - { + public function __construct($id) { $this->id = $id; } @@ -280,8 +279,7 @@ abstract public function getOCSComputers(); * @param array $options * @return mixed|null */ - public function getOcsComputer($id, $tables = array()) - { + public function getOcsComputer($id, $tables = []) { $result = $this->getComputerRule($id, $tables); @@ -344,8 +342,7 @@ abstract public function updateTag($tag, $id); /* IMPLEMENTED FUNCTIONS */ /* * ********************** */ - public function getId() - { + public function getId() { return $this->id; } @@ -354,13 +351,12 @@ public function getId() * @param array $options * @return mixed|null */ - public function getComputer($id, $options = array()) - { - + public function getComputer($id, $options = []) { + //if (!isset($options['COMPLETE'])) { // $options['COMPLETE'] = 0; //} - + //if (!isset($options['FILTER'])) { // $options['FILTER'] = array(); //} @@ -368,7 +364,6 @@ public function getComputer($id, $options = array()) //$options['FILTER']['IDS'] = array($id); $result = $this->getComputers($options, $id); - if (!isset($result['TOTAL_COUNT']) || $result['TOTAL_COUNT'] < 1 || empty($result['COMPUTERS'])) { return null; } @@ -380,16 +375,14 @@ public function getComputer($id, $options = array()) * @param array $options * @return mixed|null */ - public function getSnmpDevice($id, $options = array()) - { + public function getSnmpDevice($id, $options = []) { if (!isset($options['FILTER'])) { - $options['FILTER'] = array(); + $options['FILTER'] = []; } - $options['FILTER']['IDS'] = array($id); + $options['FILTER']['IDS'] = [$id]; $result = $this->getSnmp($options); - if (!isset($result['TOTAL_COUNT']) || $result['TOTAL_COUNT'] < 1 || empty($result['SNMP'])) { return null; } @@ -403,8 +396,7 @@ public function getSnmpDevice($id, $options = array()) * @param string $key The name of the config item to return * @return integer */ - public function getIntConfig($key) - { + public function getIntConfig($key) { $config = $this->getConfig($key); return $config['IVALUE']; } @@ -416,8 +408,7 @@ public function getIntConfig($key) * @param string $key The name of the config item to return * @return string */ - public function getTextConfig($key) - { + public function getTextConfig($key) { $config = $this->getConfig($key); return $config['TVALUE']; } @@ -425,142 +416,141 @@ public function getTextConfig($key) /** * @return array */ - public function getOcsMap() - { - $DATA_MAP = array( - 'hardware' => array( + public function getOcsMap() { + $DATA_MAP = [ + 'hardware' => [ 'checksum' => self::CHECKSUM_HARDWARE, 'multi' => 0, - ), - 'bios' => array( + ], + 'bios' => [ 'checksum' => self::CHECKSUM_BIOS, 'multi' => 0, - ), - 'memories' => array( + ], + 'memories' => [ 'checksum' => self::CHECKSUM_MEMORY_SLOTS, 'multi' => 1, - ), - 'slots' => array( + ], + 'slots' => [ 'checksum' => self::CHECKSUM_SYSTEM_SLOTS, 'multi' => 1, - ), - 'registry' => array( + ], + 'registry' => [ 'checksum' => self::CHECKSUM_REGISTRY, 'multi' => 1, - ), - 'securitycenter' => array( + ], + 'securitycenter' => [ 'plugins' => self::PLUGINS_SECURITY, 'multi' => 1, - ), - 'uptime' => array( + ], + 'uptime' => [ 'plugins' => self::PLUGINS_UPTIME, 'multi' => 0, - ), - 'winupdatestate' => array( + ], + 'winupdatestate' => [ 'plugins' => self::PLUGINS_WUPDATE, 'multi' => 0, - ), - 'osinstall' => array( + ], + 'osinstall' => [ 'plugins' => self::PLUGINS_OSINSTALL, 'multi' => 0, - ), - 'networkshare' => array( + ], + 'networkshare' => [ 'plugins' => self::PLUGINS_NETWORKSHARE, 'multi' => 1, - ), - 'runningprocess' => array( + ], + 'runningprocess' => [ 'plugins' => self::PLUGINS_RUNNINGPROCESS, 'multi' => 1, - ), - 'service' => array( + ], + 'service' => [ 'plugins' => self::PLUGINS_SERVICE, 'multi' => 1, - ), - 'navigatorproxysetting' => array( + ], + 'navigatorproxysetting' => [ 'plugins' => self::PLUGINS_PROXYSETTING, 'multi' => 1, - ), - 'winusers' => array( + ], + 'winusers' => [ 'plugins' => self::PLUGINS_WINUSERS, 'multi' => 1, - ), - 'teamviewer' => array( + ], + 'teamviewer' => [ 'plugins' => self::PLUGINS_TEAMVIEWER, 'multi' => 0, - ), - 'officepack' => array( + ], + 'officepack' => [ 'plugins' => self::PLUGINS_OFFICE, 'multi' => 1, - ), - 'controllers' => array( + ], + 'controllers' => [ 'checksum' => self::CHECKSUM_SYSTEM_CONTROLLERS, 'multi' => 1, - ), - 'monitors' => array( + ], + 'monitors' => [ 'checksum' => self::CHECKSUM_MONITORS, 'multi' => 1, - ), - 'ports' => array( + ], + 'ports' => [ 'checksum' => self::CHECKSUM_SYSTEM_PORTS, 'multi' => 1, - ), - 'storages' => array( + ], + 'storages' => [ 'checksum' => self::CHECKSUM_STORAGE_PERIPHERALS, 'multi' => 1, - ), - 'drives' => array( + ], + 'drives' => [ 'checksum' => self::CHECKSUM_LOGICAL_DRIVES, 'multi' => 1, - ), - 'inputs' => array( + ], + 'inputs' => [ 'checksum' => self::CHECKSUM_INPUT_DEVICES, 'multi' => 1, - ), - 'modems' => array( + ], + 'modems' => [ 'checksum' => self::CHECKSUM_MODEMS, 'multi' => 1, - ), - 'networks' => array( + ], + 'networks' => [ 'checksum' => self::CHECKSUM_NETWORK_ADAPTERS, 'multi' => 1, - ), - 'printers' => array( + ], + 'printers' => [ 'checksum' => self::CHECKSUM_PRINTERS, 'multi' => 1, - ), - 'sounds' => array( + ], + 'sounds' => [ 'checksum' => self::CHECKSUM_SOUND_ADAPTERS, 'multi' => 1, - ), - 'videos' => array( + ], + 'videos' => [ 'checksum' => self::CHECKSUM_VIDEO_ADAPTERS, 'multi' => 1, - ), - 'softwares' => array( + ], + 'softwares' => [ 'checksum' => self::CHECKSUM_SOFTWARE, 'multi' => 1, - ), - 'virtualmachines' => array( + ], + 'virtualmachines' => [ 'checksum' => self::CHECKSUM_VIRTUAL_MACHINES, 'multi' => 1, - ), - 'cpus' => array( + ], + 'cpus' => [ 'checksum' => self::CHECKSUM_CPUS, 'multi' => 1, - ), - 'sim' => array( + ], + 'sim' => [ 'checksum' => self::CHECKSUM_SIM, 'multi' => 1, - ), - 'accountinfo' => array( + ], + 'accountinfo' => [ 'wanted' => self::WANTED_ACCOUNTINFO, 'multi' => 1, - ), - 'dico_soft' => array( + ], + 'dico_soft' => [ 'wanted' => self::WANTED_DICO_SOFT, 'multi' => 0, - ), - ); + ], + ]; return $DATA_MAP; } @@ -569,8 +559,7 @@ public function getOcsMap() * @param $tables * @return int */ - public function getChecksumForTables($tables) - { + public function getChecksumForTables($tables) { $ocsMap = $this->getOcsMap(); $checksum = self::CHECKSUM_NONE; @@ -587,8 +576,7 @@ public function getChecksumForTables($tables) * @param $tables * @return int */ - public function getWantedForTables($tables) - { + public function getWantedForTables($tables) { $ocsMap = $this->getOcsMap(); $wanted = self::WANTED_NONE; @@ -605,8 +593,7 @@ public function getWantedForTables($tables) * @param $tables * @return int */ - public function getPluginsForTables($tables) - { + public function getPluginsForTables($tables) { $ocsMap = $this->getOcsMap(); $plugins = self::PLUGINS_NONE; @@ -622,9 +609,8 @@ public function getPluginsForTables($tables) /** * @return string */ - public function getConnectionType() - { + public function getConnectionType() { return get_class($this); } -} \ No newline at end of file +} diff --git a/inc/ocsdbclient.class.php b/inc/ocsdbclient.class.php index 3f195c98..45fc53d8 100644 --- a/inc/ocsdbclient.class.php +++ b/inc/ocsdbclient.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -59,8 +59,8 @@ public function getDB() { return $this->db; } - public function getComputerRule($id, $tables = array()) { - $computers = array(); + public function getComputerRule($id, $tables = []) { + $computers = []; $query = "SELECT `hardware`.*,`accountinfo`.`TAG` FROM `hardware` INNER JOIN `accountinfo` ON (`hardware`.`id` = `accountinfo`.`HARDWARE_ID`) @@ -87,7 +87,6 @@ public function getComputerRule($id, $tables = array()) { } - foreach ($tables as $table) { if ($table == "accountinfo") { @@ -151,7 +150,6 @@ public function getComputerRule($id, $tables = array()) { **/ function OcsTableExists($tablename) { - // Get a list of tables contained within the database. $result = $this->db->list_tables("%" . $tablename . "%"); @@ -183,7 +181,7 @@ function OcsTableExists($tablename) { private function getComputerSections($ids, $checksum, $wanted, $plugins, $complete = 0) { $OCS_MAP = self::getOcsMap(); - $DATA_MAP = array(); + $DATA_MAP = []; foreach ($OCS_MAP as $table => $value) { if ($table == "dico_soft") { @@ -197,12 +195,12 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple if ($check & $checksum) { $DATA_MAP[$table] = $value; } - } elseif (isset($value['wanted'])) { + } else if (isset($value['wanted'])) { $check = $value['wanted']; if ($wanted & self::WANTED_ACCOUNTINFO) { $DATA_MAP[$table] = $value; } - } elseif (isset($value['plugins'])) { + } else if (isset($value['plugins'])) { $check = $value['plugins']; if (self::OcsTableExists($table) && (($check & $plugins) || $plugins == self::PLUGINS_ALL)) { $DATA_MAP[$table] = $value; @@ -223,9 +221,9 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } if (isset($value['checksum'])) { $check = $value['checksum']; - } elseif (isset($value['wanted'])) { + } else if (isset($value['wanted'])) { $check = $value['wanted']; - } elseif (isset($value['plugins'])) { + } else if (isset($value['plugins'])) { $check = $value['plugins']; } $multi = $value['multi']; @@ -269,7 +267,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } } } - } elseif ($table == "softwares") { + } else if ($table == "softwares") { if (($check & $checksum) || $complete > 0) { if (self::WANTED_DICO_SOFT & $wanted) { @@ -318,7 +316,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple $computers[$software['HARDWARE_ID']]["SOFTWARES"][] = $software; } } - } elseif ($table == "registry") { + } else if ($table == "registry") { if (($check & $checksum) || $complete > 0) { $query = "SELECT `registry`.`NAME` AS name, @@ -338,7 +336,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } } } - } elseif (self::OcsTableExists("securitycenter") && $table == "securitycenter") { + } else if (self::OcsTableExists("securitycenter") && $table == "securitycenter") { if (($check & $plugins) || $plugins == self::PLUGINS_ALL || $complete > 0) { $query = "SELECT `securitycenter`.`SCV` AS scv, @@ -360,7 +358,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } } } - } elseif (self::OcsTableExists("uptime") && $table == "uptime") { + } else if (self::OcsTableExists("uptime") && $table == "uptime") { if (($check & $plugins) || $plugins == self::PLUGINS_ALL || $complete > 0) { $query = "SELECT `uptime`.`TIME` AS time, @@ -372,7 +370,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple $computers[$up['HARDWARE_ID']][strtoupper($table)] = $up; } } - } elseif (self::OcsTableExists("officepack") && $table == "officepack") { + } else if (self::OcsTableExists("officepack") && $table == "officepack") { $query = "SELECT `officepack`.* FROM `hardware` INNER JOIN `officepack` ON (`hardware`.`id` = `officepack`.`HARDWARE_ID`) @@ -387,7 +385,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } - } elseif (self::OcsTableExists("winupdatestate") && $table == "winupdatestate") { + } else if (self::OcsTableExists("winupdatestate") && $table == "winupdatestate") { $query = "SELECT `winupdatestate`.* FROM `hardware` INNER JOIN `winupdatestate` ON (`hardware`.`id` = `winupdatestate`.`HARDWARE_ID`) @@ -402,7 +400,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } - } elseif (self::OcsTableExists("osinstall") && $table == "osinstall") { + } else if (self::OcsTableExists("osinstall") && $table == "osinstall") { $query = "SELECT `osinstall`.* FROM `hardware` INNER JOIN `osinstall` ON (`hardware`.`id` = `osinstall`.`HARDWARE_ID`) @@ -419,7 +417,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple } - } elseif (self::OcsTableExists("networkshare") && $table == "networkshare") { + } else if (self::OcsTableExists("networkshare") && $table == "networkshare") { $query = "SELECT `networkshare`.* FROM `hardware` INNER JOIN `networkshare` ON (`hardware`.`id` = `networkshare`.`HARDWARE_ID`) @@ -433,7 +431,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple $computers[$meta['HARDWARE_ID']][strtoupper($table)][$meta['ID']]["QUOTA"] = $meta["QUOTA"]; } - } elseif (self::OcsTableExists("runningprocess") && $table == "runningprocess") { + } else if (self::OcsTableExists("runningprocess") && $table == "runningprocess") { $query = "SELECT `runningprocess`.* FROM `hardware` INNER JOIN `runningprocess` ON (`hardware`.`id` = `runningprocess`.`HARDWARE_ID`) @@ -453,7 +451,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple $computers[$meta['HARDWARE_ID']][strtoupper($table)][$meta['ID']]["COMPANY"] = $meta["COMPANY"]; } - } elseif (self::OcsTableExists("service") && $table == "service") { + } else if (self::OcsTableExists("service") && $table == "service") { $query = "SELECT `service`.* FROM `hardware` INNER JOIN `service` ON (`hardware`.`id` = `service`.`HARDWARE_ID`) @@ -471,7 +469,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple $computers[$meta['HARDWARE_ID']][strtoupper($table)][$meta['ID']]["SVCSPECEXITCODE"] = $meta["SVCSPECEXITCODE"]; } - } elseif ($table == "hardware") { + } else if ($table == "hardware") { $query = "SELECT `hardware`.*,`accountinfo`.`TAG` FROM `hardware` INNER JOIN `accountinfo` ON (`hardware`.`id` = `accountinfo`.`HARDWARE_ID`) @@ -528,7 +526,7 @@ private function getComputerSections($ids, $checksum, $wanted, $plugins, $comple */ private function getSnmpSections($ids, $complete = 1) { - $snmp = array(); + $snmp = []; // Check for basics snmp infos $query = "SELECT * FROM `snmp` WHERE `ID` IN (" . implode(',', $ids) . ")"; @@ -661,32 +659,31 @@ public function checkConnection() { public function searchComputers($field, $value) { if ($field == "id" || $field == "ID") { - $options = array( - "FILTER" => array( - 'IDS' => array( + $options = [ + "FILTER" => [ + 'IDS' => [ $value - ) - ) - ); - } elseif ($field == "tag" || $field == "TAG") { - $options = array( - "FILTER" => array( - 'TAGS' => array( + ] + ] + ]; + } else if ($field == "tag" || $field == "TAG") { + $options = [ + "FILTER" => [ + 'TAGS' => [ $value - ) - ) - ); - } elseif ($field == "deviceid" || $field == "DEVICEID") { - $options = array( - "FILTER" => array( - 'DEVICEIDS' => array( + ] + ] + ]; + } else if ($field == "deviceid" || $field == "DEVICEID") { + $options = [ + "FILTER" => [ + 'DEVICEIDS' => [ $value - ) - ) - ); + ] + ] + ]; } - $res = $this->getComputers($options); return $res; } @@ -722,7 +719,6 @@ public function updateTag($tag, $id) { */ public function countComputers($options, $id = 0) { - if (isset($options['OFFSET'])) { $offset = "OFFSET " . $options['OFFSET']; } else { @@ -819,7 +815,6 @@ public function countComputers($options, $id = 0) { $where_before = ""; } - if (isset($filters['CHECKSUM']) and $filters['CHECKSUM']) { $checksum = $filters['CHECKSUM']; @@ -864,7 +859,7 @@ public function countComputers($options, $id = 0) { return $hardwareids; } else { - return array(); + return []; } return $res; @@ -879,7 +874,6 @@ public function countComputers($options, $id = 0) { */ public function getComputers($options, $id = 0) { - if (isset($options['OFFSET'])) { $offset = "OFFSET " . $options['OFFSET']; } else { @@ -976,7 +970,6 @@ public function getComputers($options, $id = 0) { $where_before = ""; } - if (isset($filters['CHECKSUM']) and $filters['CHECKSUM']) { $checksum = $filters['CHECKSUM']; @@ -994,7 +987,6 @@ public function getComputers($options, $id = 0) { $where_condition = ""; } - /*$query = "SELECT * FROM `hardware`, `accountinfo` WHERE `hardware`.`DEVICEID` NOT LIKE '\\_%' AND `hardware`.`ID` = `accountinfo`.`HARDWARE_ID` @@ -1022,7 +1014,7 @@ public function getComputers($options, $id = 0) { $where_condition ORDER BY $order $max_records $offset"; - + $request = $this->db->query($query);*/ $this->getAccountInfoColumns(); while ($hardwareid = $this->db->fetch_assoc($request)) { @@ -1055,7 +1047,7 @@ public function getComputers($options, $id = 0) { } else { - $res = array(); + $res = []; } return $res; @@ -1145,7 +1137,7 @@ public function getComputersToUpdate($cfg_ocs, $max_date) { LIMIT " . intval($cfg_ocs["cron_sync_number"]); $res = $this->db->query($query); - $data = array(); + $data = []; if ($res->num_rows > 0) { while ($num = $this->db->fetch_assoc($res)) { @@ -1162,7 +1154,7 @@ public function getOCSComputers() { $query = "SELECT `ID`, `DEVICEID` FROM `hardware`"; $res = $this->db->query($query); - $data = array(); + $data = []; if ($res->num_rows > 0) { while ($num = $this->db->fetch_assoc($res)) { @@ -1196,7 +1188,7 @@ public function getOldAgents() { AND ( unix_timestamp(LASTCOME) <= UNIX_TIMESTAMP(NOW() - INTERVAL $delay DAY)) AND deviceid <> '_SYSTEMGROUP_' AND deviceid <> '_DOWNLOADGROUP_'"; $res = $this->db->query($query); - $data = array(); + $data = []; if ($res->num_rows > 0) { while ($num = $this->db->fetch_assoc($res)) { @@ -1228,7 +1220,7 @@ public function deleteOldAgents($agents) { $did = $num["deviceid"]; if ($did) { - $tables = array("accesslog", + $tables = ["accesslog", "accountinfo", "bios", "controllers", @@ -1262,7 +1254,7 @@ public function deleteOldAgents($agents) { "virtualmachines", "cpus", "sim" - ); + ]; if (isset($tables) and is_array($tables)) { foreach ($tables as $table) { if (self::OcsTableExists($table)) { @@ -1314,7 +1306,7 @@ public function getDeletedComputers() { $count++; } } else { - $res = array(); + $res = []; } $_SESSION["ocs_deleted_equiv"]["deleted"] = 0; if (empty($_SESSION["ocs_deleted_equiv"]["total"])) { @@ -1368,7 +1360,7 @@ public function getAccountInfoColumns($table = 'accountinfo') { while ($column = $this->db->fetch_assoc($columns)) { $res[$column['Field']] = $column['Field']; } - } elseif ($table == 'hardware') { + } else if ($table == 'hardware') { $res['DEVICEID'] = 'DEVICEID'; } return $res; @@ -1384,7 +1376,6 @@ public function getAccountInfoColumns($table = 'accountinfo') { */ public function getSnmp($options) { - if (isset($options['OFFSET'])) { $offset = "OFFSET " . $options['OFFSET']; } else { @@ -1458,7 +1449,6 @@ public function getSnmp($options) { $where_before = ""; } - if (isset($filters['CHECKSUM']) and $filters['CHECKSUM']) { $checksum = $filters['CHECKSUM']; $where_checksum = " AND ('" . $checksum . "' & snmp.CHECKSUM) "; @@ -1470,7 +1460,6 @@ public function getSnmp($options) { $where_condition = ""; } - $query = "SELECT DISTINCT snmp.ID FROM snmp, snmp_accountinfo WHERE snmp.SNMPDEVICEID NOT LIKE '\\_%' AND snmp.ID = snmp_accountinfo.SNMP_ID @@ -1479,7 +1468,6 @@ public function getSnmp($options) { if ($this->db->numrows($request)) { - $count = $this->db->numrows($request); $query = "SELECT DISTINCT snmp.ID, snmp.NAME FROM snmp, snmp_accountinfo WHERE snmp.SNMPDEVICEID NOT LIKE '\\_%' @@ -1510,8 +1498,7 @@ public function getSnmp($options) { $res["SNMP"] = $this->getSnmpSections($snmpids, $complete); } else { - - $res = array(); + $res = []; } return $res; diff --git a/inc/ocslink.class.php b/inc/ocslink.class.php index c76e8594..a0b92476 100644 --- a/inc/ocslink.class.php +++ b/inc/ocslink.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -84,7 +84,7 @@ static function showSimpleForItem(CommonDBTM $item) { $target = Toolbox::getItemTypeFormURL(__CLASS__); - if (in_array($item->getType(), array('Computer'))) { + if (in_array($item->getType(), ['Computer'])) { $items_id = $item->getField('id'); if (!empty($items_id) @@ -135,7 +135,6 @@ static function showSimpleForItem(CommonDBTM $item) { echo ""; } - echo ""; echo "" . __('OCSNG TAG', 'ocsinventoryng') . ""; @@ -188,8 +187,8 @@ static function showSimpleForItem(CommonDBTM $item) { echo ""; Html::showSimpleForm($target, 'force_ocs_resynch', _sx('button', 'Force synchronization', 'ocsinventoryng'), - array('id' => $items_id, - 'resynch_id' => $data["id"])); + ['id' => $items_id, + 'resynch_id' => $data["id"]]); echo ""; } else { @@ -221,10 +220,10 @@ static function showSimpleForItem(CommonDBTM $item) { echo ""; Html::showSimpleForm($target, 'force_ocssnmp_resynch', _sx('button', 'Force SNMP synchronization', 'ocsinventoryng'), - array('items_id' => $items_id, + ['items_id' => $items_id, 'itemtype' => $item->getType(), 'id' => $data["id"], - 'plugin_ocsinventoryng_ocsservers_id' => $data["plugin_ocsinventoryng_ocsservers_id"])); + 'plugin_ocsinventoryng_ocsservers_id' => $data["plugin_ocsinventoryng_ocsservers_id"]]); echo ""; } @@ -232,12 +231,12 @@ static function showSimpleForItem(CommonDBTM $item) { $linked_ids [] = $data['ocs_id']; $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($data['plugin_ocsinventoryng_ocsservers_id']); - $ocsResult = $ocsClient->getSnmp(array( + $ocsResult = $ocsClient->getSnmp([ 'MAX_RECORDS' => 1, - 'FILTER' => array( + 'FILTER' => [ 'IDS' => $linked_ids, - ) - )); + ] + ]); if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP']) > 0) { foreach ($ocsResult['SNMP'] as $snmp) { @@ -312,7 +311,7 @@ static function showForItem(CommonDBTM $item) { $target = Toolbox::getItemTypeFormURL(__CLASS__); - if (in_array($item->getType(), array('Computer'))) { + if (in_array($item->getType(), ['Computer'])) { $items_id = $item->getField('id'); if (!empty($items_id) @@ -400,14 +399,14 @@ static function showForItem(CommonDBTM $item) { if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($data["plugin_ocsinventoryng_ocsservers_id"]); - $options = array( - 'DISPLAY' => array( + $options = [ + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE, 'PLUGINS' => PluginOcsinventoryngOcsClient::PLUGINS_ALL - ), + ], 'COMPLETE' => 1 - ); - $computer = array(); + ]; + $computer = []; $checksum_client = 0; $computer = $ocsClient->getComputer($data["ocsid"], $options); echo "
"; @@ -618,10 +617,10 @@ static function addComputer_Item(CommonDBTM $item) { **/ static function purgeComputer(Computer $comp) { $link = new self(); - $link->deleteByCriteria(array('computers_id' => $comp->getField("id"))); + $link->deleteByCriteria(['computers_id' => $comp->getField("id")]); $reg = new PluginOcsinventoryngRegistryKey(); - $reg->deleteByCriteria(array('computers_id' => $comp->getField("id"))); + $reg->deleteByCriteria(['computers_id' => $comp->getField("id")]); } @@ -655,7 +654,6 @@ static function purgeComputer_Item(Computer_Item $comp) { // 2 : a deconnection's status have been defined // 3 : unique with serial - if (($mode >= 2) && (strlen($decoConf) > 0) ) { @@ -710,7 +708,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { switch ($item->getType()) { case 'Computer' : if (!$withtemplate) { - return array('1' => _n('OCSNG link', 'OCSNG links', 1, 'ocsinventoryng')); + return ['1' => _n('OCSNG link', 'OCSNG links', 1, 'ocsinventoryng')]; } } } @@ -816,4 +814,4 @@ static function getOCSServerForItem(CommonDBTM $item) { return false; } } -} \ No newline at end of file +} diff --git a/inc/ocsserver.class.php b/inc/ocsserver.class.php index 8bb80268..e5cb8872 100644 --- a/inc/ocsserver.class.php +++ b/inc/ocsserver.class.php @@ -38,7 +38,7 @@ */ class PluginOcsinventoryngOcsServer extends CommonDBTM { - static $types = array('Computer'); + static $types = ['Computer']; static $rightname = "plugin_ocsinventoryng"; // From CommonDBTM public $dohistory = true; @@ -145,7 +145,6 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { return $ong; } - } return ''; } @@ -190,9 +189,9 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem * * @return array */ - function defineTabs($options = array()) { + function defineTabs($options = []) { - $ong = array(); + $ong = []; $this->addDefaultFormTab($ong); $this->addStandardTab(__CLASS__, $ong, $options); $this->addStandardTab('PluginOcsinventoryngSnmpOcslink', $ong, $options); @@ -206,7 +205,7 @@ function defineTabs($options = array()) { */ function getSearchOptions() { - $tab = array(); + $tab = []; $tab['common'] = self::getTypeName(); @@ -265,7 +264,7 @@ function getSearchOptions() { static function setupMenu($plugin_ocsinventoryng_ocsservers_id) { global $CFG_GLPI, $DB; $name = ""; - $ocsservers = array(); + $ocsservers = []; //echo "
"; //echo ""; @@ -291,10 +290,10 @@ static function setupMenu($plugin_ocsinventoryng_ocsservers_id) { foreach ($DB->request($query) as $data) { $ocsservers[] = $data['id']; } - Dropdown::show('PluginOcsinventoryngOcsServer', array("condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", + Dropdown::show('PluginOcsinventoryngOcsServer', ["condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", "value" => $_SESSION["plugin_ocsinventoryng_ocsservers_id"], "on_change" => "this.form.submit()", - "display_emptychoice" => false)); + "display_emptychoice" => false]); echo ""; echo "
"; echo ""; echo "\n"; echo "\n"; - $import_array = array("0" => __('No import'), + $import_array = ["0" => __('No import'), "1" => __('Global import', 'ocsinventoryng'), - "2" => __('Unit import', 'ocsinventoryng')); + "2" => __('Unit import', 'ocsinventoryng')]; - $import_array2 = array("0" => __('No import'), + $import_array2 = ["0" => __('No import'), "1" => __('Global import', 'ocsinventoryng'), "2" => __('Unit import', 'ocsinventoryng'), "3" => __('Unit import on serial number', 'ocsinventoryng'), - "4" => __('Unit import serial number only', 'ocsinventoryng')); + "4" => __('Unit import serial number only', 'ocsinventoryng')]; $periph = $this->fields["import_periph"]; $monitor = $this->fields["import_monitor"]; @@ -806,23 +804,23 @@ function accordion(id, openall) { $software = $this->fields["import_software"]; echo "\n\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; echo "\n\n"; - echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; @@ -965,8 +962,8 @@ function accordion(id, openall) { $link->getFromDBbyOcsServerIDAndGlpiColumn($ID, "groups_id"); $value = (isset($link->fields["ocs_column"]) ? $link->fields["ocs_column"] : ""); - Dropdown::showFromArray("import_group", $opt, array('value' => $value, - 'width' => '100%')); + Dropdown::showFromArray("import_group", $opt, ['value' => $value, + 'width' => '100%']); echo "\n"; echo "\n"; @@ -975,8 +972,8 @@ function accordion(id, openall) { $link->getFromDBbyOcsServerIDAndGlpiColumn($ID, "contact_num"); $value = (isset($link->fields["ocs_column"]) ? $link->fields["ocs_column"] : ""); - Dropdown::showFromArray("import_contact_num", $opt, array('value' => $value, - 'width' => '100%')); + Dropdown::showFromArray("import_contact_num", $opt, ['value' => $value, + 'width' => '100%']); echo "\n"; @@ -986,8 +983,8 @@ function accordion(id, openall) { $link->getFromDBbyOcsServerIDAndGlpiColumn($ID, "networks_id"); $value = (isset($link->fields["ocs_column"]) ? $link->fields["ocs_column"] : ""); - Dropdown::showFromArray("import_network", $opt, array('value' => $value, - 'width' => '100%')); + Dropdown::showFromArray("import_network", $opt, ['value' => $value, + 'width' => '100%']); echo "\n"; $opt_date = self::getColumnListFromAccountInfoTable($ID, 'hardware'); @@ -997,8 +994,8 @@ function accordion(id, openall) { $link->getFromDBbyOcsServerIDAndGlpiColumn($ID, "use_date"); $value = (isset($link->fields["ocs_column"]) ? $link->fields["ocs_column"] : ""); - Dropdown::showFromArray("import_use_date", $opt_date, array('value' => $value, - 'width' => '100%')); + Dropdown::showFromArray("import_use_date", $opt_date, ['value' => $value, + 'width' => '100%']); echo "\n"; echo "
"; echo __('If you not find your OCSNG server in this dropdown, please check if your profile can access it !', 'ocsinventoryng'); @@ -383,7 +382,7 @@ static function setupMenu($plugin_ocsinventoryng_ocsservers_id) { static function importMenu($plugin_ocsinventoryng_ocsservers_id) { global $CFG_GLPI, $DB; $name = ""; - $ocsservers = array(); + $ocsservers = []; $numberActiveServers = countElementsInTable('glpi_plugin_ocsinventoryng_ocsservers', "`is_active`='1'"); if ($numberActiveServers > 0) { echo "request($query) as $data) { $ocsservers[] = $data['id']; } - Dropdown::show('PluginOcsinventoryngOcsServer', array("condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", + Dropdown::show('PluginOcsinventoryngOcsServer', ["condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", "value" => $_SESSION["plugin_ocsinventoryng_ocsservers_id"], "on_change" => "this.form.submit()", - "display_emptychoice" => false)); + "display_emptychoice" => false]); echo "
"; echo __('If you not find your OCSNG server in this dropdown, please check if your profile can access it !', 'ocsinventoryng'); @@ -595,16 +594,15 @@ function form_init_all(form, value) { } JAVASCRIPT; - Dropdown::showYesNo('init_all', 0, -1, array( + Dropdown::showYesNo('init_all', 0, -1, [ 'width' => '10%', 'on_change' => "form_init_all(this.form, this.selectedIndex);" - )); + ]); echo "
\n"; - echo $JS = << function accordion(id, openall) { @@ -790,15 +788,15 @@ function accordion(id, openall) { echo "
" . __('Linked objects', 'ocsinventoryng') . "
" . _n('Device', 'Devices', 2) . " "; - Dropdown::showFromArray("import_periph", $import_array, array('value' => $periph)); + Dropdown::showFromArray("import_periph", $import_array, ['value' => $periph]); echo "" . _n('Monitor', 'Monitors', 2) . ""; - Dropdown::showFromArray("import_monitor", $import_array2, array('value' => $monitor)); + Dropdown::showFromArray("import_monitor", $import_array2, ['value' => $monitor]); echo "
" . __('Comments') . " " . _n('Monitor', 'Monitors', 2) . " "; Dropdown::showYesNo("import_monitor_comment", $this->fields["import_monitor_comment"]); echo "" . _n('Printer', 'Printers', 2) . ""; - Dropdown::showFromArray("import_printer", $import_array, array('value' => $printer)); + Dropdown::showFromArray("import_printer", $import_array, ['value' => $printer]); echo "
" . _n('Software', 'Software', 2) . ""; - $import_array = array("0" => __('No import'), - "1" => __('Unit import', 'ocsinventoryng')); - Dropdown::showFromArray("import_software", $import_array, array('value' => $software)); + $import_array = ["0" => __('No import'), + "1" => __('Unit import', 'ocsinventoryng')]; + Dropdown::showFromArray("import_software", $import_array, ['value' => $software]); echo "" . _n('Volume', 'Volumes', 2) . ""; Dropdown::showYesNo("import_disk", $this->fields["import_disk"]); @@ -883,7 +881,6 @@ function accordion(id, openall) { Html::showToolTip(nl2br(__('Winupdate Plugin for OCSNG (https://github.com/PluginsOCSInventory-NG/winupdate) must be installed', 'ocsinventoryng'))); echo " 
" . __('Teamviewer', 'ocsinventoryng') . ""; Dropdown::showYesNo("import_teamviewer", $this->fields["import_teamviewer"]); echo " "; @@ -946,8 +943,8 @@ function accordion(id, openall) { $link->getFromDBbyOcsServerIDAndGlpiColumn($ID, "otherserial"); $value = (isset($link->fields["ocs_column"]) ? $link->fields["ocs_column"] : ""); - Dropdown::showFromArray("import_otherserial", $oserial, array('value' => $value, - 'width' => '100%')); + Dropdown::showFromArray("import_otherserial", $oserial, ['value' => $value, + 'width' => '100%']); echo "" . __('Location') . " "; @@ -955,8 +952,8 @@ function accordion(id, openall) { $link->getFromDBbyOcsServerIDAndGlpiColumn($ID, "locations_id"); $value = (isset($link->fields["ocs_column"]) ? $link->fields["ocs_column"] : ""); - Dropdown::showFromArray("import_location", $opt, array('value' => $value, - 'width' => '100%')); + Dropdown::showFromArray("import_location", $opt, ['value' => $value, + 'width' => '100%']); echo "
" . __('Group') . " " . __('Alternate username number') . "
"; @@ -1052,10 +1049,10 @@ function form_init_all(form, value) { } JAVASCRIPT; - Dropdown::showYesNo('init_all', 0, -1, array( + Dropdown::showYesNo('init_all', 0, -1, [ 'width' => '10%', 'on_change' => "form_init_all(this.form, this.selectedIndex);" - )); + ]); echo ""; echo " " . __('General history', 'ocsinventoryng') . @@ -1178,14 +1175,14 @@ function ocsFormImportOptions($ID) { echo "" . __('Default status', 'ocsinventoryng') . "\n"; - State::dropdown(array('name' => 'states_id_default', - 'value' => $this->fields["states_id_default"])); + State::dropdown(['name' => 'states_id_default', + 'value' => $this->fields["states_id_default"]]); echo "\n"; echo "" . __('Behavior when disconnecting', 'ocsinventoryng') . "\n"; - Dropdown::showFromArray("deconnection_behavior", array('' => __('Preserve link', 'ocsinventoryng'), + Dropdown::showFromArray("deconnection_behavior", ['' => __('Preserve link', 'ocsinventoryng'), "trash" => __('Put the link in dustbin and add a lock', 'ocsinventoryng'), - "delete" => __('Delete the link permanently', 'ocsinventoryng')), array('value' => $this->fields["deconnection_behavior"])); + "delete" => __('Delete the link permanently', 'ocsinventoryng')], ['value' => $this->fields["deconnection_behavior"]]); echo "\n"; echo ""; echo __("Define the action to do on link with other objects when computer is disconnecting from them", 'ocsinventoryng'); @@ -1201,9 +1198,9 @@ function ocsFormImportOptions($ID) { echo "" . __('Number of items to synchronize via the automatic OCSNG action', 'ocsinventoryng') . "\n"; - Dropdown::showNumber('cron_sync_number', array('value' => $this->fields['cron_sync_number'], + Dropdown::showNumber('cron_sync_number', ['value' => $this->fields['cron_sync_number'], 'min' => 1, - 'toadd' => array(0 => __('None')))); + 'toadd' => [0 => __('None')]]); echo ""; echo ""; @@ -1220,7 +1217,7 @@ function ocsFormImportOptions($ID) { foreach (getAllDatasFromTable('glpi_states') as $state) { $actions['STATE_' . $state['id']] = sprintf(__('Change to state %s', 'ocsinventoryng'), $state['name']); } - Dropdown::showFromArray('deleted_behavior', $actions, array('value' => $this->fields['deleted_behavior'])); + Dropdown::showFromArray('deleted_behavior', $actions, ['value' => $this->fields['deleted_behavior']]); echo ""; echo ""; @@ -1255,26 +1252,26 @@ function post_getEmpty() { * * @return Nothing (display) * */ - function showForm($ID, $options = array()) { + function showForm($ID, $options = []) { $this->initForm($ID, $options); $this->showFormHeader($options); - $conn_type_values = array( + $conn_type_values = [ 0 => __('Database', 'ocsinventoryng'), //1 => __('Webservice (SOAP)', 'ocsinventoryng'), - ); + ]; - $sync_method_values = array( + $sync_method_values = [ 0 => __("Standard (allow manual actions)", "ocsinventoryng"), 1 => __("Expert (Fully automatic, for large configuration)", "ocsinventoryng") - ); + ]; echo ""; echo "" . __('Connection type', 'ocsinventoryng') . ""; echo ""; - Dropdown::showFromArray('conn_type', $conn_type_values, array('value' => $this->fields['conn_type'], - 'on_change' => "form_init_all(this.form, this.selectedIndex);")); + Dropdown::showFromArray('conn_type', $conn_type_values, ['value' => $this->fields['conn_type'], + 'on_change' => "form_init_all(this.form, this.selectedIndex);"]); echo ""; echo "" . __("Active") . ""; echo ""; @@ -1296,7 +1293,7 @@ function showForm($ID, $options = array()) { echo " "; Html::showSimpleForm(Toolbox::getItemTypeFormURL("PluginOcsinventoryngOcsServer"), 'force_checksum', _sx('button', 'Reload Checksum', 'ocsinventoryng'), - array('id' => $ID)); + ['id' => $ID]); } echo ""; echo ""; @@ -1309,7 +1306,7 @@ function showForm($ID, $options = array()) { echo ""; echo "" . __("Synchronisation method", "ocsinventoryng") . ""; echo ""; - Dropdown::showFromArray('use_massimport', $sync_method_values, array('value' => $this->fields['use_massimport'])); + Dropdown::showFromArray('use_massimport', $sync_method_values, ['value' => $this->fields['use_massimport']]); echo ""; echo ""; @@ -1344,7 +1341,7 @@ function showForm($ID, $options = array()) { echo ""; echo "" . __('Use automatic action for clean old agents & drop from OCSNG software', 'ocsinventoryng') . ""; echo ""; - Dropdown::showYesNo("use_cleancron", $this->fields["use_cleancron"], -1, array('on_change' => 'hide_show_cleancron(this.value);')); + Dropdown::showYesNo("use_cleancron", $this->fields["use_cleancron"], -1, ['on_change' => 'hide_show_cleancron(this.value);']); echo ""; echo Html::scriptBlock(" function hide_show_cleancron(val) { @@ -1361,7 +1358,7 @@ function hide_show_cleancron(val) { echo "" . __("Action") . ""; $actions = self::getValuesActionCron(); echo ""; - Dropdown::showFromArray("action_cleancron", $actions, array('value' => $this->fields["action_cleancron"])); + Dropdown::showFromArray("action_cleancron", $actions, ['value' => $this->fields["action_cleancron"]]); echo ""; echo ""; @@ -1370,7 +1367,7 @@ function hide_show_cleancron(val) { echo ""; echo "" . __('Use automatic action restore deleted computer', 'ocsinventoryng') . ""; echo ""; - Dropdown::showYesNo("use_restorationcron", $this->fields["use_restorationcron"], -1, array('on_change' => 'hide_show_restorecron(this.value);')); + Dropdown::showYesNo("use_restorationcron", $this->fields["use_restorationcron"], -1, ['on_change' => 'hide_show_restorecron(this.value);']); echo ""; echo Html::scriptBlock(" @@ -1386,7 +1383,7 @@ function hide_show_restorecron(val) { echo "" . __("Number of days for the restoration of computers from the date of last inventory", "ocsinventoryng") . ""; echo ""; - Dropdown::showNumber("delay_restorationcron", array('value' => $this->fields["delay_restorationcron"])); + Dropdown::showNumber("delay_restorationcron", ['value' => $this->fields["delay_restorationcron"]]); echo ""; echo ""; @@ -1417,7 +1414,7 @@ function hide_show_restorecron(val) { * @return type */ static function getValuesActionCron() { - $values = array(); + $values = []; $values[self::ACTION_PURGE_COMPUTER] = self::getActionCronName(self::ACTION_PURGE_COMPUTER); $values[self::ACTION_DELETE_COMPUTER] = self::getActionCronName(self::ACTION_DELETE_COMPUTER); @@ -1514,8 +1511,7 @@ function pre_updateInDB() { // Update checksum $checksum = 0; - if ( - //$this->fields["import_device_processor"] || + if (//$this->fields["import_device_processor"] || $this->fields["import_general_contact"] || $this->fields["import_general_comment"] || $this->fields["import_general_domain"] @@ -1629,13 +1625,13 @@ function post_addItem() { function cleanDBonPurge() { $link = new PluginOcsinventoryngOcslink(); - $link->deleteByCriteria(array('plugin_ocsinventoryng_ocsservers_id' => $this->fields['id'])); + $link->deleteByCriteria(['plugin_ocsinventoryng_ocsservers_id' => $this->fields['id']]); $admin = new PluginOcsinventoryngOcsAdminInfosLink(); - $admin->deleteByCriteria(array('plugin_ocsinventoryng_ocsservers_id' => $this->fields['id'])); + $admin->deleteByCriteria(['plugin_ocsinventoryng_ocsservers_id' => $this->fields['id']]); $server = new PluginOcsinventoryngServer(); - $server->deleteByCriteria(array('plugin_ocsinventoryng_ocsservers_id' => $this->fields['id'])); + $server->deleteByCriteria(['plugin_ocsinventoryng_ocsservers_id' => $this->fields['id']]); unset($_SESSION["plugin_ocsinventoryng_ocsservers_id"]); @@ -1964,11 +1960,11 @@ static function linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $comp } } } - $options = array( - "DISPLAY" => array( + $options = [ + "DISPLAY" => [ "CHECKSUM" => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS | PluginOcsinventoryngOcsClient::CHECKSUM_NETWORK_ADAPTERS, - ) - ); + ] + ]; $ocsComputer = $ocsClient->getComputer($ocsid, $options); $serial = (isset($ocsComputer['BIOS']["SSN"])) ? $ocsComputer['BIOS']["SSN"] : ""; @@ -2024,7 +2020,7 @@ static function linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $comp $comp->update($input, $cfg_ocs['history_hardware']); // Auto restore if deleted if ($comp->fields['is_deleted']) { - $comp->restore(array('id' => $computers_id)); + $comp->restore(['id' => $computers_id]); } // Reset only if not in ocs id change case @@ -2184,10 +2180,10 @@ public static function checkVersion($ID) { if ($version) { $server = new self(); - $server->update(array( + $server->update([ 'id' => $ID, 'ocs_version' => $version - )); + ]); } return true; if (!$version || ($version < self::OCS_VERSION_LIMIT && strpos($version, '2.0') !== 0)) { // hack for 2.0 RC @@ -2272,7 +2268,7 @@ static function manageDeleted($plugin_ocsinventoryng_ocsservers_id, $redirect = AND `plugin_ocsinventoryng_ocsservers_id` = '$plugin_ocsinventoryng_ocsservers_id'"; $DB->query($query); // for history, see below - $data = array('ID' => $equiv); + $data = ['ID' => $equiv]; } } //foreach($ocs_deviceid as $deviceid => $equiv){ @@ -2302,7 +2298,7 @@ static function manageDeleted($plugin_ocsinventoryng_ocsservers_id, $redirect = } } } else { // Deleted - $ocslinks_toclean = array(); + $ocslinks_toclean = []; if (strstr($del, "-")) { $link = "ocs_deviceid"; } else { @@ -2378,7 +2374,7 @@ static function deleteComputers($plugin_ocsinventoryng_ocsservers_id, $agents) { if (!$computer->fields['is_deleted']) { $computer->fields['is_deleted'] = 1; $computer->fields['date_mod'] = $_SESSION['glpi_currenttime']; - $computer->updateInDB(array('is_deleted', 'date_mod')); + $computer->updateInDB(['is_deleted', 'date_mod']); //add history $changes[0] = 0; $changes[2] = ""; @@ -2404,23 +2400,23 @@ static function deleteComputers($plugin_ocsinventoryng_ocsservers_id, $agents) { static function getOcsFieldsMatching() { // Manufacturer and Model both as text (for rules) and as id (for import) - return array('manufacturer' => array('BIOS', 'SMANUFACTURER'), - 'manufacturers_id' => array('BIOS', 'SMANUFACTURER'), - 'license_number' => array('HARDWARE', 'WINPRODKEY'), - 'license_id' => array('HARDWARE', 'WINPRODID'), - 'operatingsystems_id' => array('HARDWARE', 'OSNAME'), - 'operatingsystemversions_id' => array('HARDWARE', 'OSVERSION'), - 'operatingsystemarchitectures_id' => array('HARDWARE', 'ARCH'), - 'operatingsystemservicepacks_id' => array('HARDWARE', 'OSCOMMENTS'), - 'domains_id' => array('HARDWARE', 'WORKGROUP'), - 'contact' => array('HARDWARE', 'USERID'), - 'name' => array('META', 'NAME'), - 'comment' => array('HARDWARE', 'DESCRIPTION'), - 'serial' => array('BIOS', 'SSN'), - 'model' => array('BIOS', 'SMODEL'), - 'computermodels_id' => array('BIOS', 'SMODEL'), - 'TAG' => array('ACCOUNTINFO', 'TAG') - ); + return ['manufacturer' => ['BIOS', 'SMANUFACTURER'], + 'manufacturers_id' => ['BIOS', 'SMANUFACTURER'], + 'license_number' => ['HARDWARE', 'WINPRODKEY'], + 'license_id' => ['HARDWARE', 'WINPRODID'], + 'operatingsystems_id' => ['HARDWARE', 'OSNAME'], + 'operatingsystemversions_id' => ['HARDWARE', 'OSVERSION'], + 'operatingsystemarchitectures_id' => ['HARDWARE', 'ARCH'], + 'operatingsystemservicepacks_id' => ['HARDWARE', 'OSCOMMENTS'], + 'domains_id' => ['HARDWARE', 'WORKGROUP'], + 'contact' => ['HARDWARE', 'USERID'], + 'name' => ['META', 'NAME'], + 'comment' => ['HARDWARE', 'DESCRIPTION'], + 'serial' => ['BIOS', 'SSN'], + 'model' => ['BIOS', 'SMODEL'], + 'computermodels_id' => ['BIOS', 'SMODEL'], + 'TAG' => ['ACCOUNTINFO', 'TAG'] + ]; } /** @@ -2431,8 +2427,8 @@ static function getOcsFieldsMatching() { * * @return array */ - static function getComputerInformations($ocs_fields = array(), $cfg_ocs, $entities_id, $locations_id = 0, $groups_id = 0) { - $input = array(); + static function getComputerInformations($ocs_fields = [], $cfg_ocs, $entities_id, $locations_id = 0, $groups_id = 0) { + $input = []; $input["is_dynamic"] = 1; if ($cfg_ocs["states_id_default"] > 0) { @@ -2475,7 +2471,7 @@ static function getComputerInformations($ocs_fields = array(), $cfg_ocs, $entiti continue; } $itemtype = getItemTypeForTable($table); - $external_params = array(); + $external_params = []; foreach ($item->additional_fields_for_dictionnary as $field) { $additional_ocs_section = $ocs_fields_matching[$field][0]; @@ -2580,19 +2576,19 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo $cfg_ocs = self::getConfig($plugin_ocsinventoryng_ocsservers_id); $comp = new Computer(); - $rules_matched = array(); + $rules_matched = []; $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id); $ocsClient->setChecksum(PluginOcsinventoryngOcsClient::CHECKSUM_ALL, $ocsid); - $ocsComputer = $ocsClient->getComputer($ocsid, array( - 'DISPLAY' => array( + $ocsComputer = $ocsClient->getComputer($ocsid, [ + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE | PluginOcsinventoryngOcsClient::CHECKSUM_BIOS, 'WANTED' => PluginOcsinventoryngOcsClient::WANTED_ACCOUNTINFO - ) - )); + ] + ]); - $locations_id = 0; - $groups_id = 0; + $locations_id = 0; + $groups_id = 0; $contact = (isset($ocsComputer['META']["USERID"])) ? $ocsComputer['META']["USERID"] : ""; if (!empty($contact) && $cfg_ocs["import_general_contact"] > 0) { $query = "SELECT `id` @@ -2617,20 +2613,20 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo if ($defaultentity == -1 && ($defaultlocation == -1 || $defaultlocation == 0)) { //Try to affect computer to an entity $rule = new RuleImportEntityCollection(); - $data = array(); - $data = $rule->processAllRules(array('ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, + $data = []; + $data = $rule->processAllRules(['ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, '_source' => 'ocsinventoryng', 'locations_id' => $locations_id, 'groups_id' => $groups_id - ), array( + ], [ 'locations_id' => $locations_id, 'groups_id' => $groups_id - ), array('ocsid' => $ocsid)); + ], ['ocsid' => $ocsid]); if (isset($data['_ignore_import']) && $data['_ignore_import'] == 1) { //ELSE Return code to indicates that the machine was not imported because it doesn't matched rules - return array('status' => self::COMPUTER_LINK_REFUSED, - 'rule_matched' => $data['_ruleid']); + return ['status' => self::COMPUTER_LINK_REFUSED, + 'rule_matched' => $data['_ruleid']]; } } else { //An entity or a location has already been defined via the web interface @@ -2660,12 +2656,12 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo $data['entities_id'], $locations_id, $groups_id); //Check if machine could be linked with another one already in DB $rulelink = new RuleImportComputerCollection(); - $rulelink_results = array(); - $params = array('entities_id' => $data['entities_id'], + $rulelink_results = []; + $params = ['entities_id' => $data['entities_id'], 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, - 'ocsid' => $ocsid); - $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($input), array(), $params); + 'ocsid' => $ocsid]; + $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($input), [], $params); //If at least one rule matched //else do import as usual @@ -2674,9 +2670,9 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo switch ($rulelink_results['action']) { case self::LINK_RESULT_NO_IMPORT : - return array('status' => self::COMPUTER_LINK_REFUSED, + return ['status' => self::COMPUTER_LINK_REFUSED, 'entities_id' => $data['entities_id'], - 'rule_matched' => $rules_matched); + 'rule_matched' => $rules_matched]; case self::LINK_RESULT_LINK : if (is_array($rulelink_results['found_computers']) && count($rulelink_results['found_computers']) > 0) { @@ -2684,10 +2680,10 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo foreach ($rulelink_results['found_computers'] as $tmp => $computers_id) { if (self::linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id)) { - return array('status' => self::COMPUTER_LINKED, + return ['status' => self::COMPUTER_LINKED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched, - 'computers_id' => $computers_id); + 'computers_id' => $computers_id]; } } break; @@ -2695,7 +2691,7 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo } } //ADD IF NOT LINKED - $computers_id = $comp->add($input, array('unicity_error_message' => false)); + $computers_id = $comp->add($input, ['unicity_error_message' => false]); if ($computers_id) { $ocsid = $computer['META']['ID']; $changes[0] = '0'; @@ -2710,14 +2706,14 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo //Return code to indicates that the machine was imported // var_dump("post",$_POST,"session",$_SESSION,"server",$_SERVER,"get",$_GET,"cookie",$_COOKIE,"request",$_REQUEST); //die("lets see the thisngs in post get session, cookie and reques"); - return array('status' => self::COMPUTER_IMPORTED, + return ['status' => self::COMPUTER_IMPORTED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched, - 'computers_id' => $computers_id); + 'computers_id' => $computers_id]; } - return array('status' => self::COMPUTER_NOT_UNIQUE, + return ['status' => self::COMPUTER_NOT_UNIQUE, 'entities_id' => $data['entities_id'], - 'rule_matched' => $rules_matched); + 'rule_matched' => $rules_matched]; } if ($lock) { @@ -2725,8 +2721,8 @@ static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lo } } //ELSE Return code to indicates that the machine was not imported because it doesn't matched rules - return array('status' => self::COMPUTER_FAILED_IMPORT, - 'rule_matched' => $rules_matched); + return ['status' => self::COMPUTER_FAILED_IMPORT, + 'rule_matched' => $rules_matched]; } /** Update a ocs computer @@ -2757,11 +2753,11 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis $comp = new Computer(); $comp->getFromDB($line["computers_id"]); $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id); - $options = array( - "DISPLAY" => array( + $options = [ + "DISPLAY" => [ "CHECKSUM" => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE, - ) - ); + ] + ]; $computer = $ocsClient->getComputer($line['ocsid'], $options); $data_ocs = $computer; @@ -2804,14 +2800,14 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis } $rule = new RuleImportEntityCollection(); - $data = array(); - $data = $rule->processAllRules(array('ocsservers_id' => $line["plugin_ocsinventoryng_ocsservers_id"], + $data = []; + $data = $rule->processAllRules(['ocsservers_id' => $line["plugin_ocsinventoryng_ocsservers_id"], '_source' => 'ocsinventoryng', 'locations_id' => $locations_id, - 'groups_id' => $groups_id), - array('locations_id' => $locations_id, - 'groups_id' => $groups_id), - array('ocsid' => $line["ocsid"])); + 'groups_id' => $groups_id], + ['locations_id' => $locations_id, + 'groups_id' => $groups_id], + ['ocsid' => $line["ocsid"]]); self::updateComputerFields($line, $data, $cfg_ocs); } @@ -2966,8 +2962,8 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis $computer_updates = self::migrateComputerUpdates($line["computers_id"], $computer_updates); } - $ocsCheck = array(); - $ocsPlugins = array(); + $ocsCheck = []; + $ocsPlugins = []; if ($mixed_checksum & pow(2, self::HARDWARE_FL)) { $hardware = true; $ocsCheck[] = PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE; @@ -3034,7 +3030,6 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis } if ($mixed_checksum & pow(2, self::NETWORKS_FL)) { - if ($cfg_ocs["import_device_iface"] || $cfg_ocs["import_ip"] ) { @@ -3162,7 +3157,7 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis if (!isset($ocsWanted)) { $ocsWanted = 0; } - $ocsPluginsResult = array(); + $ocsPluginsResult = []; if ($ocsPlugins) { $ocsPluginsResult = $ocsPlugins[0]; foreach ($ocsPlugins as $plug) { @@ -3172,13 +3167,13 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis $ocsPluginsResult = 0; } - $import_options = array( - 'DISPLAY' => array( + $import_options = [ + 'DISPLAY' => [ 'CHECKSUM' => $ocsCheckResult, 'WANTED' => $ocsWanted, 'PLUGINS' => $ocsPluginsResult - ), - ); + ], + ]; $ocsComputer = $ocsClient->getComputer($line['ocsid'], $import_options); @@ -3190,21 +3185,21 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis $loghistory["history"] = $cfg_ocs['history_hardware']; if ($hardware) { - $p = array('computers_id' => $line['computers_id'], + $p = ['computers_id' => $line['computers_id'], 'ocs_id' => $line['ocsid'], 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, 'cfg_ocs' => $cfg_ocs, 'computers_updates' => $computer_updates, 'dohistory' => $cfg_ocs['history_hardware'], 'check_history' => true, - 'entities_id' => $comp->fields['entities_id']); + 'entities_id' => $comp->fields['entities_id']]; self::updateHardware($p); } if ($bios) { self::updateComputerFromBios($line['computers_id'], $ocsComputer, $cfg_ocs, $computer_updates, $comp->fields['entities_id']); } // Get import devices - $import_device = array(); + $import_device = []; $types = $CFG_GLPI['ocsinventoryng_devices_index']; foreach ($types as $old => $type) { $associated_type = str_replace('Item_', '', $type); @@ -3258,7 +3253,7 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis self::updateDevices("Item_DeviceSoundCard", $line['computers_id'], $ocsComputer['SOUNDS'], $cfg_ocs, $import_device, ''); } if ($networks && isset($ocsComputer['NETWORKS'])) { - self::updateDevices("Item_DeviceNetworkCard", $line['computers_id'], $ocsComputer['NETWORKS'], $cfg_ocs, $import_device, array()); + self::updateDevices("Item_DeviceNetworkCard", $line['computers_id'], $ocsComputer['NETWORKS'], $cfg_ocs, $import_device, []); } if ($modems && isset($ocsComputer['MODEMS'])) { self::updateDevices("Item_DevicePci", $line['computers_id'], $ocsComputer, $cfg_ocs, $import_device, ''); @@ -3342,16 +3337,16 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis $newchecksum = $oldChecksum - $mixed_checksum; $ocsClient->setChecksum($newchecksum, $line['ocsid']); //Return code to indicate that computer was synchronized - return array('status' => self::COMPUTER_SYNCHRONIZED, + return ['status' => self::COMPUTER_SYNCHRONIZED, 'entities_id' => $comp->fields["entities_id"], - 'rule_matched' => array(), - 'computers_id' => $line['computers_id']); + 'rule_matched' => [], + 'computers_id' => $line['computers_id']]; } // ELSE Return code to indicate only last inventory date changed - return array('status' => self::COMPUTER_NOTUPDATED, + return ['status' => self::COMPUTER_NOTUPDATED, 'entities_id' => $comp->fields["entities_id"], - 'rule_matched' => array(), - 'computers_id' => $line['computers_id']); + 'rule_matched' => [], + 'computers_id' => $line['computers_id']]; } } @@ -3360,14 +3355,14 @@ static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohis * * @return array */ - static function setComputerHardware($params = array()) { + static function setComputerHardware($params = []) { global $DB; $options['computers_id'] = 0; $options['ocs_id'] = 0; $options['plugin_ocsinventoryng_ocsservers_id'] = 0; - $options['cfg_ocs'] = array(); - $options['computers_update'] = array(); + $options['cfg_ocs'] = []; + $options['computers_update'] = []; $options['check_history'] = true; $options['do_history'] = 2; @@ -3381,11 +3376,11 @@ static function setComputerHardware($params = array()) { // self::checkOCSconnection($ocsServerId); $ocsClient = self::getDBocs($ocsServerId); - $opts = array( - 'DISPLAY' => array( + $opts = [ + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE - ) - ); + ] + ]; $ocsComputer = $ocsClient->getComputer($options['ocs_id'], $opts); $options['do_history'] = $options['cfg_ocs']["history_hardware"]; @@ -3393,7 +3388,7 @@ static function setComputerHardware($params = array()) { if ($ocsComputer) { $hardware = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsComputer['HARDWARE'])); - $updates = array(); + $updates = []; if (intval($options['cfg_ocs']["import_general_domain"]) > 0 && !in_array("domains_id", $options['computers_updates'])) { @@ -3446,7 +3441,7 @@ static function setComputerHardware($params = array()) { $updates["uuid"] = $hardware["UUID"]; } - $results = array(); + $results = []; if (count($updates)) { $updates["id"] = $options['computers_id']; $updates["entities_id"] = $options['entities_id']; @@ -3462,14 +3457,14 @@ static function setComputerHardware($params = array()) { * * @return array */ - static function setComputerOS($params = array()) { + static function setComputerOS($params = []) { global $DB; $options['computers_id'] = 0; $options['ocs_id'] = 0; $options['plugin_ocsinventoryng_ocsservers_id'] = 0; - $options['cfg_ocs'] = array(); - $options['computers_update'] = array(); + $options['cfg_ocs'] = []; + $options['computers_update'] = []; $options['check_history'] = true; $options['do_history'] = 2; @@ -3481,11 +3476,11 @@ static function setComputerOS($params = array()) { $ocsServerId = $options['plugin_ocsinventoryng_ocsservers_id']; $ocsClient = self::getDBocs($ocsServerId); - $opts = array( - 'DISPLAY' => array( + $opts = [ + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE - ) - ); + ] + ]; $ocsComputer = $ocsClient->getComputer($options['ocs_id'], $opts); $options['do_history'] = $options['cfg_ocs']["history_hardware"]; @@ -3493,7 +3488,7 @@ static function setComputerOS($params = array()) { if ($ocsComputer) { $hardware = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsComputer['HARDWARE'])); $updates = 0; - $license_number = NULL; + $license_number = null; if (intval($options['cfg_ocs']["import_os_serial"]) > 0 && !in_array("license_number", $options['computers_updates']) ) { @@ -3503,7 +3498,7 @@ static function setComputerOS($params = array()) { $updates++; } } - $license_id = NULL; + $license_id = null; if (intval($options['cfg_ocs']["import_os_serial"]) > 0 && !in_array("license_id", $options['computers_updates']) ) { @@ -3594,7 +3589,7 @@ static function setComputerOS($params = array()) { $device = new Item_OperatingSystem(); // if ($operatingsystems_id) { - $device->add(array('items_id' => $options['computers_id'], + $device->add(['items_id' => $options['computers_id'], 'itemtype' => 'Computer', 'operatingsystems_id' => $operatingsystems_id, 'operatingsystemversions_id' => $operatingsystemversions_id, @@ -3605,7 +3600,7 @@ static function setComputerOS($params = array()) { '_nolock' => true, 'is_dynamic' => 1, 'entities_id' => $options['entities_id'] - ), array(), $options['dohistory']); + ], [], $options['dohistory']); // } } } @@ -3617,16 +3612,16 @@ static function setComputerOS($params = array()) { * @param $params array * */ - static function updateHardware($params = array()) { + static function updateHardware($params = []) { - $p = array('computers_id' => 0, + $p = ['computers_id' => 0, 'ocs_id' => 0, 'plugin_ocsinventoryng_ocsservers_id' => 0, - 'cfg_ocs' => array(), - 'computers_updates' => array(), + 'cfg_ocs' => [], + 'computers_updates' => [], 'dohistory' => true, 'check_history' => true, - 'entities_id' => 0); + 'entities_id' => 0]; foreach ($params as $key => $value) { $p[$key] = $value; } @@ -3656,10 +3651,10 @@ static function updateHardware($params = array()) { */ static function updateComputerFromBios($computers_id, $ocsComputer, $cfg_ocs, $computer_updates, $entities_id = 0) { - $compupdate = array(); + $compupdate = []; $computer = $ocsComputer; if (!is_null($computer)) { - $compudate = array(); + $compudate = []; if (isset($computer["BIOS"])) { @@ -3678,7 +3673,7 @@ static function updateComputerFromBios($computers_id, $ocsComputer, $cfg_ocs, $c && !in_array("computermodels_id", $computer_updates) ) { - $compupdate["computermodels_id"] = Dropdown::importExternal('ComputerModel', self::encodeOcsDataInUtf8($cfg_ocs['ocs_db_utf8'], $bios["SMODEL"]), -1, (isset($bios["SMANUFACTURER"]) ? array("manufacturer" => $bios["SMANUFACTURER"]) : array())); + $compupdate["computermodels_id"] = Dropdown::importExternal('ComputerModel', self::encodeOcsDataInUtf8($cfg_ocs['ocs_db_utf8'], $bios["SMODEL"]), -1, (isset($bios["SMANUFACTURER"]) ? ["manufacturer" => $bios["SMANUFACTURER"]] : [])); } if (intval($cfg_ocs["import_general_manufacturer"]) > 0 @@ -3767,9 +3762,9 @@ static function showComputersToClean($plugin_ocsinventoryng_ocsservers_id, $chec // Select unexisting OCS hardware $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id); - $computerOptions = array( + $computerOptions = [ 'COMPLETE' => '0', - ); + ]; $computers = $ocsClient->getComputers($computerOptions); @@ -3777,7 +3772,7 @@ static function showComputersToClean($plugin_ocsinventoryng_ocsservers_id, $chec && count($computers['COMPUTERS']) > 0) { $hardware = $computers['COMPUTERS']; } else { - $hardware = array(); + $hardware = []; } $query = "SELECT `ocsid` @@ -3786,7 +3781,7 @@ static function showComputersToClean($plugin_ocsinventoryng_ocsservers_id, $chec = '$plugin_ocsinventoryng_ocsservers_id'"; $result = $DB->query($query); - $ocs_missing = array(); + $ocs_missing = []; if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_array($result)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); @@ -3820,7 +3815,7 @@ static function showComputersToClean($plugin_ocsinventoryng_ocsservers_id, $chec $result_glpi = $DB->query($query_glpi); // fetch all links missing between glpi and OCS - $already_linked = array(); + $already_linked = []; if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_assoc($result_glpi)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); @@ -3940,7 +3935,7 @@ static function cleanLinksFromList($plugin_ocsinventoryng_ocsservers_id, $ocslin $comp = new Computer(); if ($cfg_ocs['deleted_behavior']) { if ($cfg_ocs['deleted_behavior'] == 1) { - $comp->delete(array("id" => $data["computers_id"]), 0); + $comp->delete(["id" => $data["computers_id"]], 0); } else { if (preg_match('/STATE_(.*)/', $cfg_ocs['deleted_behavior'], $results)) { $tmp['id'] = $data["computers_id"]; @@ -4001,7 +3996,7 @@ static function showComputersToUpdate($plugin_ocsinventoryng_ocsservers_id, $che return; } - $already_linked_ids = array(); + $already_linked_ids = []; while ($data = $DB->fetch_assoc($already_linked_result)) { $already_linked_ids [] = $data['ocsid']; } @@ -4019,22 +4014,22 @@ static function showComputersToUpdate($plugin_ocsinventoryng_ocsservers_id, $che // Fetch linked computers from ocs $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id); - $ocsResult = $ocsClient->getComputers(array( + $ocsResult = $ocsClient->getComputers([ 'ORDER' => 'LASTDATE', 'COMPLETE' => '0', - 'FILTER' => array( + 'FILTER' => [ 'IDS' => $already_linked_ids, 'CHECKSUM' => $cfg_ocs["checksum"], //'INVENTORIED_BEFORE' => 'NOW()', //'INVENTORIED_SINCE' => $max_date, - ) - )); + ] + ]); if (isset($ocsResult['COMPUTERS'])) { if (count($ocsResult['COMPUTERS']) > 0) { // Get all ids of the returned computers - $ocs_computer_ids = array(); - $hardware = array(); + $ocs_computer_ids = []; + $hardware = []; $computers = array_slice($ocsResult['COMPUTERS'], $start, $_SESSION['glpilist_limit']); foreach ($computers as $computer) { $ID = $computer['META']['ID']; @@ -4065,7 +4060,7 @@ static function showComputersToUpdate($plugin_ocsinventoryng_ocsservers_id, $che $result_glpi = $DB->query($query_glpi); // Get all links between glpi and OCS - $already_linked = array(); + $already_linked = []; if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_assoc($result_glpi)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); @@ -4366,7 +4361,7 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity FROM `glpi_plugin_ocsinventoryng_ocslinks` WHERE `plugin_ocsinventoryng_ocsservers_id` = '$serverId'"; $result_glpi = $DB->query($query_glpi); - $already_linked = array(); + $already_linked = []; if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_array($result_glpi)) { $already_linked [] = $data["ocsid"]; @@ -4374,16 +4369,16 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity } $cfg_ocs = self::getConfig($serverId); - $computerOptions = array('ORDER' => 'LASTDATE', + $computerOptions = ['ORDER' => 'LASTDATE', 'COMPLETE' => '0', - 'FILTER' => array( + 'FILTER' => [ 'EXCLUDE_IDS' => $already_linked - ), - 'DISPLAY' => array( + ], + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS | PluginOcsinventoryngOcsClient::CHECKSUM_NETWORK_ADAPTERS - ), + ], 'ORDER' => 'NAME' - ); + ]; if ($cfg_ocs["tag_limit"] and $tag_limit = explode("$", trim($cfg_ocs["tag_limit"]))) { $computerOptions['FILTER']['TAGS'] = $tag_limit; @@ -4402,9 +4397,9 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity $computerOptions['MAX_RECORDS'] = $_SESSION['glpilist_limit']; $ocsResult = $ocsClient->getComputers($computerOptions); - $computers = (isset($ocsResult['COMPUTERS']) ? $ocsResult['COMPUTERS'] : array()); + $computers = (isset($ocsResult['COMPUTERS']) ? $ocsResult['COMPUTERS'] : []); - $hardware = array(); + $hardware = []; if (isset($computers)) { if (count($computers)) { // Get all hardware from OCS DB @@ -4470,9 +4465,9 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity echo "" . __('Manual import mode', 'ocsinventoryng') . "\n"; echo ""; if ($advanced) { - Html::showSimpleForm($target, 'change_import_mode', __('Disable preview', 'ocsinventoryng'), array('id' => 'false')); + Html::showSimpleForm($target, 'change_import_mode', __('Disable preview', 'ocsinventoryng'), ['id' => 'false']); } else { - Html::showSimpleForm($target, 'change_import_mode', __('Enable preview', 'ocsinventoryng'), array('id' => 'true')); + Html::showSimpleForm($target, 'change_import_mode', __('Enable preview', 'ocsinventoryng'), ['id' => 'true']); } echo ""; echo "" . @@ -4506,7 +4501,7 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; - } elseif (!$tolinked && $caneditimport) { + } else if (!$tolinked && $caneditimport) { echo ""; } @@ -4514,7 +4509,7 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity echo "\n"; echo ""; if ($usecheckbox) { - echo " "; + echo " "; } echo "" . __('Name') . "\n"; echo "" . __('Manufacturer') . "\n"; @@ -4536,21 +4531,21 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity foreach ($hardware as $ID => $tab) { //$comp = new Computer(); //$comp->fields["id"] = $tab["id"]; - $data = array(); + $data = []; echo ""; if ($usecheckbox) { - echo ""; - echo ""; + echo ""; - echo ""; + echo ""; } if ($advanced && !$tolinked) { $location = isset($tab["locations_id"]) ? $tab["locations_id"] : 0; - $data = $rule->processAllRules(array('ocsservers_id' => $serverId, + $data = $rule->processAllRules(['ocsservers_id' => $serverId, '_source' => 'ocsinventoryng', 'locations_id' => $location - ), array('locations_id' => $location), array('ocsid' => $tab["id"])); + ], ['locations_id' => $location], ['ocsid' => $tab["id"]]); } echo "" . $tab["name"] . "\n"; echo "" . $tab["manufacturer"] . ""; @@ -4631,18 +4626,18 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity } echo ""; $ent = "toimport_entities[" . $tab["id"] . "]"; - Entity::dropdown(array('name' => $ent, + Entity::dropdown(['name' => $ent, 'value' => $data['entities_id'], - 'comments' => 0)); + 'comments' => 0]); echo "\n"; echo ""; if (!isset($data['locations_id'])) { $data['locations_id'] = 0; } $loc = "toimport_locations[" . $tab["id"] . "]"; - Location::dropdown(array('name' => $loc, + Location::dropdown(['name' => $loc, 'value' => $data['locations_id'], - 'comments' => 0)); + 'comments' => 0]); echo "\n"; } @@ -4651,13 +4646,13 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity echo ""; $tab['entities_id'] = $entity; $rulelink = new RuleImportComputerCollection(); - $params = array('entities_id' => $entity, + $params = ['entities_id' => $entity, 'plugin_ocsinventoryng_ocsservers_id' - => $serverId); - $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), array(), $params); + => $serverId]; + $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), [], $params); //Look for the computer using automatic link criterias as defined in OCSNG configuration - $options = array('name' => "tolink[" . $tab["id"] . "]"); + $options = ['name' => "tolink[" . $tab["id"] . "]"]; $show_dropdown = true; //If the computer is not explicitly refused by a rule if (!isset($rulelink_results['action']) @@ -4717,7 +4712,7 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity Html::closeForm(); if ($usecheckbox) { - self::checkBox($target); + self::checkBox($target); } Html::printPager($start, $numrows, $target, $parameters); @@ -4772,7 +4767,7 @@ static function showComputersToAdd($serverId, $advanced, $check, $start, $entity */ static function migrateImportDevice($import_device) { - $new_import_device = array(self::IMPORT_TAG_078); + $new_import_device = [self::IMPORT_TAG_078]; if (count($import_device)) { foreach ($import_device as $key => $val) { $tmp = explode(self::FIELD_SEPARATOR, $val); @@ -4800,9 +4795,9 @@ static function migrateImportDevice($import_device) { */ static function migrateComputerUpdates($computers_id, $computer_update) { - $new_computer_update = array(self::IMPORT_TAG_078); + $new_computer_update = [self::IMPORT_TAG_078]; - $updates = array('ID' => 'id', + $updates = ['ID' => 'id', 'FK_entities' => 'entities_id', 'tech_num' => 'users_id_tech', 'comments' => 'comment', @@ -4823,7 +4818,7 @@ static function migrateComputerUpdates($computers_id, $computer_update) { 'ocs_import' => 'is_dynamic', 'FK_users' => 'users_id', 'FK_groups' => 'groups_id', - 'state' => 'states_id'); + 'state' => 'states_id']; if (count($computer_update)) { foreach ($computer_update as $field) { @@ -4958,11 +4953,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceBios = new DeviceFirmware(); $bios_id = $DeviceBios->import($bios); if ($bios_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'devicefirmwares_id' => $bios_id, 'is_dynamic' => 1, - 'entities_id' => $entities_id), array(), $cfg_ocs['history_devices']); + 'entities_id' => $entities_id], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $bios["designation"]), $import_device); @@ -5004,19 +4999,19 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceMemory = new DeviceMemory(); $ram_id = $DeviceMemory->import($ram); if ($ram_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicememories_id' => $ram_id, 'size' => $line2["CAPACITY"], - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $ram["designation"]), $import_device); list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp); - $CompDevice->update(array('id' => $id, - 'size' => $line2["CAPACITY"]), $cfg_ocs['history_devices']); + $CompDevice->update(['id' => $id, + 'size' => $line2["CAPACITY"]], $cfg_ocs['history_devices']); unset($import_device[$tmp]); } } @@ -5048,20 +5043,20 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceHardDrive = new DeviceHardDrive(); $dd_id = $DeviceHardDrive->import($dd); if ($dd_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'deviceharddrives_id' => $dd_id, 'serial' => $line2["SERIALNUMBER"], 'capacity' => $line2["DISKSIZE"], - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $dd["designation"]), $import_device); list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp); - $CompDevice->update(array('id' => $id, + $CompDevice->update(['id' => $id, 'capacity' => $line2["DISKSIZE"], - 'serial' => $line2["SERIALNUMBER"]), $cfg_ocs['history_devices']); + 'serial' => $line2["SERIALNUMBER"]], $cfg_ocs['history_devices']); unset($import_device[$tmp]); } } @@ -5089,11 +5084,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceDrive = new DeviceDrive(); $stor_id = $DeviceDrive->import($stor); if ($stor_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicedrives_id' => $stor_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $stor["designation"]), $import_device); @@ -5120,11 +5115,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DevicePci = new DevicePci(); $mdm_id = $DevicePci->import($mdm); if ($mdm_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicepcis_id' => $mdm_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $mdm["designation"]), $import_device); @@ -5155,11 +5150,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DevicePci = new DevicePci(); $port_id = $DevicePci->import($port); if ($port_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicepcis_id' => $port_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $port["designation"]), $import_device); @@ -5189,11 +5184,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DevicePci = new DevicePci(); $pci_id = $DevicePci->import($pci); if ($pci_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicepcis_id' => $pci_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $id = array_search(stripslashes($prevalue . $pci["designation"]), $import_device); @@ -5209,7 +5204,7 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $do_clean = true; foreach ($ocsComputer as $line2) { $line2 = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line2)); - $processor = array(); + $processor = []; $processor["designation"] = $line2["TYPE"]; if (!is_numeric($line2["SPEED"])) { $line2["SPEED"] = 0; @@ -5224,18 +5219,18 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceProcessor = new DeviceProcessor(); $proc_id = $DeviceProcessor->import($processor); if ($proc_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'deviceprocessors_id' => $proc_id, 'frequency' => $line2["SPEED"], - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $processor["designation"]), $import_device); list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp); - $CompDevice->update(array('id' => $id, - 'frequency' => $line2["SPEED"]), $cfg_ocs['history_devices']); + $CompDevice->update(['id' => $id, + 'frequency' => $line2["SPEED"]], $cfg_ocs['history_devices']); unset($import_device[$tmp]); } } @@ -5263,18 +5258,18 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceGraphicCard = new DeviceGraphicCard(); $video_id = $DeviceGraphicCard->import($video); if ($video_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicegraphiccards_id' => $video_id, 'memory' => $line2["MEMORY"], - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $video["designation"]), $import_device); list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp); - $CompDevice->update(array('id' => $id, - 'memory' => $line2["MEMORY"]), $cfg_ocs['history_devices']); + $CompDevice->update(['id' => $id, + 'memory' => $line2["MEMORY"]], $cfg_ocs['history_devices']); unset($import_device[$tmp]); } } @@ -5300,11 +5295,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceSoundCard = new DeviceSoundCard(); $snd_id = $DeviceSoundCard->import($snd); if ($snd_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicesoundcards_id' => $snd_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $id = array_search(stripslashes($prevalue . $snd["designation"]), $import_device); @@ -5328,12 +5323,12 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $devicemotherboards_id = $DeviceMB->import($mb); if ($devicemotherboards_id) { $serial = $ocsComputer["MSN"]; - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'devicemotherboards_id' => $devicemotherboards_id, 'is_dynamic' => 1, 'serial' => $serial, - 'entities_id' => $entities_id), array(), $cfg_ocs['history_devices']); + 'entities_id' => $entities_id], [], $cfg_ocs['history_devices']); } } else { $tmp = array_search(stripslashes($prevalue . $mb["designation"]), $import_device); @@ -5363,11 +5358,11 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs $DeviceControl = new DeviceControl(); $ctrl_id = $DeviceControl->import($ctrl); if ($ctrl_id) { - $CompDevice->add(array('items_id' => $computers_id, + $CompDevice->add(['items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicecontrols_id' => $ctrl_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } else { $id = array_search(stripslashes($prevalue . $ctrl["designation"]), $import_device); @@ -5384,8 +5379,8 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs if (!(strpos($key, $devicetype . '$$') === false)) { list($type, $id) = explode(self::FIELD_SEPARATOR, $key); $CompDevice = new $devicetype(); - $CompDevice->delete(array('id' => $id, - '_no_history' => !$cfg_ocs['history_devices']), true, $cfg_ocs['history_devices']); + $CompDevice->delete(['id' => $id, + '_no_history' => !$cfg_ocs['history_devices']], true, $cfg_ocs['history_devices']); } } } @@ -5395,8 +5390,8 @@ static function updateDevices($devicetype, $computers_id, $ocsComputer, $cfg_ocs foreach ($import_ip as $key => $val) { if ($key > 0) { $netport = new NetworkPort(); - $netport->delete(array('id' => $key, - '_no_history' => !$cfg_ocs['history_network']), 0, $cfg_ocs['history_network']); + $netport->delete(['id' => $key, + '_no_history' => !$cfg_ocs['history_network']], 0, $cfg_ocs['history_network']); } } } @@ -5457,18 +5452,17 @@ static function getComputerLinkToOcsConsole($plugin_ocsinventoryng_ocsservers_id static function getGeneralIpAddress($plugin_ocsinventoryng_ocsservers_id, $computers_id) { self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id); - $options = array( - 'DISPLAY' => array( + $options = [ + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE - ) - ); + ] + ]; $computer = $ocsClient->getComputer($computers_id, $options); $ipaddress = $computer["HARDWARE"]["IPADDR"]; if ($ipaddress) { return $ipaddress; } - return ''; } @@ -5562,7 +5556,7 @@ static function getFormServerAction($ID, $templateid) { */ static function getColumnListFromAccountInfoTable($ID, $table) { - $listColumn = array("0" => __('No import')); + $listColumn = ["0" => __('No import')]; if ($ID != -1) { if (self::checkOCSconnection($ID)) { $ocsClient = self::getDBocs($ID); @@ -5676,9 +5670,9 @@ static function resetDevices($glpi_computers_id, $itemtype, $cfg_ocs) { $linktype = 'Item_' . $itemtype; $item = new $linktype(); - $item->deleteByCriteria(array('items_id' => $glpi_computers_id, + $item->deleteByCriteria(['items_id' => $glpi_computers_id, 'itemtype' => 'Computer', - 'is_dynamic' => 1), 1, $cfg_ocs['history_devices']); + 'is_dynamic' => 1], 1, $cfg_ocs['history_devices']); } @@ -5697,10 +5691,10 @@ static function resetOS($glpi_computers_id, $itemtype, $cfg_ocs) { $linktype = 'Item_' . $itemtype; $item = new $linktype(); - $item->deleteByCriteria(array('items_id' => $glpi_computers_id, + $item->deleteByCriteria(['items_id' => $glpi_computers_id, 'itemtype' => 'Computer', 'is_dynamic' => 1 - ), 1, $cfg_ocs['history_hardware'] + ], 1, $cfg_ocs['history_hardware'] ); } @@ -5749,7 +5743,7 @@ static function resetDropdown($glpi_computers_id, $field, $table) { static function resetRegistry($glpi_computers_id) { $registry = new PluginOcsinventoryngRegistryKey(); - $registry->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $registry->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } /** @@ -5764,8 +5758,8 @@ static function resetRegistry($glpi_computers_id) { static function resetAntivirus($glpi_computers_id, $cfg_ocs) { $av = new ComputerAntivirus(); - $av->deleteByCriteria(array('computers_id' => $glpi_computers_id, - 'is_dynamic' => 1), 1, 1); + $av->deleteByCriteria(['computers_id' => $glpi_computers_id, + 'is_dynamic' => 1], 1, 1); } @@ -5781,7 +5775,7 @@ static function resetAntivirus($glpi_computers_id, $cfg_ocs) { static function resetWinupdatestate($glpi_computers_id, $cfg_ocs) { $win = new PluginOcsinventoryngWinupdate(); - $win->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $win->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5798,7 +5792,7 @@ static function resetWinupdatestate($glpi_computers_id, $cfg_ocs) { static function resetOSInstall($glpi_computers_id, $cfg_ocs) { $os = new PluginOcsinventoryngOsinstall(); - $os->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $os->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5814,7 +5808,7 @@ static function resetOSInstall($glpi_computers_id, $cfg_ocs) { static function resetProxysetting($glpi_computers_id, $cfg_ocs) { $proxy = new PluginOcsinventoryngProxysetting(); - $proxy->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $proxy->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5830,7 +5824,7 @@ static function resetProxysetting($glpi_computers_id, $cfg_ocs) { static function resetNetworkshare($glpi_computers_id, $cfg_ocs) { $share = new PluginOcsinventoryngNetworkshare(); - $share->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $share->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5846,7 +5840,7 @@ static function resetNetworkshare($glpi_computers_id, $cfg_ocs) { static function resetService($glpi_computers_id, $cfg_ocs) { $service = new PluginOcsinventoryngService(); - $service->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $service->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5862,7 +5856,7 @@ static function resetService($glpi_computers_id, $cfg_ocs) { static function resetRunningProcess($glpi_computers_id, $cfg_ocs) { $runningprocess = new PluginOcsinventoryngRunningprocess(); - $runningprocess->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $runningprocess->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5878,7 +5872,7 @@ static function resetRunningProcess($glpi_computers_id, $cfg_ocs) { static function resetWinuser($glpi_computers_id, $cfg_ocs) { $wuser = new PluginOcsinventoryngWinuser(); - $wuser->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $wuser->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5894,7 +5888,7 @@ static function resetWinuser($glpi_computers_id, $cfg_ocs) { static function resetTeamviewer($glpi_computers_id, $cfg_ocs) { $team = new PluginOcsinventoryngTeamviewer(); - $team->deleteByCriteria(array('computers_id' => $glpi_computers_id), 1); + $team->deleteByCriteria(['computers_id' => $glpi_computers_id], 1); } @@ -5931,14 +5925,14 @@ static function resetOfficePack($glpi_computers_id) { if ($DB->result($result3, 0, 0) == 1) { $soft = new Software(); - $soft->delete(array('id' => $license->fields['softwares_id']), 1); + $soft->delete(['id' => $license->fields['softwares_id']], 1); } - $license->delete(array("id" => $data['softwarelicenses_id'])); + $license->delete(["id" => $data['softwarelicenses_id']]); } } $computer_softwarelicenses = new Computer_SoftwareVersion(); - $computer_softwarelicenses->deleteByCriteria(array('computers_id' => $glpi_computers_id)); + $computer_softwarelicenses->deleteByCriteria(['computers_id' => $glpi_computers_id]); } } @@ -5965,7 +5959,7 @@ static function resetPrinters($glpi_computers_id, $cfg_ocs) { $conn = new Computer_Item(); while ($data = $DB->fetch_assoc($result)) { - $conn->delete(array('id' => $data['id'], '_no_history' => !$cfg_ocs['history_printer']), true, $cfg_ocs['history_printer']); + $conn->delete(['id' => $data['id'], '_no_history' => !$cfg_ocs['history_printer']], true, $cfg_ocs['history_printer']); $query2 = "SELECT COUNT(*) FROM `glpi_computers_items` @@ -5975,7 +5969,7 @@ static function resetPrinters($glpi_computers_id, $cfg_ocs) { $printer = new Printer(); if ($DB->result($result2, 0, 0) == 1) { - $printer->delete(array('id' => $data['items_id'], '_no_history' => !$cfg_ocs['history_printer']), true, $cfg_ocs['history_printer']); + $printer->delete(['id' => $data['items_id'], '_no_history' => !$cfg_ocs['history_printer']], true, $cfg_ocs['history_printer']); } } } @@ -6006,7 +6000,7 @@ static function resetMonitors($glpi_computers_id, $cfg_ocs) { while ($data = $DB->fetch_assoc($result)) { - $conn->delete(array('id' => $data['id'], '_no_history' => !$cfg_ocs['history_monitor']), true, $cfg_ocs['history_monitor']); + $conn->delete(['id' => $data['id'], '_no_history' => !$cfg_ocs['history_monitor']], true, $cfg_ocs['history_monitor']); $query2 = "SELECT COUNT(*) FROM `glpi_computers_items` @@ -6015,7 +6009,7 @@ static function resetMonitors($glpi_computers_id, $cfg_ocs) { $result2 = $DB->query($query2); if ($DB->result($result2, 0, 0) == 1) { - $mon->delete(array('id' => $data['items_id'], '_no_history' => !$cfg_ocs['history_monitor']), true, $cfg_ocs['history_monitor']); + $mon->delete(['id' => $data['items_id'], '_no_history' => !$cfg_ocs['history_monitor']], true, $cfg_ocs['history_monitor']); } } } @@ -6044,7 +6038,7 @@ static function resetPeripherals($glpi_computers_id, $cfg_ocs) { if ($DB->numrows($result) > 0) { $conn = new Computer_Item(); while ($data = $DB->fetch_assoc($result)) { - $conn->delete(array('id' => $data['id'], '_no_history' => !$cfg_ocs['history_peripheral']), true, $cfg_ocs['history_peripheral']); + $conn->delete(['id' => $data['id'], '_no_history' => !$cfg_ocs['history_peripheral']], true, $cfg_ocs['history_peripheral']); $query2 = "SELECT COUNT(*) FROM `glpi_computers_items` @@ -6053,7 +6047,7 @@ static function resetPeripherals($glpi_computers_id, $cfg_ocs) { $result2 = $DB->query($query2); if ($DB->result($result2, 0, 0) == 1) { - $per->delete(array('id' => $data['items_id'], '_no_history' => !$cfg_ocs['history_peripheral']), true, $cfg_ocs['history_peripheral']); + $per->delete(['id' => $data['items_id'], '_no_history' => !$cfg_ocs['history_peripheral']], true, $cfg_ocs['history_peripheral']); } } } @@ -6094,16 +6088,15 @@ static function resetSoftwares($glpi_computers_id, $cfg_ocs) { if ($DB->result($result3, 0, 0) == 1) { $soft = new Software(); - $soft->delete(array('id' => $vers->fields['softwares_id'], '_no_history' => !$cfg_ocs['history_software']), true, $cfg_ocs['history_software']); + $soft->delete(['id' => $vers->fields['softwares_id'], '_no_history' => !$cfg_ocs['history_software']], true, $cfg_ocs['history_software']); } - $vers->delete(array("id" => $data['softwareversions_id'], '_no_history' => !$cfg_ocs['history_software']), true, $cfg_ocs['history_software']); + $vers->delete(["id" => $data['softwareversions_id'], '_no_history' => !$cfg_ocs['history_software']], true, $cfg_ocs['history_software']); } } - $csv = new Computer_SoftwareVersion(); - $csv->deleteByCriteria(array('computers_id' => $glpi_computers_id, - 'is_dynamic' => 1), 1, $cfg_ocs['history_software']); + $csv->deleteByCriteria(['computers_id' => $glpi_computers_id, + 'is_dynamic' => 1], 1, $cfg_ocs['history_software']); } } @@ -6120,8 +6113,8 @@ static function resetSoftwares($glpi_computers_id, $cfg_ocs) { static function resetDisks($glpi_computers_id, $cfg_ocs) { $dd = new ComputerDisk(); - $dd->deleteByCriteria(array('computers_id' => $glpi_computers_id, - 'is_dynamic' => 1), 1, $cfg_ocs['history_drives']); + $dd->deleteByCriteria(['computers_id' => $glpi_computers_id, + 'is_dynamic' => 1], 1, $cfg_ocs['history_drives']); } @@ -6193,7 +6186,7 @@ static function importVersion($cfg_ocs, $software, $version, $comments) { $input["softwares_id"] = $software; $input["name"] = $version; $input["comment"] = $comments; - $isNewVers = $vers->add($input, array(), $cfg_ocs['history_software']); + $isNewVers = $vers->add($input, [], $cfg_ocs['history_software']); } return ($isNewVers); @@ -6214,7 +6207,7 @@ static function importVersion($cfg_ocs, $software, $version, $comments) { */ static function updateVirtualMachines($computers_id, $ocsComputer, $ocsservers_id, $cfg_ocs) { global $DB; - $already_processed = array(); + $already_processed = []; $virtualmachine = new ComputerVirtualMachine(); $ocsVirtualmachines = $ocsComputer; @@ -6222,7 +6215,7 @@ static function updateVirtualMachines($computers_id, $ocsComputer, $ocsservers_i if (count($ocsVirtualmachines) > 0) { foreach ($ocsVirtualmachines as $ocsVirtualmachine) { $ocsVirtualmachine = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsVirtualmachine)); - $vm = array(); + $vm = []; $vm['name'] = $ocsVirtualmachine['NAME']; $vm['vcpu'] = $ocsVirtualmachine['VCPU']; $vm['ram'] = $ocsVirtualmachine['MEMORY']; @@ -6253,7 +6246,7 @@ static function updateVirtualMachines($computers_id, $ocsComputer, $ocsservers_i } if (!$id) { $virtualmachine->reset(); - $id_vm = $virtualmachine->add($vm, array(), $cfg_ocs['history_vm']); + $id_vm = $virtualmachine->add($vm, [], $cfg_ocs['history_vm']); if ($id_vm) { $already_processed[] = $id_vm; } @@ -6277,8 +6270,8 @@ static function updateVirtualMachines($computers_id, $ocsComputer, $ocsservers_i } foreach ($DB->request($query) as $data) { //Delete all connexions - $virtualmachine->delete(array('id' => $data['id'], - '_ocsservers_id' => $ocsservers_id, '_no_history' => !$cfg_ocs['history_vm']), true, $cfg_ocs['history_vm']); + $virtualmachine->delete(['id' => $data['id'], + '_ocsservers_id' => $ocsservers_id, '_no_history' => !$cfg_ocs['history_vm']], true, $cfg_ocs['history_vm']); } } @@ -6326,8 +6319,8 @@ static function updateOfficePack($computers_id, $softwares_id, $softwares_name, AND `softwareversions_id_use` = " . $softwareversions_id) ) { - $software_licenses->update(array('id' => $software_licenses->getID(), - 'comment' => $ocsOfficePack['NOTE'])); + $software_licenses->update(['id' => $software_licenses->getID(), + 'comment' => $ocsOfficePack['NOTE']]); if (!$computer_softwarelicenses->getFromDBByQuery("WHERE `computers_id` = " . $computers_id . " AND `softwarelicenses_id` = " . $software_licenses->getID()) ) { @@ -6337,8 +6330,8 @@ static function updateOfficePack($computers_id, $softwares_id, $softwares_name, $computer_soft_l['is_dynamic'] = -1; $computer_softwarelicenses->add($computer_soft_l); //Update for validity - $software_licenses->update(array('id' => $software_licenses->getID(), - 'is_valid' => 1)); + $software_licenses->update(['id' => $software_licenses->getID(), + 'is_valid' => 1]); } } } @@ -6356,7 +6349,7 @@ static function updateOfficePack($computers_id, $softwares_id, $softwares_name, $id_software_licenses = $software_licenses->getID(); } else { $software_licenses->fields['softwares_id'] = $softwares_id; - $id_software_licenses = $software_licenses->add($soft_l, array(), $cfg_ocs['history_software']); + $id_software_licenses = $software_licenses->add($soft_l, [], $cfg_ocs['history_software']); } if ($id_software_licenses) { @@ -6370,8 +6363,8 @@ static function updateOfficePack($computers_id, $softwares_id, $softwares_name, $computer_softwarelicenses->add($computer_soft_l); } //Update for validity - $software_licenses->update(array('id' => $id_software_licenses, - 'is_valid' => 1)); + $software_licenses->update(['id' => $id_software_licenses, + 'is_valid' => 1]); } } } @@ -6397,7 +6390,7 @@ static function updateOfficePack($computers_id, $softwares_id, $softwares_name, static function updateDisk($computers_id, $ocsComputer, $ocsservers_id, $cfg_ocs) { global $DB; - $already_processed = array(); + $already_processed = []; $logical_drives = $ocsComputer; $d = new ComputerDisk(); @@ -6407,21 +6400,21 @@ static function updateDisk($computers_id, $ocsComputer, $ocsservers_id, $cfg_ocs // Only not empty disk if ($logical_drive['TOTAL'] > 0) { - $disk = array(); + $disk = []; $disk['computers_id'] = $computers_id; $disk['is_dynamic'] = 1; // TYPE : vxfs / ufs : VOLUMN = mount / FILESYSTEM = device - if (in_array($logical_drive['TYPE'], array("vxfs", "ufs"))) { + if (in_array($logical_drive['TYPE'], ["vxfs", "ufs"])) { $disk['name'] = $logical_drive['VOLUMN']; $disk['mountpoint'] = $logical_drive['VOLUMN']; $disk['device'] = $logical_drive['FILESYSTEM']; $disk['filesystems_id'] = Dropdown::importExternal('Filesystem', $logical_drive["TYPE"]); - } else if (in_array($logical_drive['FILESYSTEM'], array('ext2', 'ext3', 'ext4', 'ffs', + } else if (in_array($logical_drive['FILESYSTEM'], ['ext2', 'ext3', 'ext4', 'ffs', 'fuseblk', 'fusefs', 'hfs', 'jfs', 'jfs2', 'Journaled HFS+', 'nfs', 'smbfs', 'reiserfs', 'vmfs', 'VxFS', - 'ufs', 'xfs', 'zfs'))) { + 'ufs', 'xfs', 'zfs'])) { // Try to detect mount point : OCS database is dirty $disk['mountpoint'] = $logical_drive['VOLUMN']; $disk['device'] = $logical_drive['TYPE']; @@ -6438,7 +6431,7 @@ static function updateDisk($computers_id, $ocsComputer, $ocsservers_id, $cfg_ocs $disk['name'] = $disk['mountpoint']; } $disk['filesystems_id'] = Dropdown::importExternal('Filesystem', $logical_drive["FILESYSTEM"]); - } else if (in_array($logical_drive['FILESYSTEM'], array('FAT', 'FAT32', 'NTFS'))) { + } else if (in_array($logical_drive['FILESYSTEM'], ['FAT', 'FAT32', 'NTFS'])) { if (!empty($logical_drive['VOLUMN'])) { $disk['name'] = $logical_drive['VOLUMN']; } else { @@ -6468,7 +6461,7 @@ static function updateDisk($computers_id, $ocsComputer, $ocsservers_id, $cfg_ocs if (!$id) { $d->reset(); $disk['is_dynamic'] = 1; - $id_disk = $d->add($disk, array(), $cfg_ocs['history_drives']); + $id_disk = $d->add($disk, [], $cfg_ocs['history_drives']); $already_processed[] = $id_disk; } else { // Only update if needed @@ -6504,8 +6497,8 @@ static function updateDisk($computers_id, $ocsComputer, $ocsservers_id, $cfg_ocs } foreach ($DB->request($query) as $data) { //Delete all connexions - $d->delete(array('id' => $data['id'], - '_ocsservers_id' => $ocsservers_id, '_no_history' => !$cfg_ocs['history_drives']), true, $cfg_ocs['history_drives']); + $d->delete(['id' => $data['id'], + '_ocsservers_id' => $ocsservers_id, '_no_history' => !$cfg_ocs['history_drives']], true, $cfg_ocs['history_drives']); } } @@ -6533,11 +6526,11 @@ static function installSoftwareVersion($computers_id, $softwareversions_id, $ins } $tmp = new Computer_SoftwareVersion(); - return $tmp->add(array('computers_id' => $computers_id, + return $tmp->add(['computers_id' => $computers_id, 'softwareversions_id' => $softwareversions_id, 'date_install' => $installdate, 'is_dynamic' => 1, - 'is_deleted' => 0), array(), $dohistory); + 'is_deleted' => 0], [], $dohistory); } return 0; } @@ -6566,10 +6559,9 @@ static function updateSoftwareVersion($computers_id, $softwareversions_id, $inst $data = $DB->fetch_array($result); $tmp = new Computer_SoftwareVersion(); - - $input = array('id' => $data['id'], + $input = ['id' => $data['id'], '_no_history' => !$dohistory, - 'date_install' => $installdate); + 'date_install' => $installdate]; return $tmp->update($input); } @@ -6596,9 +6588,9 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ $is_utf8 = $cfg_ocs["ocs_db_utf8"]; $computer_softwareversion = new Computer_SoftwareVersion(); - $softwares = array(); + $softwares = []; //---- Get all the softwares for this machine from OCS -----// - $softwares = (isset($ocsComputer["SOFTWARES"]) ? $ocsComputer["SOFTWARES"] : array()); + $softwares = (isset($ocsComputer["SOFTWARES"]) ? $ocsComputer["SOFTWARES"] : []); $soft = new Software(); @@ -6613,8 +6605,7 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ ON `glpi_softwares`.`id`= `glpi_softwareversions`.`softwares_id` WHERE `glpi_computers_softwareversions`.`computers_id`='$computers_id' AND `is_dynamic`"; - $imported = array(); - + $imported = []; foreach ($DB->request($query) as $data) { $imported[$data['id']] = strtolower($data['sname'] . self::FIELD_SEPARATOR . $data['vname']); @@ -6635,7 +6626,7 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ ON `glpi_softwarelicenses`.`softwareversions_id_use` = `glpi_softwareversions`.`id` WHERE `glpi_computers_softwarelicenses`.`computers_id`='$computers_id' AND `is_dynamic`"; - $imported_licences = array(); + $imported_licences = []; foreach ($DB->request($query) as $data) { $imported_licences[$data['id']] = strtolower($data['vid']); @@ -6648,7 +6639,7 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ //As we cannot be sure that data coming from OCS are in utf8, let's try to encode them //if possible - foreach (array('NAME', 'PUBLISHER', 'VERSION') as $field) { + foreach (['NAME', 'PUBLISHER', 'VERSION'] as $field) { if (isset($software[$field])) { $software[$field] = self::encodeOcsDataInUtf8($is_utf8, $software[$field]); } @@ -6671,15 +6662,15 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ $modified_name = $name; $modified_version = $version; $version_comments = $software['COMMENTS']; - $is_helpdesk_visible = NULL; + $is_helpdesk_visible = null; if (!$cfg_ocs["use_soft_dict"]) { //Software dictionnary - $params = array("name" => $name, + $params = ["name" => $name, "manufacturer" => $manufacturer, "old_version" => $version, - "entities_id" => $entity); + "entities_id" => $entity]; $rulecollection = new RuleDictionnarySoftwareCollection(); - $res_rule = $rulecollection->processAllRules(Toolbox::stripslashes_deep($params), array(), Toolbox::stripslashes_deep(array('version' => $version))); + $res_rule = $rulecollection->processAllRules(Toolbox::stripslashes_deep($params), [], Toolbox::stripslashes_deep(['version' => $version])); if (isset($res_rule["name"]) && $res_rule["name"] @@ -6763,7 +6754,7 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ } foreach ($imported as $id => $unused) { - $computer_softwareversion->delete(array('id' => $id, '_no_history' => !$cfg_ocs['history_software']), true, $cfg_ocs['history_software']); + $computer_softwareversion->delete(['id' => $id, '_no_history' => !$cfg_ocs['history_software']], true, $cfg_ocs['history_software']); // delete cause a getFromDB, so fields contains values $verid = $computer_softwareversion->getField('softwareversions_id'); @@ -6779,14 +6770,14 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ // 1 is the current to be removed $soft->putInTrash($vers->fields['softwares_id'], __('Software deleted by OCSNG synchronization', 'ocsinventoryng')); } - $vers->delete(array("id" => $verid, '_no_history' => !$cfg_ocs['history_software']), true, $cfg_ocs['history_software']); + $vers->delete(["id" => $verid, '_no_history' => !$cfg_ocs['history_software']], true, $cfg_ocs['history_software']); } } if ($officepack) { $computer_softwarelicenses = new Computer_SoftwareLicense(); foreach ($imported_licences as $id => $unused) { - $computer_softwarelicenses->delete(array('id' => $id), true, $cfg_ocs['history_software']); + $computer_softwarelicenses->delete(['id' => $id], true, $cfg_ocs['history_software']); // delete cause a getFromDB, so fields contains values $verid = $computer_softwarelicenses->getField('softwareversions_id'); @@ -6796,9 +6787,9 @@ static function updateSoftware($cfg_ocs, $computers_id, $ocsComputer, $entity, $ if ($vers->getFromDB($verid) && countElementsInTable('glpi_softwarelicenses', "softwares_id = '" . $vers->fields['softwares_id'] . "'") == 0) { $soft = new Software(); - $soft->delete(array('id' => $vers->fields['softwares_id']), 1); + $soft->delete(['id' => $vers->fields['softwares_id']], 1); } - $vers->delete(array("id" => $verid)); + $vers->delete(["id" => $verid]); } } } @@ -6824,13 +6815,13 @@ static function updateRegistry($computers_id, $ocsComputer) { //update data foreach ($ocsComputer as $registry) { $registry = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($registry)); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $input["hive"] = $registry["regtree"]; $input["value"] = $registry["regvalue"]; $input["path"] = $registry["regkey"]; $input["ocs_name"] = $registry["name"]; - $reg->add($input, array('disable_unicity_check' => true)); + $reg->add($input, ['disable_unicity_check' => true]); $reg->fields = []; } @@ -6855,7 +6846,7 @@ static function updateAntivirus($computers_id, $ocsComputer, $cfg_ocs) { foreach ($ocsComputer as $anti) { $antivirus = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($anti)); - $input = array(); + $input = []; if ($antivirus["category"] == "AntiVirus") { $input["computers_id"] = $computers_id; @@ -6865,7 +6856,7 @@ static function updateAntivirus($computers_id, $ocsComputer, $cfg_ocs) { $input["is_active"] = $antivirus["enabled"]; $input["is_uptodate"] = $antivirus["uptodate"]; $input["is_dynamic"] = 1; - $av->add($input, array('disable_unicity_check' => true), 0); + $av->add($input, ['disable_unicity_check' => true], 0); $av->fields = []; } } @@ -6892,7 +6883,7 @@ static function updateWinupdatestate($computers_id, $ocsComputer, $cfg_ocs) { foreach ($ocsComputer as $wup) { $wupdate = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($wup)); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $computer = new Computer; @@ -6905,7 +6896,7 @@ static function updateWinupdatestate($computers_id, $ocsComputer, $cfg_ocs) { $input["detectsuccesstime"] = $wupdate["DETECTSUCCESSTIME"]; $input["downloadsuccesstime"] = $wupdate["DOWNLOADSUCCESSTIME"]; - $CompWupdate->add($input, array('disable_unicity_check' => true), 0); + $CompWupdate->add($input, ['disable_unicity_check' => true], 0); $CompWupdate->fields = []; } @@ -6930,7 +6921,7 @@ static function updateOSInstall($computers_id, $ocsComputer, $cfg_ocs) { foreach ($ocsComputer as $osi) { $os = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($osi)); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $computer = new Computer; @@ -6945,7 +6936,7 @@ static function updateOSInstall($computers_id, $ocsComputer, $cfg_ocs) { $input["oslanguage"] = $os["OSLANGUAGE"]; $input["curtimezone"] = $os["CURTIMEZONE"]; $input["locale"] = $os["LOCALE"]; - $osinstall->add($input, array('disable_unicity_check' => true), 0); + $osinstall->add($input, ['disable_unicity_check' => true], 0); $osinstall->fields = []; } @@ -6972,7 +6963,7 @@ static function updateProxysetting($computers_id, $ocsComputer, $cfg_ocs) { foreach ($ocsComputer as $prox) { $proxy = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($prox)); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $computer = new Computer; @@ -6988,7 +6979,7 @@ static function updateProxysetting($computers_id, $ocsComputer, $cfg_ocs) { if (isset($proxy["OVERRIDE"])) { $input["override"] = $proxy["OVERRIDE"]; } - $ProxySetting->add($input, array('disable_unicity_check' => true), 0); + $ProxySetting->add($input, ['disable_unicity_check' => true], 0); $ProxySetting->fields = []; } @@ -7016,7 +7007,7 @@ static function updateNetworkshare($computers_id, $ocsComputer, $cfg_ocs) { foreach ($ocsComputer as $share) { $sha = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($share)); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $computer = new Computer; @@ -7028,7 +7019,7 @@ static function updateNetworkshare($computers_id, $ocsComputer, $cfg_ocs) { $input["size"] = $sha["SIZE"]; $input["freespace"] = $sha["FREESPACE"]; $input["quota"] = $sha["QUOTA"]; - $Shares->add($input, array('disable_unicity_check' => true), 0); + $Shares->add($input, ['disable_unicity_check' => true], 0); $Shares->fields = []; } @@ -7058,7 +7049,7 @@ static function updateRunningprocess($computers_id, $ocsComputer, $cfg_ocs) { $input = array_change_key_case($process, CASE_LOWER); $input["computers_id"] = $computers_id; - $Runningprocess->add($input, array('disable_unicity_check' => true), 0); + $Runningprocess->add($input, ['disable_unicity_check' => true], 0); $Runningprocess->fields = []; } @@ -7087,7 +7078,7 @@ static function updateService($computers_id, $ocsComputer, $cfg_ocs) { $input = array_change_key_case($service, CASE_LOWER); $input["computers_id"] = $computers_id; - $Service->add($input, array('disable_unicity_check' => true), 0); + $Service->add($input, ['disable_unicity_check' => true], 0); $Service->fields = []; } @@ -7112,7 +7103,7 @@ static function updateWinuser($computers_id, $ocsComputer, $cfg_ocs) { foreach ($ocsComputer as $wusers) { $wuser = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($wusers)); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $computer = new Computer; @@ -7126,7 +7117,7 @@ static function updateWinuser($computers_id, $ocsComputer, $cfg_ocs) { $input["disabled"] = (isset($wuser["TYPE"]) ? $wuser["DISABLED"] : ''); $input["sid"] = (isset($wuser["TYPE"]) ? $wuser["SID"]: ''); - $winusers->add($input, array('disable_unicity_check' => true), 0); + $winusers->add($input, ['disable_unicity_check' => true], 0); } $winusers->fields = []; } @@ -7148,7 +7139,7 @@ static function updateTeamviewer($computers_id, $ocsComputer, $cfg_ocs) { self::resetTeamviewer($computers_id, $cfg_ocs); $CompTeam = new PluginOcsinventoryngTeamviewer(); - $input = array(); + $input = []; $input["computers_id"] = $computers_id; $computer = new Computer; @@ -7158,7 +7149,7 @@ static function updateTeamviewer($computers_id, $ocsComputer, $cfg_ocs) { $input["version"] = $ocsComputer["VERSION"]; $input["twid"] = $ocsComputer["TWID"]; - $CompTeam->add($input, array('disable_unicity_check' => true), 0); + $CompTeam->add($input, ['disable_unicity_check' => true], 0); return; } @@ -7211,12 +7202,12 @@ static function updateAdministrativeInfo($computers_id, $ocsid, $plugin_ocsinven $result = $DB->query($queryListUpdate); if ($DB->numrows($result) > 0) { - $options = array( - "DISPLAY" => array( + $options = [ + "DISPLAY" => [ "CHECKSUM" => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS, "WANTED" => PluginOcsinventoryngOcsClient::WANTED_ACCOUNTINFO, - ) - ); + ] + ]; $computer = $ocsClient->getComputer($ocsid, $options); if ($computer) { @@ -7253,7 +7244,7 @@ static function updateAdministrativeInfo($computers_id, $ocsid, $plugin_ocsinven break; } - $input = array(); + $input = []; $input[$glpi_column] = $var; $input["id"] = $computers_id; $input["entities_id"] = $entities_id; @@ -7270,7 +7261,7 @@ static function updateAdministrativeInfo($computers_id, $ocsid, $plugin_ocsinven if (isset($computer["BIOS"]["ASSETTAG"]) && !empty($computer["BIOS"]["ASSETTAG"]) ) { - $input = array(); + $input = []; $input[$glpi_column] = $var; $input["id"] = $computers_id; $input["entities_id"] = $entities_id; @@ -7312,7 +7303,6 @@ static function updateAdministrativeInfoUseDate($computers_id, $plugin_ocsinvent if ($DB->numrows($result) > 0) { - if (isset($ocsComputer['HARDWARE'])) { $metas = $ocsComputer['HARDWARE']; foreach ($metas as $key => $meta) { @@ -7337,7 +7327,6 @@ static function updateAdministrativeInfoUseDate($computers_id, $plugin_ocsinvent $computer_updates = PluginOcsinventoryngOcsAdminInfosLink::addInfocomsForComputer($computers_id, $date, $computer_updates); break; - } } } @@ -7356,13 +7345,13 @@ static function cronInfo($name) { // no translation for the name of the project switch ($name) { case 'ocsng': - return array('description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Launch OCSNG synchronization script', 'ocsinventoryng')); + return ['description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Launch OCSNG synchronization script', 'ocsinventoryng')]; break; case 'CleanOldAgents': - return array('description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Clean old agents & drop from OCSNG software', 'ocsinventoryng')); + return ['description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Clean old agents & drop from OCSNG software', 'ocsinventoryng')]; break; case 'RestoreOldAgents': - return array('description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Restore computers from the date of last inventory', 'ocsinventoryng')); + return ['description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Restore computers from the date of last inventory', 'ocsinventoryng')]; break; } } @@ -7398,7 +7387,7 @@ static function cronCleanOldAgents($task) { if ($config['action_cleancron'] == self::ACTION_PURGE_COMPUTER) { //action purge agents OCSNG - $computers = array(); + $computers = []; if (count($agents) > 0) { $nb = $ocsClient->deleteOldAgents($agents); @@ -7472,7 +7461,6 @@ static function cronRestoreOldAgents($task) { WHERE `glpi_computers`.`is_deleted` = 1 AND ( unix_timestamp(ocslink.`last_ocs_update`) >= UNIX_TIMESTAMP(NOW() - INTERVAL $delay DAY))"; - $result = $DB->query($query); if ($DB->numrows($result) > 0) { $computer = new Computer(); @@ -7480,7 +7468,7 @@ static function cronRestoreOldAgents($task) { $computer->fields['id'] = $data['id']; $computer->fields['is_deleted'] = 0; $computer->fields['date_mod'] = $_SESSION['glpi_currenttime']; - $computer->updateInDB(array('is_deleted', 'date_mod')); + $computer->updateInDB(['is_deleted', 'date_mod']); //add history $changes[0] = 0; $changes[2] = ""; @@ -7594,25 +7582,25 @@ static function analizePrinterPorts(&$printer_infos, $port = '') { */ static function getAvailableStatistics($snmp = false, $ipdiscover = false) { - $stats = array('imported_machines_number' => __('Computers imported', 'ocsinventoryng'), + $stats = ['imported_machines_number' => __('Computers imported', 'ocsinventoryng'), 'synchronized_machines_number' => __('Computers synchronized', 'ocsinventoryng'), 'linked_machines_number' => __('Computers linked', 'ocsinventoryng'), 'notupdated_machines_number' => __('Computers not updated', 'ocsinventoryng'), 'failed_rules_machines_number' => __("Computers don't check any rule", 'ocsinventoryng'), 'not_unique_machines_number' => __('Duplicate computers', 'ocsinventoryng'), - 'link_refused_machines_number' => __('Computers whose import is refused by a rule', 'ocsinventoryng')); + 'link_refused_machines_number' => __('Computers whose import is refused by a rule', 'ocsinventoryng')]; if ($snmp) { - $stats = array('imported_snmp_number' => __('SNMP objects imported', 'ocsinventoryng'), + $stats = ['imported_snmp_number' => __('SNMP objects imported', 'ocsinventoryng'), 'synchronized_snmp_number' => __('SNMP objects synchronized', 'ocsinventoryng'), 'linked_snmp_number' => __('SNMP objects linked', 'ocsinventoryng'), 'notupdated_snmp_number' => __('SNMP objects not updated', 'ocsinventoryng'), - 'failed_imported_snmp_number' => __("SNMP objects not imported", 'ocsinventoryng')); + 'failed_imported_snmp_number' => __("SNMP objects not imported", 'ocsinventoryng')]; } if ($ipdiscover) { - $stats = array('imported_ipdiscover_number' => __('IPDISCOVER objects imported', 'ocsinventoryng'), + $stats = ['imported_ipdiscover_number' => __('IPDISCOVER objects imported', 'ocsinventoryng'), 'synchronized_ipdiscover_number' => __('IPDISCOVER objects synchronized', 'ocsinventoryng'), 'notupdated_ipdiscover_number' => __('IPDISCOVER objects not updated', 'ocsinventoryng'), - 'failed_imported_ipdiscover_number' => __("IPDISCOVER objects not imported", 'ocsinventoryng')); + 'failed_imported_ipdiscover_number' => __("IPDISCOVER objects not imported", 'ocsinventoryng')]; } return $stats; @@ -7624,7 +7612,7 @@ static function getAvailableStatistics($snmp = false, $ipdiscover = false) { * @param bool $snmp * @param bool $ipdiscover */ - static function manageImportStatistics(&$statistics = array(), $action = false, $snmp = false, $ipdiscover = false) { + static function manageImportStatistics(&$statistics = [], $action = false, $snmp = false, $ipdiscover = false) { if (empty($statistics)) { foreach (self::getAvailableStatistics($snmp, $ipdiscover) as $field => $label) { @@ -7705,7 +7693,7 @@ static function manageImportStatistics(&$statistics = array(), $action = false, * @param bool $snmp * @param bool $ipdiscover */ - static function showStatistics($statistics = array(), $finished = false, $snmp = false, $ipdiscover = false) { + static function showStatistics($statistics = [], $finished = false, $snmp = false, $ipdiscover = false) { echo "
"; echo ""; @@ -7773,14 +7761,14 @@ static function transferComputer($line_links) { // Get all rules for the current plugin_ocsinventoryng_ocsservers_id $rule = new RuleImportEntityCollection(); - $data = $rule->processAllRules(array('ocsservers_id' => $line_links["plugin_ocsinventoryng_ocsservers_id"], + $data = $rule->processAllRules(['ocsservers_id' => $line_links["plugin_ocsinventoryng_ocsservers_id"], '_source' => 'ocsinventoryng', 'locations_id' => $locations_id, 'groups_id' => $groups_id - ), array( + ], [ 'locations_id' => $locations_id, 'groups_id' => $groups_id - ), array('ocsid' => $line_links["ocsid"])); + ], ['ocsid' => $line_links["ocsid"]]); // If entity is changing move items to the new entities_id if (isset($data['entities_id']) && $data['entities_id'] > -1 && $data['entities_id'] != $line_links['entities_id']) { @@ -7792,8 +7780,8 @@ static function transferComputer($line_links) { $transfer = new Transfer(); $transfer->getFromDB($CFG_GLPI['transfers_id_auto']); - $item_to_transfer = array("Computer" => array($line_links['computers_id'] - => $line_links['computers_id'])); + $item_to_transfer = ["Computer" => [$line_links['computers_id'] + => $line_links['computers_id']]]; $transfer->moveItems($item_to_transfer, $data['entities_id'], $transfer->fields); } @@ -7810,7 +7798,7 @@ static function transferComputer($line_links) { * * @return array|int */ - static private function getUserGroup ($entity, $userid, $filter='', $first=true) { + static private function getUserGroup ($entity, $userid, $filter = '', $first = true) { global $DB; $query = "SELECT `glpi_groups`.`id` @@ -7918,7 +7906,7 @@ static function getLocksForComputer($ID) { $query = "SELECT * FROM `glpi_plugin_ocsinventoryng_ocslinks` WHERE `computers_id` = '$ID'"; - $locks = array(); + $locks = []; $result = $DB->query($query); if ($DB->numrows($result) == 1) { $data = $DB->fetch_assoc($result); @@ -8037,7 +8025,7 @@ static function getTypes($all = false) { */ static function getLockableFields() { - return array("name" => __('Name'), + return ["name" => __('Name'), "computertypes_id" => __('Type'), "manufacturers_id" => __('Manufacturer'), "computermodels_id" => __('Model'), @@ -8057,7 +8045,7 @@ static function getLockableFields() { "users_id" => __('User'), "locations_id" => __('Location'), "use_date" => __('Startup date'), - "groups_id" => __('Group')); + "groups_id" => __('Group')]; } /** @@ -8125,12 +8113,12 @@ static function getFirstServer() { static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsComputer, $entity) { global $DB, $CFG_GLPI; - $already_processed = array(); + $already_processed = []; $do_clean = true; $m = new Monitor(); $conn = new Computer_Item(); - $monitors = array(); + $monitors = []; $checkserial = true; // First pass - check if all serial present @@ -8151,7 +8139,7 @@ static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu foreach ($monitors as $monitor) { - $mon = array(); + $mon = []; if (!empty($monitor["CAPTION"])) { $mon["name"] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $monitor["CAPTION"]); $mon["monitormodels_id"] = Dropdown::importExternal('MonitorModel', $monitor["CAPTION"]); @@ -8221,7 +8209,7 @@ static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu $input["states_id"] = $cfg_ocs["states_id_default"]; } $input["entities_id"] = $entity; - $id_monitor = $m->add($input, array(), $cfg_ocs['history_monitor']); + $id_monitor = $m->add($input, [], $cfg_ocs['history_monitor']); } } else if ($cfg_ocs["import_monitor"] >= 2) { //Config says : manage monitors as single units @@ -8270,28 +8258,27 @@ static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu } } - if (!$id_monitor) { $input = $mon; if ($cfg_ocs["states_id_default"] > 0) { $input["states_id"] = $cfg_ocs["states_id_default"]; } $input["entities_id"] = $entity; - $id_monitor = $m->add($input, array(), $cfg_ocs['history_monitor']); + $id_monitor = $m->add($input, [], $cfg_ocs['history_monitor']); } } // ($cfg_ocs["import_monitor"] >= 2) if ($id_monitor) { //Import unique : Disconnect monitor on other computer done in Connect function - $connID = $conn->add(array('computers_id' => $computers_id, + $connID = $conn->add(['computers_id' => $computers_id, 'itemtype' => 'Monitor', 'items_id' => $id_monitor, 'is_dynamic' => 1, - 'is_deleted' => 0), array(), $cfg_ocs['history_monitor']); + 'is_deleted' => 0], [], $cfg_ocs['history_monitor']); $already_processed[] = $id_monitor; //Update column "is_deleted" set value to 0 and set status to default - $input = array(); + $input = []; $old = new Monitor(); if ($old->getFromDB($id_monitor)) { if ($old->fields["is_deleted"]) { @@ -8386,14 +8373,14 @@ static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu static function importPrinter($cfg_ocs, $computers_id, $ocsservers_id, $ocsComputer, $entity) { global $DB, $CFG_GLPI; - $already_processed = array(); + $already_processed = []; $conn = new Computer_Item(); $p = new Printer(); foreach ($ocsComputer as $printer) { $printer = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($printer)); - $print = array(); + $print = []; // TO TEST : PARSE NAME to have real name. $print['name'] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $printer['NAME']); @@ -8411,7 +8398,7 @@ static function importPrinter($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu if (!empty($print["name"])) { $rulecollection = new RuleDictionnaryPrinterCollection(); - $res_rule = Toolbox::addslashes_deep($rulecollection->processAllRules(Toolbox::stripslashes_deep($params), array(), array())); + $res_rule = Toolbox::addslashes_deep($rulecollection->processAllRules(Toolbox::stripslashes_deep($params), [], [])); if (!isset($res_rule["_ignore_import"]) || !$res_rule["_ignore_import"]) { @@ -8478,7 +8465,7 @@ static function importPrinter($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu $input["states_id"] = $cfg_ocs["states_id_default"]; } $input["entities_id"] = $entity; - $id_printer = $p->add($input, array(), $cfg_ocs['history_printer']); + $id_printer = $p->add($input, [], $cfg_ocs['history_printer']); } } else if ($management_process == 2) { //Config says : manage printers as single units @@ -8491,18 +8478,18 @@ static function importPrinter($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu } $input["entities_id"] = $entity; $input['is_dynamic'] = 1; - $id_printer = $p->add($input, array(), $cfg_ocs['history_printer']); + $id_printer = $p->add($input, [], $cfg_ocs['history_printer']); } if ($id_printer) { $already_processed[] = $id_printer; $conn = new Computer_Item(); - $connID = $conn->add(array('computers_id' => $computers_id, + $connID = $conn->add(['computers_id' => $computers_id, 'itemtype' => 'Printer', 'items_id' => $id_printer, - 'is_dynamic' => 1), array(), $cfg_ocs['history_printer']); + 'is_dynamic' => 1], [], $cfg_ocs['history_printer']); //Update column "is_deleted" set value to 0 and set status to default - $input = array(); + $input = []; $input["id"] = $id_printer; $input["is_deleted"] = 0; $input["entities_id"] = $entity; @@ -8582,11 +8569,11 @@ static function importPrinter($cfg_ocs, $computers_id, $ocsservers_id, $ocsCompu static function importPeripheral($cfg_ocs, $computers_id, $ocsservers_id, $ocsComputer, $entity) { global $DB, $CFG_GLPI; - $already_processed = array(); + $already_processed = []; $p = new Peripheral(); $conn = new Computer_Item(); - $peripherals = array(); + $peripherals = []; foreach ($ocsComputer as $peripheral) { @@ -8597,7 +8584,7 @@ static function importPeripheral($cfg_ocs, $computers_id, $ocsservers_id, $ocsCo if (count($peripherals) > 0) { foreach ($peripherals as $peripheral) { $peripheral = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($peripheral)); - $periph = array(); + $periph = []; $periph["name"] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $peripheral["CAPTION"]); //Look for a monitor with the same name (and serial if possible) already connected //to this computer @@ -8648,7 +8635,7 @@ static function importPeripheral($cfg_ocs, $computers_id, $ocsservers_id, $ocsCo $input["states_id"] = $cfg_ocs["states_id_default"]; } $input["entities_id"] = $entity; - $id_periph = $p->add($input, array(), $cfg_ocs['history_peripheral']); + $id_periph = $p->add($input, [], $cfg_ocs['history_peripheral']); } } else if ($cfg_ocs["import_periph"] == 2) { //Config says : manage peripherals as single units @@ -8659,19 +8646,19 @@ static function importPeripheral($cfg_ocs, $computers_id, $ocsservers_id, $ocsCo $input["states_id"] = $cfg_ocs["states_id_default"]; } $input["entities_id"] = $entity; - $id_periph = $p->add($input, array(), $cfg_ocs['history_peripheral']); + $id_periph = $p->add($input, [], $cfg_ocs['history_peripheral']); } if ($id_periph) { $already_processed[] = $id_periph; $conn = new Computer_Item(); - if ($connID = $conn->add(array('computers_id' => $computers_id, + if ($connID = $conn->add(['computers_id' => $computers_id, 'itemtype' => 'Peripheral', 'items_id' => $id_periph, - 'is_dynamic' => 1), array(), $cfg_ocs['history_peripheral']) + 'is_dynamic' => 1], [], $cfg_ocs['history_peripheral']) ) { //Update column "is_deleted" set value to 0 and set status to default - $input = array(); + $input = []; $input["id"] = $id_periph; $input["is_deleted"] = 0; $input["entities_id"] = $entity; @@ -8743,7 +8730,7 @@ static function importPeripheral($cfg_ocs, $computers_id, $ocsservers_id, $ocsCo * * @return an */ - function getSpecificMassiveActions($checkitem = NULL) { + function getSpecificMassiveActions($checkitem = null) { $actions = parent::getSpecificMassiveActions($checkitem); @@ -8764,21 +8751,21 @@ static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { case 'plugin_ocsinventoryng_force_ocsng_update': echo " " . - Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; case 'plugin_ocsinventoryng_lock_ocsng_field': $fields['all'] = __('All'); $fields += self::getLockableFields(); Dropdown::showFromArray("field", $fields); echo " " . - Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; case 'plugin_ocsinventoryng_unlock_ocsng_field': $fields['all'] = __('All'); $fields += self::getLockableFields(); Dropdown::showFromArray("field", $fields); echo " " . - Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; } return parent::showMassiveActionsSubForm($ma); @@ -8840,7 +8827,7 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); } } else { - if (self::addToOcsArray($id, array($_POST['field']), "computer_update")) { + if (self::addToOcsArray($id, [$_POST['field']], "computer_update")) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); @@ -8858,7 +8845,7 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT foreach ($ids as $id) { if ($_POST['field'] == 'all') { - if (self::replaceOcsArray($id, array(), "computer_update")) { + if (self::replaceOcsArray($id, [], "computer_update")) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); diff --git a/inc/ocsserver_profile.class.php b/inc/ocsserver_profile.class.php index 709e88db..37680aa4 100644 --- a/inc/ocsserver_profile.class.php +++ b/inc/ocsserver_profile.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -40,4 +40,4 @@ class PluginOcsinventoryngOcsserver_Profile extends CommonDBTM static $rightname = "profile"; -} \ No newline at end of file +} diff --git a/inc/ocssoapclient.class.php b/inc/ocssoapclient.class.php index 5ee8e531..c28f8d29 100644 --- a/inc/ocssoapclient.class.php +++ b/inc/ocssoapclient.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -45,11 +45,10 @@ class PluginOcsinventoryngOcsSoapClient extends PluginOcsinventoryngOcsClient * @param $user * @param $pass */ - public function __construct($id, $url, $user, $pass) - { + public function __construct($id, $url, $user, $pass) { parent::__construct($id); - $options = array( + $options = [ 'location' => "$url/ocsinterface", 'uri' => "$url/Apache/Ocsinventory/Interface", 'login' => $user, @@ -57,7 +56,7 @@ public function __construct($id, $url, $user, $pass) 'trace' => true, 'soap_version' => SOAP_1_1, 'exceptions' => 0 - ); + ]; $this->soapClient = new SoapClient(null, $options); } @@ -65,8 +64,7 @@ public function __construct($id, $url, $user, $pass) /** * @see PluginOcsinventoryngOcsClient::checkConnection() */ - public function checkConnection() - { + public function checkConnection() { return !is_soap_fault($this->soapClient->ocs_config_V2('LOGLEVEL')); } @@ -75,16 +73,15 @@ public function checkConnection() * @param mixed $value * @return array */ - public function searchComputers($field, $value) - { - $xml = $this->callSoap('search_computers_V1', array($field, $value)); + public function searchComputers($field, $value) { + $xml = $this->callSoap('search_computers_V1', [$field, $value]); $computerObjs = simplexml_load_string($xml); - $computers = array(); + $computers = []; if (count($computerObjs) > 0) { foreach ($computerObjs as $obj) { - $computers [] = array( + $computers [] = [ 'ID' => (int)$obj->DATABASEID, 'CHECKSUM' => (int)$obj->CHECKSUM, 'DEVICEID' => (string)$obj->DEVICEID, @@ -92,7 +89,7 @@ public function searchComputers($field, $value) 'LASTDATE' => (string)$obj->LASTDATE, 'NAME' => (string)$obj->NAME, 'TAG' => (string)$obj->TAG - ); + ]; } } return $computers; @@ -103,8 +100,7 @@ public function searchComputers($field, $value) * @param array $options * @return array */ - public function getComputers($options) - { + public function getComputers($options) { $offset = $originalOffset = isset($options['OFFSET']) ? (int)$options['OFFSET'] : 0; $maxRecords = isset($options['MAX_RECORDS']) ? (int)$options['MAX_RECORDS'] : null; $checksum = isset($options['CHECKSUM']) ? (int)$options['CHECKSUM'] : 131071; @@ -115,7 +111,7 @@ public function getComputers($options) $originalEnd = isset($options['MAX_RECORDS']) ? $originalOffset + $maxRecords : null; $ocsMap = $this->getOcsMap(); - $computers = array(); + $computers = []; do { $options['ENGINE'] = $engine; @@ -128,7 +124,7 @@ public function getComputers($options) $xml = $this->callSoap('get_computers_V1', new PluginOcsinventoryngOcsSoapRequest($options)); - $computerObjs = array(); + $computerObjs = []; $computerObjs = simplexml_load_string($xml); if (count($computerObjs) > 0) { @@ -139,8 +135,8 @@ public function getComputers($options) $meta = $obj->META; - $computer = array( - 'META' => array( + $computer = [ + 'META' => [ 'ID' => (int)$meta->DATABASEID, 'CHECKSUM' => (int)$meta->CHECKSUM, 'DEVICEID' => (string)$meta->DEVICEID, @@ -148,13 +144,12 @@ public function getComputers($options) 'LASTDATE' => (string)$meta->LASTDATE, 'NAME' => (string)$meta->NAME, 'TAG' => (string)$meta->TAG - ) - ); - + ] + ]; foreach ($obj->children() as $sectionName => $sectionObj) { - $section = array(); - $special_sections = array('ACCOUNTINFO', 'DICO_SOFT'); + $section = []; + $special_sections = ['ACCOUNTINFO', 'DICO_SOFT']; foreach ($sectionObj as $key => $val) { if (in_array($sectionName, $special_sections)) { $section[(string)$val->attributes()->Name] = (string)$val; @@ -163,7 +158,7 @@ public function getComputers($options) } } if (!isset($computer[$sectionName])) { - $computer[$sectionName] = array(); + $computer[$sectionName] = []; } $lowerSectionName = strtolower($sectionName); @@ -194,10 +189,10 @@ public function getComputers($options) } while ($options['OFFSET'] + $computerObjs['MAX_RECORDS'] < $end); //toolbox::logdebug($computers); - return array( + return [ 'TOTAL_COUNT' => $totalCount, 'COMPUTERS' => $computers - ); + ]; } /** @@ -206,19 +201,18 @@ public function getComputers($options) * @param int $wanted * @return array */ - public function getComputerSections($ids, $checksum = self::CHECKSUM_ALL, $wanted = self::WANTED_ALL) - { - $xml = $this->callSoap('get_computer_sections_V1', array($ids, $checksum, $wanted)); + public function getComputerSections($ids, $checksum = self::CHECKSUM_ALL, $wanted = self::WANTED_ALL) { + $xml = $this->callSoap('get_computer_sections_V1', [$ids, $checksum, $wanted]); $computerObjs = simplexml_load_string($xml); - $computers = array(); + $computers = []; foreach ($computerObjs as $obj) { $id = (int)$obj['ID']; - $computer = array(); + $computer = []; foreach ($obj as $sectionName => $sectionObj) { - $computer[$sectionName] = array(); + $computer[$sectionName] = []; foreach ($sectionObj as $key => $val) { $computer[$sectionName][$key] = (string)$val; } @@ -233,8 +227,7 @@ public function getComputerSections($ids, $checksum = self::CHECKSUM_ALL, $wante /** * @param $id */ - public function getAccountInfo($id) - { + public function getAccountInfo($id) { } @@ -284,24 +277,22 @@ public function getAccountInfo($id) * ) * ) */ - public function getSnmp($options) - { + public function getSnmp($options) { } - + /** * @see PluginOcsinventoryngOcsClient::getConfig() * @param string $key * @return array|bool|mixed */ - public function getConfig($key) - { + public function getConfig($key) { $xml = $this->callSoap('ocs_config_V2', $key); if (!is_soap_fault($xml)) { $configObj = simplexml_load_string($xml); - $config = array( + $config = [ 'IVALUE' => (int)$configObj->IVALUE, 'TVALUE' => (string)$configObj->TVALUE - ); + ]; return $config; } return false; @@ -313,13 +304,12 @@ public function getConfig($key) * @param int $ivalue * @param string $tvalue */ - public function setConfig($key, $ivalue, $tvalue) - { - $this->callSoap('ocs_config_V2', array( + public function setConfig($key, $ivalue, $tvalue) { + $this->callSoap('ocs_config_V2', [ $key, $ivalue, $tvalue - )); + ]); } /** @@ -329,8 +319,7 @@ public function setConfig($key, $ivalue, $tvalue) * @param $max_date * @return array $data the computers to update */ - public function getComputersToUpdate($cfg_ocs, $max_date) - { + public function getComputersToUpdate($cfg_ocs, $max_date) { } /** @@ -338,19 +327,17 @@ public function getComputersToUpdate($cfg_ocs, $max_date) * * @return array $data the list of computers */ - public function getOCSComputers() - { + public function getOCSComputers() { } - + /** * */ - public function getDeletedComputers() - { - $deletedObjs = array(); + public function getDeletedComputers() { + $deletedObjs = []; //$xml = $this->callSoap('get_deleted_computers_V1', new PluginOcsinventoryngOcsSoapRequest(array())); //$deletedObjs = simplexml_load_string($xml); - $res = array(); + $res = []; /* if (is_array($deletedObjs) && count($deletedObjs) > 0) { foreach ($deletedObjs as $obj) { @@ -368,20 +355,19 @@ public function getDeletedComputers() * @param null $equiv * @return mixed|void */ - public function removeDeletedComputers($deleted, $equiv = null) - { + public function removeDeletedComputers($deleted, $equiv = null) { $count = 0; if (is_array($deleted)) { foreach ($deleted as $del) { - $this->callSoap('remove_deleted_computer_V1', array($del)); + $this->callSoap('remove_deleted_computer_V1', [$del]); $count++; } } else { if ($equiv) { - $this->callSoap('remove_deleted_computer_V1', array($deleted, $equiv)); + $this->callSoap('remove_deleted_computer_V1', [$deleted, $equiv]); $count++; } else { - $this->callSoap('remove_deleted_computer_V1', array($deleted)); + $this->callSoap('remove_deleted_computer_V1', [$deleted]); $count++; } } @@ -397,35 +383,31 @@ public function removeDeletedComputers($deleted, $equiv = null) * 'DELETED' => 'EQUIV' * ) */ - public function getOldAgents() - { + public function getOldAgents() { } - + /** * @param $columns * @param $table * @param $conditions * @param $sort */ - public function getUnique($columns, $table, $conditions, $sort) - { + public function getUnique($columns, $table, $conditions, $sort) { } /** * @param int $checksum * @param int $id */ - public function setChecksum($checksum, $id) - { - $this->callSoap('reset_checksum_V1', array($checksum, $id)); + public function setChecksum($checksum, $id) { + $this->callSoap('reset_checksum_V1', [$checksum, $id]); } /** * @param int $id * @return int */ - public function getChecksum($id) - { + public function getChecksum($id) { $xml = $this->callSoap('get_checksum_V1', $id); return (int)simplexml_load_string($xml); } @@ -436,13 +418,12 @@ public function getChecksum($id) * @param $table * @return array */ - public function getAccountInfoColumns($table) - { + public function getAccountInfoColumns($table) { $xml = $this->callSoap('_get_account_fields_V1', new PluginOcsinventoryngOcsSoapRequest()); - $res = array( + $res = [ 'HARDWARE_ID' => 'HARDWARE_ID', 'TAG' => 'TAG' - ); + ]; $res = array_merge($res, (array)$xml); return $res; } @@ -459,9 +440,7 @@ public function getAccountInfoColumns($table) * @param int $ssn * @param int $id */ - public function updateBios($ssn, $id) - { - + public function updateBios($ssn, $id) { } @@ -470,8 +449,7 @@ public function updateBios($ssn, $id) * @param int $tag * @param int $id */ - public function updateTag($tag, $id) - { + public function updateTag($tag, $id) { } @@ -566,15 +544,14 @@ public function updateTag($tag, $id) * @param mixed $request * @return mixed */ - private function callSoap($method, $request) - { + private function callSoap($method, $request) { if ($request instanceof PluginOcsinventoryngOcsSoapRequest) { $res = $this->soapClient->$method($request->toXml()); } else if (is_array($request)) { - $res = call_user_func_array(array( + $res = call_user_func_array([ $this->soapClient, $method - ), $request); + ], $request); } else { $res = $this->soapClient->$method($request); } @@ -585,4 +562,4 @@ private function callSoap($method, $request) return is_string($res) ? trim($res) : $res; } -} \ No newline at end of file +} diff --git a/inc/ocssoaprequest.class.php b/inc/ocssoaprequest.class.php index e967dd5d..ff9a7af0 100644 --- a/inc/ocssoaprequest.class.php +++ b/inc/ocssoaprequest.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -41,16 +41,14 @@ class PluginOcsinventoryngOcsSoapRequest /** * @param mixed $params */ - public function __construct($params) - { + public function __construct($params) { $this->params = $params; } /** * @return string */ - public function toXml() - { + public function toXml() { return $this->_toXml('REQUEST', $this->params); } @@ -59,8 +57,7 @@ public function toXml() * @param $value * @return string */ - private function _toXml($tagName, $value) - { + private function _toXml($tagName, $value) { $xml = ''; if (is_array($value)) { @@ -86,8 +83,7 @@ private function _toXml($tagName, $value) * @param $array * @return bool */ - private function isIndexed($array) - { + private function isIndexed($array) { return (bool)count(array_filter(array_keys($array), 'is_numeric')); } -} \ No newline at end of file +} diff --git a/inc/osinstall.class.php b/inc/osinstall.class.php index a135f99a..5846e930 100644 --- a/inc/osinstall.class.php +++ b/inc/osinstall.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -67,13 +67,12 @@ public static function showForItem_OperatingSystem($params) { PluginOcsinventoryngOcsServer::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); $cfg_ocs = PluginOcsinventoryngOcsServer::getConfig($plugin_ocsinventoryng_ocsservers_id); // can exists for template - if ( -// ($item->getType() == 'Item_OperatingSystem') + if (// ($item->getType() == 'Item_OperatingSystem') // && Computer::canView() -// && + // && $cfg_ocs["import_osinstall"] ) { - if ($result = $DB->request('glpi_plugin_ocsinventoryng_osinstalls', array('computers_id' => $computer->getID()))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_osinstalls', ['computers_id' => $computer->getID()])) { echo "
"; $colspan = 4; echo ""; echo ""; - $used = array(); + $used = []; echo ""; echo "
" . self::getTypeName($result->numrows()) . @@ -118,4 +117,4 @@ public static function showForItem_OperatingSystem($params) { } } } -} \ No newline at end of file +} diff --git a/inc/profile.class.php b/inc/profile.class.php index a3fcfeb3..2937c255 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -74,14 +74,14 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem $prof = new self(); self::addDefaultProfileInfos($ID, - array('plugin_ocsinventoryng' => 0, + ['plugin_ocsinventoryng' => 0, 'plugin_ocsinventoryng_sync' => 0, 'plugin_ocsinventoryng_view' => 0, 'plugin_ocsinventoryng_import' => 0, 'plugin_ocsinventoryng_link' => 0, 'plugin_ocsinventoryng_clean' => 0, 'plugin_ocsinventoryng_rule' => 0 - )); + ]); $prof->showForm($ID); } return true; @@ -94,13 +94,13 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem static function createFirstAccess($ID) { //85 self::addDefaultProfileInfos($ID, - array('plugin_ocsinventoryng' => READ + CREATE + UPDATE + PURGE, + ['plugin_ocsinventoryng' => READ + CREATE + UPDATE + PURGE, 'plugin_ocsinventoryng_sync' => READ + UPDATE, 'plugin_ocsinventoryng_view' => READ, 'plugin_ocsinventoryng_import' => READ + UPDATE, 'plugin_ocsinventoryng_link' => READ + UPDATE, 'plugin_ocsinventoryng_clean' => READ + UPDATE, - 'plugin_ocsinventoryng_rule' => READ + UPDATE), true); + 'plugin_ocsinventoryng_rule' => READ + UPDATE], true); } @@ -118,7 +118,7 @@ static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = f if (countElementsInTable('glpi_profilerights', "`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing ) { - $profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right)); + $profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]); } if (!countElementsInTable('glpi_profilerights', "`profiles_id`='$profiles_id' AND `name`='$right'") @@ -192,7 +192,7 @@ static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = f * @internal param int $items_id id of the profile * @internal param value $target url of target */ - function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE) { + function showForm($profiles_id = 0, $openform = true, $closeform = true) { global $DB, $CFG_GLPI; $profile = new Profile(); @@ -200,7 +200,7 @@ function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE) { echo "
"; - if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) + if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) && $openform ) { echo ""; @@ -211,12 +211,12 @@ function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE) { $profile->fields["name"]) . "
" . sprintf(__('%1$s : %2$s'), _n('Allowed OCSNG server', 'Allowed OCSNG servers', 2, 'ocsinventoryng'), " "); //$profile = $this->fields['id']; - $crit = array('profiles_id' => $profiles_id); + $crit = ['profiles_id' => $profiles_id]; foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers_profiles", $crit) as $data) { $used[$data['plugin_ocsinventoryng_ocsservers_id']] = $data['plugin_ocsinventoryng_ocsservers_id']; $configid[$data['plugin_ocsinventoryng_ocsservers_id']] = $data['id']; @@ -273,7 +273,7 @@ function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE) { echo "
"; Html::closeForm(); - if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) + if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) && $openform ) { @@ -282,18 +282,17 @@ function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE) { $rights = $this->getAllRights(); - $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, + $profile->displayRightsChoiceMatrix($rights, ['canedit' => $canedit, 'default_class' => 'tab_bg_2', - 'title' => __('General'))); - + 'title' => __('General')]); if ($canedit && $closeform ) { echo "
"; - echo Html::hidden('id', array('value' => $profiles_id)); + echo Html::hidden('id', ['value' => $profiles_id]); echo Html::submit(_sx('button', 'Save'), - array('name' => 'update')); + ['name' => 'update']); echo "
\n"; Html::closeForm(); } @@ -383,11 +382,11 @@ static function migrateOneProfile($profiles_id) { foreach ($DB->request('glpi_plugin_ocsinventoryng_profiles', "`profiles_id`='$profiles_id'") as $profile_data) { - $matching = array('ocsng' => 'plugin_ocsinventoryng', + $matching = ['ocsng' => 'plugin_ocsinventoryng', 'sync_ocsng' => 'plugin_ocsinventoryng_sync', 'view_ocsng' => 'plugin_ocsinventoryng_view', 'clean_ocsng' => 'plugin_ocsinventoryng_clean', - 'rule_ocs' => 'plugin_ocsinventoryng_rule'); + 'rule_ocs' => 'plugin_ocsinventoryng_rule']; $current_rights = ProfileRight::getProfileRights($profiles_id, array_values($matching)); foreach ($matching as $old => $new) { if (!isset($current_rights[$old])) { @@ -412,7 +411,7 @@ static function initProfile() { if (countElementsInTable("glpi_profilerights", "`name` = '" . $data['field'] . "'") == 0 ) { - ProfileRight::addProfileRights(array($data['field'])); + ProfileRight::addProfileRights([$data['field']]); } } @@ -457,4 +456,4 @@ static function addAllServers($profile) { $newID = $profservers->add($input); } } -} \ No newline at end of file +} diff --git a/inc/proxysetting.class.php b/inc/proxysetting.class.php index 8be4b9bf..51d13700 100644 --- a/inc/proxysetting.class.php +++ b/inc/proxysetting.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -111,7 +111,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
"; - if ($result = $DB->request('glpi_plugin_ocsinventoryng_proxysettings', array('computers_id' => $ID, 'ORDER' => 'user'))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_proxysettings', ['computers_id' => $ID, 'ORDER' => 'user'])) { echo ""; $colspan = 5; echo "
" . self::getTypeName($result->numrows()) . @@ -152,4 +152,4 @@ static function showForComputer(Computer $comp, $withtemplate = '') { } echo ""; } -} \ No newline at end of file +} diff --git a/inc/registrykey.class.php b/inc/registrykey.class.php index 19d19859..1b75485b 100644 --- a/inc/registrykey.class.php +++ b/inc/registrykey.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -55,7 +55,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -74,12 +74,12 @@ static function showForComputer($ID) { } //REGISTRY HIVE - $REGISTRY_HIVE = array("HKEY_CLASSES_ROOT", + $REGISTRY_HIVE = ["HKEY_CLASSES_ROOT", "HKEY_CURRENT_USER", "HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CURRENT_CONFIG", - "HKEY_DYN_DATA"); + "HKEY_DYN_DATA"]; $query = "SELECT * FROM `glpi_plugin_ocsinventoryng_registrykeys` @@ -176,7 +176,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem function getSearchOptions() { - $tab = array(); + $tab = []; $tab['common'] = self::getTypeName(2); @@ -185,7 +185,6 @@ function getSearchOptions() { $tab[1]['name'] = __('ID'); $tab[1]['datatype'] = 'integer'; - return $tab; } -} \ No newline at end of file +} diff --git a/inc/ruleimportentity.class.php b/inc/ruleimportentity.class.php index a5455763..7f9377f6 100644 --- a/inc/ruleimportentity.class.php +++ b/inc/ruleimportentity.class.php @@ -58,7 +58,7 @@ static function cronInfo($name) { switch ($name) { case "CheckRuleImportEntity" : - return array('description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Alerts on computers that no longer respond the rules for assigning an item to an entity', 'ocsinventoryng')); + return ['description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Alerts on computers that no longer respond the rules for assigning an item to an entity', 'ocsinventoryng')]; } } @@ -72,7 +72,7 @@ static function cronInfo($name) { */ static function cronCheckRuleImportEntity($task) { global $DB, $CFG_GLPI; - + ini_set("memory_limit", "-1"); ini_set("max_execution_time", "0"); @@ -98,7 +98,7 @@ static function cronCheckRuleImportEntity($task) { if ($plugin_ocsinventoryng_ocsservers_id > 0) { $computers = self::checkRuleImportEntity($plugin_ocsinventoryng_ocsservers_id); - + foreach ($computers as $entities_id => $items) { $message = $plugin_ocsinventoryng_ocsservers_name . ":
" . sprintf(__('Items that do not meet the allocation rules for the entity %s: %s', 'ocsinventoryng'), @@ -107,9 +107,9 @@ static function cronCheckRuleImportEntity($task) { if (NotificationEvent::raiseEvent("CheckRuleImportEntity", new PluginOcsinventoryngRuleImportEntity(), - array('entities_id' => $entities_id, - 'items' => $items))) { - + ['entities_id' => $entities_id, + 'items' => $items])) { + $cron_status = 1; if ($task) { $task->addVolume(1); @@ -143,16 +143,16 @@ static function cronCheckRuleImportEntity($task) { */ static function checkRuleImportEntity($plugin_ocsinventoryng_ocsservers_id) { - $data = array(); + $data = []; $computers = self::getComputerOcsLink($plugin_ocsinventoryng_ocsservers_id); $ruleCollection = new RuleImportEntityCollection(); - $fields = array(); + $fields = []; foreach ($computers as $computer) { $computer['_source'] = 'ocsinventoryng'; - $fields = $ruleCollection->processAllRules($computer, $fields, array('ocsid' => $computer['ocsid'])); + $fields = $ruleCollection->processAllRules($computer, $fields, ['ocsid' => $computer['ocsid']]); //case pc matched with a rule if (isset($fields['_ruleid'])) { @@ -163,7 +163,7 @@ static function checkRuleImportEntity($plugin_ocsinventoryng_ocsservers_id) { || isset($fields['locations_id']) && $fields['locations_id'] != $computer['locations_id']) { if (!isset($data[$entities_id])) { - $data[$entities_id] = array(); + $data[$entities_id] = []; } $data[$entities_id][$computer['id']] = $computer; @@ -181,7 +181,7 @@ static function checkRuleImportEntity($plugin_ocsinventoryng_ocsservers_id) { if (isset($fields['entities_id']) && $fields['entities_id'] != $entities_id) { if (!isset($data[$fields['entities_id']])) { - $data[$fields['entities_id']] = array(); + $data[$fields['entities_id']] = []; } $data[$entities_id][$computer['id']]['error'][] = 'Entity'; @@ -195,7 +195,7 @@ static function checkRuleImportEntity($plugin_ocsinventoryng_ocsservers_id) { $entities_id = $computer['entities_id']; if (!isset($data[$entities_id])) { - $data[$entities_id] = array(); + $data[$entities_id] = []; } $data[$entities_id][$computer['id']] = $computer; $data[$entities_id][$computer['id']]['error'][] = self::NO_RULE; @@ -216,7 +216,7 @@ static function getComputerOcsLink($plugin_ocsinventoryng_ocsservers_id) { $ocslinks = $ocslink->find("`plugin_ocsinventoryng_ocsservers_id` = $plugin_ocsinventoryng_ocsservers_id", "entities_id"); - $computers = array(); + $computers = []; foreach ($ocslinks as $ocs) { $computer = new Computer(); if ($computer->getFromDB($ocs['computers_id'])) { @@ -231,4 +231,4 @@ static function getComputerOcsLink($plugin_ocsinventoryng_ocsservers_id) { } -} \ No newline at end of file +} diff --git a/inc/runningprocess.class.php b/inc/runningprocess.class.php index 890d7376..51201f75 100644 --- a/inc/runningprocess.class.php +++ b/inc/runningprocess.class.php @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -111,7 +111,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
"; if ($result = $DB->request('glpi_plugin_ocsinventoryng_runningprocesses', - array('computers_id' => $ID, 'ORDER' => 'processname'))) { + ['computers_id' => $ID, 'ORDER' => 'processname'])) { echo ""; echo ""; @@ -121,7 +121,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { $header = ""; $header .= ""; $header .= ""; - $header .= ""; + $header .= ""; $header .= ""; $header .= ""; $header .= ""; @@ -155,4 +155,4 @@ static function showForComputer(Computer $comp, $withtemplate = '') { } echo ""; } -} \ No newline at end of file +} diff --git a/inc/server.class.php b/inc/server.class.php index de97af84..2dffc0c7 100644 --- a/inc/server.class.php +++ b/inc/server.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -39,8 +39,7 @@ class PluginOcsinventoryngServer extends CommonDBTM * @param $id * @return bool */ - function getFromDBbyOcsServer($id) - { + function getFromDBbyOcsServer($id) { global $DB; $query = "SELECT * @@ -58,4 +57,4 @@ function getFromDBbyOcsServer($id) } return false; } -} \ No newline at end of file +} diff --git a/inc/service.class.php b/inc/service.class.php index d8fde5c3..1a8ca1b5 100644 --- a/inc/service.class.php +++ b/inc/service.class.php @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -108,7 +108,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { return false; } echo "
"; - if ($result = $DB->request('glpi_plugin_ocsinventoryng_services', array('computers_id' => $ID, 'ORDER' => 'svcname'))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_services', ['computers_id' => $ID, 'ORDER' => 'svcname'])) { echo "
" . self::getTypeName($result->numrows()) . "
" . __('Process name', 'ocsinventoryng') . "" . __('Process ID', 'ocsinventoryng') . "" . __('User') . "" . sprintf(__('%1$s (%2$s)'),__('Process memory', 'ocsinventoryng'), __('Mio')) . "" . sprintf(__('%1$s (%2$s)'), __('Process memory', 'ocsinventoryng'), __('Mio')) . "" . __('Command line', 'ocsinventoryng') . "" . __('Description') . "" . __('Company', 'ocsinventoryng') . "
"; echo ""; @@ -155,4 +155,4 @@ static function showForComputer(Computer $comp, $withtemplate = '') { } echo ""; } -} \ No newline at end of file +} diff --git a/inc/snmpocslink.class.php b/inc/snmpocslink.class.php index 84d25f8d..a1da956c 100644 --- a/inc/snmpocslink.class.php +++ b/inc/snmpocslink.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -37,13 +37,13 @@ class PluginOcsinventoryngSnmpOcslink extends CommonDBTM { - static $snmptypes = array('Computer', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'); + static $snmptypes = ['Computer', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer']; static $rightname = "plugin_ocsinventoryng"; /** @const */ - private static $CARTRIDGE_COLOR_CYAN = array('cyan'); - private static $CARTRIDGE_COLOR_MAGENTA = array('magenta'); - private static $CARTRIDGE_COLOR_YELLOW = array('yellow', 'jaune'); - private static $CARTRIDGE_COLOR_BLACK = array('black', 'noir'); + private static $CARTRIDGE_COLOR_CYAN = ['cyan']; + private static $CARTRIDGE_COLOR_MAGENTA = ['magenta']; + private static $CARTRIDGE_COLOR_YELLOW = ['yellow', 'jaune']; + private static $CARTRIDGE_COLOR_BLACK = ['black', 'noir']; const OTHER_DATA = 'other'; /** @@ -54,8 +54,7 @@ class PluginOcsinventoryngSnmpOcslink extends CommonDBTM * * @return string|translated */ - function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) - { + function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (in_array($item->getType(), self::$snmptypes) && $this->canView() @@ -92,8 +91,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) * * @return bool|true */ - static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) - { + static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if (in_array($item->getType(), self::$snmptypes)) { @@ -112,8 +110,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem * @internal param $withtemplate (default '') * @internal param $templateid (default '') */ - function ocsFormSNMPImportOptions($ID) - { + function ocsFormSNMPImportOptions($ID) { $conf = new PluginOcsinventoryngOcsServer(); $conf->getFromDB($ID); @@ -134,10 +131,10 @@ function form_init_all(form, value) { } JAVASCRIPT; - Dropdown::showYesNo('init_all', 0, -1, array( + Dropdown::showYesNo('init_all', 0, -1, [ 'width' => '10%', 'on_change' => "form_init_all(this.form, this.selectedIndex);" - )); + ]); echo ""; echo "\n"; @@ -201,7 +198,7 @@ function accordions(id, openall) { echo "\n\n"; - + echo "\n"; echo "\n\n\n"; - + echo "\n\n\n"; - + echo "\n"; echo "\n\n\n"; - + echo "\n"; echo "\n\n\n"; - + echo "\n\n\n"; - + echo "\n\n\n"; - + echo "\n"; echo "\n"; echo ""; - + echo ""; - + } if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { echo "
" . self::getTypeName($result->numrows()) . "
" . __('Create network port', 'ocsinventoryng') . ""; Dropdown::showYesNo("importsnmp_createport", $conf->fields["importsnmp_createport"]); echo "
" . __('Computer SNMP import options', 'ocsinventoryng') . "
" . __('Import SNMP network cards', 'ocsinventoryng') . ""; @@ -210,7 +207,7 @@ function accordions(id, openall) { echo "" . __('Import SNMP memory', 'ocsinventoryng') . ""; Dropdown::showYesNo("importsnmp_computermemory", $conf->fields["importsnmp_computermemory"]); echo "
" . __('Import SNMP processors', 'ocsinventoryng') . ""; Dropdown::showYesNo("importsnmp_computerprocessors", $conf->fields["importsnmp_computerprocessors"]); @@ -223,7 +220,7 @@ function accordions(id, openall) { echo "" . __('Import SNMP volumes', 'ocsinventoryng') . ""; Dropdown::showYesNo("importsnmp_computerdisks", $conf->fields["importsnmp_computerdisks"]); echo "
" . __('Printer SNMP import options', 'ocsinventoryng') . "
" . __('Import SNMP last pages counter', 'ocsinventoryng') . ""; @@ -289,7 +286,7 @@ function accordions(id, openall) { echo "" . __('Create network port', 'ocsinventoryng') . ""; Dropdown::showYesNo("linksnmp_createport", $conf->fields["linksnmp_createport"]); echo "
" . __('Computer SNMP link options', 'ocsinventoryng') . "
" . __('Link SNMP network cards', 'ocsinventoryng') . ""; @@ -298,20 +295,20 @@ function accordions(id, openall) { echo "" . __('Link SNMP memory', 'ocsinventoryng') . ""; Dropdown::showYesNo("linksnmp_computermemory", $conf->fields["linksnmp_computermemory"]); echo "
" . __('Link SNMP processors', 'ocsinventoryng') . ""; Dropdown::showYesNo("linksnmp_computerprocessors", $conf->fields["linksnmp_computerprocessors"]); echo "" . __('Link SNMP softwares', 'ocsinventoryng') . ""; Dropdown::showYesNo("linksnmp_computersoftwares", $conf->fields["linksnmp_computersoftwares"]); echo "
" . __('Link SNMP virtual machines', 'ocsinventoryng') . ""; Dropdown::showYesNo("linksnmp_computervm", $conf->fields["linksnmp_computervm"]); echo "" . __('Link SNMP volumes', 'ocsinventoryng') . ""; Dropdown::showYesNo("linksnmp_computerdisks", $conf->fields["linksnmp_computerdisks"]); echo "
" . __('Printer SNMP link options', 'ocsinventoryng') . "
" . __('Link SNMP last pages counter', 'ocsinventoryng') . ""; @@ -359,10 +356,9 @@ function accordions(id, openall) { /** * @param $plugin_ocsinventoryng_ocsservers_id */ - static function snmpMenu($plugin_ocsinventoryng_ocsservers_id) - { + static function snmpMenu($plugin_ocsinventoryng_ocsservers_id) { global $CFG_GLPI, $DB; - $ocsservers = array(); + $ocsservers = []; //echo "
"; //echo ""; @@ -387,10 +383,10 @@ static function snmpMenu($plugin_ocsinventoryng_ocsservers_id) foreach ($DB->request($query) as $data) { $ocsservers[] = $data['id']; } - Dropdown::show('PluginOcsinventoryngOcsServer', array("condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", + Dropdown::show('PluginOcsinventoryngOcsServer', ["condition" => "`id` IN ('" . implode("','", $ocsservers) . "')", "value" => $_SESSION["plugin_ocsinventoryng_ocsservers_id"], "on_change" => "this.form.submit()", - "display_emptychoice" => false)); + "display_emptychoice" => false]); echo "
"; echo __('If you not find your OCSNG server in this dropdown, please check if your profile can access it !', 'ocsinventoryng'); @@ -465,8 +461,7 @@ static function snmpMenu($plugin_ocsinventoryng_ocsservers_id) * @return nothing * @internal param int|string $withtemplate integer withtemplate param (default '') */ - static function showForItem(CommonDBTM $item) - { + static function showForItem(CommonDBTM $item) { global $DB; //$target = Toolbox::getItemTypeFormURL(__CLASS__); @@ -500,12 +495,12 @@ static function showForItem(CommonDBTM $item) $linked_ids [] = $data['ocs_id']; $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($data['plugin_ocsinventoryng_ocsservers_id']); - $ocsResult = $ocsClient->getSnmp(array( + $ocsResult = $ocsClient->getSnmp([ 'MAX_RECORDS' => 1, - 'FILTER' => array( + 'FILTER' => [ 'IDS' => $linked_ids, - ) - )); + ] + ]); if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP']) > 0) { foreach ($ocsResult['SNMP'] as $snmp) { @@ -517,18 +512,18 @@ static function showForItem(CommonDBTM $item) echo "
" . __('Uptime', 'ocsinventoryng'); echo "" . $UPTIME . "
"; $target = Toolbox::getItemTypeFormURL(__CLASS__); - + Html::showSimpleForm($target, 'delete_link', _sx('button', 'Delete link', 'ocsinventoryng'), - array('items_id' => $items_id, + ['items_id' => $items_id, 'itemtype' => $item->getType(), 'id' => $data["id"], - 'plugin_ocsinventoryng_ocsservers_id' => $data["plugin_ocsinventoryng_ocsservers_id"])); + 'plugin_ocsinventoryng_ocsservers_id' => $data["plugin_ocsinventoryng_ocsservers_id"]]); echo "
"; @@ -559,15 +554,14 @@ static function showForItem(CommonDBTM $item) * * @param $print Printer object **/ - static function purgePrinter(Printer $print) - { + static function purgePrinter(Printer $print) { $snmp = new self(); - $snmp->deleteByCriteria(array('items_id' => $print->getField("id"), - 'itemtype' => $print->getType())); + $snmp->deleteByCriteria(['items_id' => $print->getField("id"), + 'itemtype' => $print->getType()]); $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink(); - $ipdiscover->deleteByCriteria(array('items_id' => $print->getField("id"), - 'itemtype' => $print->getType())); + $ipdiscover->deleteByCriteria(['items_id' => $print->getField("id"), + 'itemtype' => $print->getType()]); } /** @@ -575,14 +569,13 @@ static function purgePrinter(Printer $print) * * @param $per Peripheral object **/ - static function purgePeripheral(Peripheral $per) - { + static function purgePeripheral(Peripheral $per) { $snmp = new self(); - $snmp->deleteByCriteria(array('items_id' => $per->getField("id"), - 'itemtype' => $per->getType())); + $snmp->deleteByCriteria(['items_id' => $per->getField("id"), + 'itemtype' => $per->getType()]); $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink(); - $ipdiscover->deleteByCriteria(array('items_id' => $per->getField("id"), - 'itemtype' => $per->getType())); + $ipdiscover->deleteByCriteria(['items_id' => $per->getField("id"), + 'itemtype' => $per->getType()]); } /** @@ -591,14 +584,13 @@ static function purgePeripheral(Peripheral $per) * @param NetworkEquipment $net * @internal param NetworkEquipment $comp object */ - static function purgeNetworkEquipment(NetworkEquipment $net) - { + static function purgeNetworkEquipment(NetworkEquipment $net) { $snmp = new self(); - $snmp->deleteByCriteria(array('items_id' => $net->getField("id"), - 'itemtype' => $net->getType())); + $snmp->deleteByCriteria(['items_id' => $net->getField("id"), + 'itemtype' => $net->getType()]); $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink(); - $ipdiscover->deleteByCriteria(array('items_id' => $net->getField("id"), - 'itemtype' => $net->getType())); + $ipdiscover->deleteByCriteria(['items_id' => $net->getField("id"), + 'itemtype' => $net->getType()]); } @@ -607,14 +599,13 @@ static function purgeNetworkEquipment(NetworkEquipment $net) * * @param $comp Computer object **/ - static function purgeComputer(Computer $comp) - { + static function purgeComputer(Computer $comp) { $snmp = new self(); - $snmp->deleteByCriteria(array('items_id' => $comp->getField("id"), - 'itemtype' => $comp->getType())); + $snmp->deleteByCriteria(['items_id' => $comp->getField("id"), + 'itemtype' => $comp->getType()]); $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink(); - $ipdiscover->deleteByCriteria(array('items_id' => $comp->getField("id"), - 'itemtype' => $comp->getType())); + $ipdiscover->deleteByCriteria(['items_id' => $comp->getField("id"), + 'itemtype' => $comp->getType()]); } @@ -623,14 +614,13 @@ static function purgeComputer(Computer $comp) * * @param $pho Phone object **/ - static function purgePhone(Phone $pho) - { + static function purgePhone(Phone $pho) { $snmp = new self(); - $snmp->deleteByCriteria(array('items_id' => $pho->getField("id"), - 'itemtype' => $pho->getType())); + $snmp->deleteByCriteria(['items_id' => $pho->getField("id"), + 'itemtype' => $pho->getType()]); $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink(); - $ipdiscover->deleteByCriteria(array('items_id' => $pho->getField("id"), - 'itemtype' => $pho->getType())); + $ipdiscover->deleteByCriteria(['items_id' => $pho->getField("id"), + 'itemtype' => $pho->getType()]); } /** @@ -640,8 +630,7 @@ static function purgePhone(Phone $pho) * * @return nothing **/ - static function showSimpleForItem(CommonDBTM $item) - { + static function showSimpleForItem(CommonDBTM $item) { global $DB; $target = Toolbox::getItemTypeFormURL(__CLASS__); @@ -674,10 +663,10 @@ static function showSimpleForItem(CommonDBTM $item) echo ""; } else { @@ -687,12 +676,12 @@ static function showSimpleForItem(CommonDBTM $item) $linked_ids [] = $data['ocs_id']; $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($data['plugin_ocsinventoryng_ocsservers_id']); - $ocsResult = $ocsClient->getSnmp(array( + $ocsResult = $ocsClient->getSnmp([ 'MAX_RECORDS' => 1, - 'FILTER' => array( + 'FILTER' => [ 'IDS' => $linked_ids, - ) - )); + ] + ]); if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP']) > 0) { foreach ($ocsResult['SNMP'] as $snmp) { @@ -708,8 +697,8 @@ static function showSimpleForItem(CommonDBTM $item) } } if ($item->getType() == 'Printer') { - $cartridges = array(); - $trays = array(); + $cartridges = []; + $trays = []; if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP']) > 0) { foreach ($ocsResult['SNMP'] as $snmp) { @@ -720,10 +709,10 @@ static function showSimpleForItem(CommonDBTM $item) } if (count($cartridges) > 0) { - $colors = array(self::$CARTRIDGE_COLOR_BLACK, + $colors = [self::$CARTRIDGE_COLOR_BLACK, self::$CARTRIDGE_COLOR_CYAN, self::$CARTRIDGE_COLOR_MAGENTA, - self::$CARTRIDGE_COLOR_YELLOW); + self::$CARTRIDGE_COLOR_YELLOW]; echo ""; foreach ($cartridges as $cartridge) { @@ -819,8 +808,7 @@ static function showSimpleForItem(CommonDBTM $item) * @param $params * @return array */ - static function processSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lock = 0, $params) - { + static function processSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lock = 0, $params) { global $DB; PluginOcsinventoryngOcsServer::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); @@ -847,8 +835,7 @@ static function processSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lock * @param $params * @return array */ - static function importSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params) - { + static function importSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params) { global $DB; $p['entity'] = -1; @@ -878,22 +865,22 @@ static function importSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params if ($itemtype == "NetworkEquipment") { - $id = self::addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add",false,$cfg_ocs); + $id = self::addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add", false, $cfg_ocs); } else if ($itemtype == "Printer") { - $id = self::addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add",false,$cfg_ocs); + $id = self::addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add", false, $cfg_ocs); } else if ($itemtype == "Computer") { - $id = self::addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add",false,$cfg_ocs); + $id = self::addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add", false, $cfg_ocs); } else if ($itemtype == "Peripheral" || $itemtype == "Phone") { - $id = self::addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add",false,$cfg_ocs); + $id = self::addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype, 0, $ocsSnmp, $loc_id, $dom_id, "add", false, $cfg_ocs); } - //TODOSNMP + //TODOSNMP //Monitor & Phone ??? if ($id) { $date = date("Y-m-d H:i:s"); @@ -908,18 +895,18 @@ static function importSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params $DB->query($query); - return array('status' => PluginOcsinventoryngOcsServer::SNMP_IMPORTED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_IMPORTED, //'entities_id' => $data['entities_id'], - ); + ]; } else { - return array('status' => PluginOcsinventoryngOcsServer::SNMP_FAILED_IMPORT, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_FAILED_IMPORT, //'entities_id' => $data['entities_id'], - ); + ]; } } else { - return array('status' => PluginOcsinventoryngOcsServer::SNMP_FAILED_IMPORT, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_FAILED_IMPORT, //'entities_id' => $data['entities_id'], - ); + ]; } } @@ -960,22 +947,21 @@ static function importSnmp($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params * @param bool $linked * @return int */ - static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) - { + static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) { global $DB; $snmpDevice = new $itemtype(); - $input = array( + $input = [ "is_dynamic" => 1, "entities_id" => (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0), "have_ethernet" => 1, - ); + ]; //TODOSNMP TO TEST: - //'PRINTER' => + //'PRINTER' => // array (size=1) - // 0 => + // 0 => // array (size=6) // 'SNMP_ID' => string '4' (length=1) // 'NAME' => string 'MP C3003' (length=8) @@ -984,7 +970,6 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty // 'STATUS' => string 'idle' (length=4) // 'ERRORSTATE' => string '' (length=0) - if (($cfg_ocs['importsnmp_name'] && $action == "add") || ($cfg_ocs['linksnmp_name'] && $linked) || ($action == "update" && $cfg_ocs['importsnmp_name'] && !$linked) @@ -1021,7 +1006,6 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty $input["last_pages_counter"] = $ocsSnmp['PRINTER'][0]['COUNTER']; } - if ($loc_id > 0) { $input["locations_id"] = $loc_id; } @@ -1032,7 +1016,7 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty $id_printer = 0; if ($action == "add") { - $id_printer = $snmpDevice->add($input, array('unicity_error_message' => true), $cfg_ocs['history_hardware']); + $id_printer = $snmpDevice->add($input, ['unicity_error_message' => true], $cfg_ocs['history_hardware']); } else { $id_printer = $ID; $input["id"] = $ID; @@ -1040,11 +1024,10 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty $input["entities_id"] = $snmpDevice->fields['entities_id']; } - $snmpDevice->update($input, $cfg_ocs['history_hardware'], array('unicity_error_message' => false, - '_no_history' => !$cfg_ocs['history_hardware'])); + $snmpDevice->update($input, $cfg_ocs['history_hardware'], ['unicity_error_message' => false, + '_no_history' => !$cfg_ocs['history_hardware']]); } - if ($id_printer > 0 && isset($ocsSnmp['MEMORIES']) && (($cfg_ocs['importsnmp_printermemory'] && $action == "add") @@ -1054,7 +1037,7 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty && count($ocsSnmp['MEMORIES']) > 0 && $ocsSnmp['MEMORIES'][0]['CAPACITY'] > 0 ) { - + $dev['designation'] = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep(__("Printer Memory", 'ocsinventoryng'))); $item = new $itemtype(); @@ -1078,15 +1061,15 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty AND `itemtype` = '" . $itemtype . "'"; $DB->query($query); } -// CANNOT USE BEFORE 9.1.2 - for _no_history problem -// $CompDevice->deleteByCriteria(array('items_id' => $id_printer, -// 'itemtype' => $itemtype), 1); - $CompDevice->add(array('items_id' => $id_printer, + // CANNOT USE BEFORE 9.1.2 - for _no_history problem + // $CompDevice->deleteByCriteria(array('items_id' => $id_printer, + // 'itemtype' => $itemtype), 1); + $CompDevice->add(['items_id' => $id_printer, 'itemtype' => $itemtype, 'size' => $ocsSnmp['MEMORIES'][0]['CAPACITY'], 'entities_id' => $entity, 'devicememories_id' => $device_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } @@ -1096,7 +1079,7 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty || ($action == "update" && $cfg_ocs['importsnmp_createport'] && !$linked) || ($action == "update" && $cfg_ocs['linksnmp_createport'] && $linked)) ) { - + //Delete Existing network config $query = "SELECT `id` FROM `glpi_networkports` @@ -1111,20 +1094,20 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty AND `itemtype` = 'NetworkPort'"; foreach ($DB->request($queryPort) as $networkNameID) { - + $ipAddress = new IPAddress(); - $ipAddress->deleteByCriteria(array('items_id' => $networkNameID['id'], - 'itemtype' => 'NetworkName'), 1); + $ipAddress->deleteByCriteria(['items_id' => $networkNameID['id'], + 'itemtype' => 'NetworkName'], 1); } - + $nn = new NetworkName(); - $nn->deleteByCriteria(array('items_id' => $networkPortID['id'], - 'itemtype' => 'NetworkPort'), 1); + $nn->deleteByCriteria(['items_id' => $networkPortID['id'], + 'itemtype' => 'NetworkPort'], 1); } $np = new NetworkPort(); - $np->deleteByCriteria(array('items_id' => $id_printer, - 'itemtype' => $itemtype), 1); - + $np->deleteByCriteria(['items_id' => $id_printer, + 'itemtype' => $itemtype], 1); + //Add network port $ip = $ocsSnmp['META']['IPADDR']; $mac = $ocsSnmp['META']['MACADDR']; @@ -1140,24 +1123,24 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty $entity = $item->fields['entities_id']; } - $port_input = array('name' => $ocsSnmp['PRINTER'][0]['NAME'], + $port_input = ['name' => $ocsSnmp['PRINTER'][0]['NAME'], 'mac' => $mac, 'items_id' => $id_printer, 'itemtype' => $itemtype, 'instantiation_type' => "NetworkPortEthernet", "entities_id" => $entity, - "NetworkName__ipaddresses" => array("-100" => $ip), + "NetworkName__ipaddresses" => ["-100" => $ip], '_create_children' => 1, //'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; - $np->add($port_input, array(), $cfg_ocs['history_network']); + $np->add($port_input, [], $cfg_ocs['history_network']); } //TODOSNMP TO TEST: - //'PRINTER' => + //'PRINTER' => // array (size=1) - // 0 => + // 0 => //array (size=7) // 'ID' => string '6' (length=1) // 'SNMP_ID' => string '4' (length=1) @@ -1207,17 +1190,16 @@ static function addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemty * @param bool $linked * @return int */ - static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) - { + static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) { global $DB; $snmpDevice = new $itemtype(); - $input = array( + $input = [ "is_dynamic" => 1, "entities_id" => (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0), "is_recursive" => 0, - ); + ]; if (($cfg_ocs['importsnmp_name'] && $action == "add") || ($cfg_ocs['linksnmp_name'] && $linked) @@ -1307,15 +1289,15 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id } $id_network = 0; if ($action == "add") { - $id_network = $snmpDevice->add($input, array('unicity_error_message' => true), $cfg_ocs['history_hardware']); + $id_network = $snmpDevice->add($input, ['unicity_error_message' => true], $cfg_ocs['history_hardware']); } else { $input["id"] = $ID; $id_network = $ID; if ($snmpDevice->getFromDB($id_network)) { $input["entities_id"] = $snmpDevice->fields['entities_id']; } - $snmpDevice->update($input, $cfg_ocs['history_hardware'], array('unicity_error_message' => false, - '_no_history' => !$cfg_ocs['history_hardware'])); + $snmpDevice->update($input, $cfg_ocs['history_hardware'], ['unicity_error_message' => false, + '_no_history' => !$cfg_ocs['history_hardware']]); } if ($id_network > 0 @@ -1358,15 +1340,15 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id AND `itemtype` = '" . $itemtype . "'"; $DB->query($query); } -// CANNOT USE BEFORE 9.1.2 - for _no_history problem -// $CompDevice->deleteByCriteria(array('items_id' => $id_network, -// 'itemtype' => $itemtype), 1); - $CompDevice->add(array('items_id' => $id_network, + // CANNOT USE BEFORE 9.1.2 - for _no_history problem + // $CompDevice->deleteByCriteria(array('items_id' => $id_network, + // 'itemtype' => $itemtype), 1); + $CompDevice->add(['items_id' => $id_network, 'itemtype' => $itemtype, 'entities_id' => $entity, 'serial' => $serial, 'devicepowersupplies_id' => $power_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } @@ -1404,14 +1386,14 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id AND `itemtype` = '" . $itemtype . "'"; $DB->query($query); } -// CANNOT USE BEFORE 9.1.2 - for _no_history problem -// $CompDevice->deleteByCriteria(array('items_id' => $id_network, -// 'itemtype' => $itemtype), 1); - $CompDevice->add(array('items_id' => $id_network, + // CANNOT USE BEFORE 9.1.2 - for _no_history problem + // $CompDevice->deleteByCriteria(array('items_id' => $id_network, + // 'itemtype' => $itemtype), 1); + $CompDevice->add(['items_id' => $id_network, 'itemtype' => $itemtype, 'entities_id' => $entity, 'devicepcis_id' => $device_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } } @@ -1424,9 +1406,9 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id //Add local port $ip = $ocsSnmp['META']['IPADDR']; $mac = $ocsSnmp['META']['MACADDR']; - + //if ($cfg_ocs['history_devices']) { - + //$table = getTableForItemType("NetworkPort"); //$query = "DELETE // FROM `glpi_networkports` @@ -1435,7 +1417,7 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id // AND `instantiation_type` = 'NetworkPortLocal'"; //$DB->query($query); //} - + $query = "SELECT `id` FROM `glpi_networkports` WHERE `items_id` = '".$id_network."' @@ -1449,21 +1431,20 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id AND `itemtype` = 'NetworkPort'"; foreach ($DB->request($queryPort) as $networkNameID) { - + $ipAddress = new IPAddress(); - $ipAddress->deleteByCriteria(array('items_id' => $networkNameID['id'], - 'itemtype' => 'NetworkName'), 1); + $ipAddress->deleteByCriteria(['items_id' => $networkNameID['id'], + 'itemtype' => 'NetworkName'], 1); } - + $nn = new NetworkName(); - $nn->deleteByCriteria(array('items_id' => $networkPortID['id'], - 'itemtype' => 'NetworkPort'), 1); + $nn->deleteByCriteria(['items_id' => $networkPortID['id'], + 'itemtype' => 'NetworkPort'], 1); } $np = new NetworkPort(); - $np->deleteByCriteria(array('items_id' => $id_network, - 'itemtype' => $itemtype), 1); - - + $np->deleteByCriteria(['items_id' => $id_network, + 'itemtype' => $itemtype], 1); + $np = new NetworkPort(); $np->getFromDBByQuery("WHERE `mac` LIKE '$mac' AND `items_id` = '$id_network' @@ -1476,20 +1457,20 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id $entity = $item->fields['entities_id']; } - $port_input = array('name' => $ocsSnmp['META']['NAME'], + $port_input = ['name' => $ocsSnmp['META']['NAME'], 'mac' => $mac, 'items_id' => $id_network, 'itemtype' => $itemtype, 'instantiation_type' => "NetworkPortLocal", "entities_id" => $entity, - "NetworkName__ipaddresses" => array("-100" => $ip), + "NetworkName__ipaddresses" => ["-100" => $ip], '_create_children' => 1, 'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; - $np->add($port_input, array(), $cfg_ocs['history_network']); + $np->add($port_input, [], $cfg_ocs['history_network']); } - + //All PORTS if ($id_network > 0 && isset($ocsSnmp['NETWORKS']) @@ -1503,7 +1484,7 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id // WHERE `items_id` = '" . $id_network . "' // AND `itemtype` = '" . $itemtype . "'"; //$DB->query($query); - + //$table = getTableForItemType("NetworkPort"); //$query = "DELETE // FROM `glpi_networkports` @@ -1511,9 +1492,9 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id // AND `itemtype` = '" . $itemtype . "' // AND `instantiation_type` = 'NetworkPortEthernet'"; // $DB->query($query); - + // CANNOT USE BEFORE 9.1.2 - for _no_history problem - + //$query = "SELECT `id` // FROM `glpi_networkports` // WHERE `items_id` = '".$id_network."' @@ -1528,12 +1509,12 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id // AND `itemtype` = 'NetworkPort'"; // foreach ($DB->request($queryPort) as $networkNameID) { - + // $ipAddress = new IPAddress(); // $ipAddress->deleteByCriteria(array('items_id' => $networkNameID['id'], // 'itemtype' => 'NetworkName'), 1); // } - + // $nn = new NetworkName(); // $nn->deleteByCriteria(array('items_id' => $networkPortID['id'], // 'itemtype' => 'NetworkPort'), 1); @@ -1542,9 +1523,8 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id //$np->deleteByCriteria(array('items_id' => $id_network, // 'itemtype' => $itemtype, // 'instantiation_type' => 'NetworkPortEthernet'), 1); - + //} - foreach ($ocsSnmp['NETWORKS'] as $k => $net) { //$dev["designation"] = $net['SLOT']; @@ -1554,11 +1534,9 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id $name_dest = $net['DEVICEPORT']; $net['DEVICENAME'] = str_replace("SEP", "", $net['DEVICENAME']); $mac_dest = self::addMacSeparator($net['DEVICENAME']); - - + $ip_dest = $net['DEVICEADDRESS']; - - + $item = new $itemtype(); $entity = (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0); if ($item->getFromDB($id_network)) { @@ -1571,58 +1549,58 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id //$device_id = $device->import($dev); //if ($device_id) { - + //$id = new Item_DeviceNetworkCard(); - //$id->getFromDBByQuery("WHERE `mac` LIKE '$mac' - // AND `items_id` = '$id_network' + //$id->getFromDBByQuery("WHERE `mac` LIKE '$mac' + // AND `items_id` = '$id_network' // AND `itemtype` LIKE '$itemtype'"); //if (count($id->fields) < 1) { - + // $CompDevice->add(array('items_id' => $id_network, // 'itemtype' => $itemtype, // 'mac' => $mac, // 'entities_id' => $entity, // 'devicenetworkcards_id' => $device_id, // 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); - + //} $np = new NetworkPort(); $np->getFromDBByQuery("WHERE `mac` LIKE '$mac' AND `items_id` = '$id_network' AND `itemtype` LIKE '$itemtype' AND `instantiation_type` = 'NetworkPortEthernet' "); - if (count($np->fields) < 1) { - - $item = new $itemtype(); - $entity = (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0); - if ($item->getFromDB($id_network)) { - $entity = $item->fields['entities_id']; - } + if (count($np->fields) < 1) { - $port_input = array('name' => $net['SLOT'], - 'mac' => $mac, - 'items_id' => $id_network, - 'itemtype' => $itemtype, - 'instantiation_type' => "NetworkPortEthernet", - "entities_id" => $entity, - //"NetworkName__ipaddresses" => array("-100" => $ip), - '_create_children' => 1, - 'is_dynamic' => 1, - 'is_deleted' => 0); - - $np_src = $np->add($port_input, array(), $cfg_ocs['history_network']); + $item = new $itemtype(); + $entity = (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0); + if ($item->getFromDB($id_network)) { + $entity = $item->fields['entities_id']; } - + + $port_input = ['name' => $net['SLOT'], + 'mac' => $mac, + 'items_id' => $id_network, + 'itemtype' => $itemtype, + 'instantiation_type' => "NetworkPortEthernet", + "entities_id" => $entity, + //"NetworkName__ipaddresses" => array("-100" => $ip), + '_create_children' => 1, + 'is_dynamic' => 1, + 'is_deleted' => 0]; + + $np_src = $np->add($port_input, [], $cfg_ocs['history_network']); + } + $link = new NetworkPort_NetworkPort(); $np_dest = new NetworkPort(); $np_dest->getFromDBByQuery("WHERE `mac` LIKE '$mac_dest' "); - if (count($np_dest->fields) > 0) { - - $link_input = array('networkports_id_1' => $np_src, - 'networkports_id_2' => $np_dest->fields['id']); - $link->add($link_input, array(), $cfg_ocs['history_network']); - - } + if (count($np_dest->fields) > 0) { + + $link_input = ['networkports_id_1' => $np_src, + 'networkports_id_2' => $np_dest->fields['id']]; + $link->add($link_input, [], $cfg_ocs['history_network']); + + } //} } } @@ -1630,11 +1608,10 @@ static function addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id return $id_network; } - - - public static function addMacSeparator($mac, $separator = ':') - { - return join($separator, str_split($mac, 2)); + + + public static function addMacSeparator($mac, $separator = ':') { + return join($separator, str_split($mac, 2)); } /** @@ -1648,16 +1625,15 @@ public static function addMacSeparator($mac, $separator = ':') * @param bool $linked * @return int */ - static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) - { + static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) { global $DB; - + $snmpDevice = new $itemtype(); - $input = array( + $input = [ "is_dynamic" => 1, "entities_id" => (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0) - ); + ]; if (($cfg_ocs['importsnmp_name'] && $action == "add") || ($cfg_ocs['linksnmp_name'] && $linked) @@ -1691,17 +1667,17 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt $id_item = 0; if ($action == "add") { - $id_item = $snmpDevice->add($input, array('unicity_error_message' => true), $cfg_ocs['history_hardware']); + $id_item = $snmpDevice->add($input, ['unicity_error_message' => true], $cfg_ocs['history_hardware']); } else { $input["id"] = $ID; $id_item = $ID; if ($snmpDevice->getFromDB($id_item)) { $input["entities_id"] = $snmpDevice->fields['entities_id']; } - $snmpDevice->update($input, $cfg_ocs['history_hardware'], array('unicity_error_message' => false, - '_no_history' => !$cfg_ocs['history_hardware'])); + $snmpDevice->update($input, $cfg_ocs['history_hardware'], ['unicity_error_message' => false, + '_no_history' => !$cfg_ocs['history_hardware']]); } - + if ($id_item > 0 && isset($ocsSnmp['MEMORIES']) && (($cfg_ocs['importsnmp_computermemory'] && $action == "add") @@ -1734,18 +1710,18 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt AND `itemtype` = '" . $itemtype . "'"; $DB->query($query); } -// CANNOT USE BEFORE 9.1.2 - for _no_history problem -// $CompDevice->deleteByCriteria(array('items_id' => $id_item, -// 'itemtype' => $itemtype), 1); - $CompDevice->add(array('items_id' => $id_item, + // CANNOT USE BEFORE 9.1.2 - for _no_history problem + // $CompDevice->deleteByCriteria(array('items_id' => $id_item, + // 'itemtype' => $itemtype), 1); + $CompDevice->add(['items_id' => $id_item, 'itemtype' => $itemtype, 'size' => $ocsSnmp['MEMORIES'][0]['CAPACITY'], 'entities_id' => $entity, 'devicememories_id' => $device_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } - + if ($id_item > 0 && isset($ocsSnmp['NETWORKS']) && (($cfg_ocs['importsnmp_computernetworkcards'] && $action == "add") @@ -1763,10 +1739,10 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt AND `itemtype` = '" . $itemtype . "'"; $DB->query($query); } -// CANNOT USE BEFORE 9.1.2 - for _no_history problem -// $CompDevice->deleteByCriteria(array('items_id' => $id_item, -// 'itemtype' => $itemtype), 1); - + // CANNOT USE BEFORE 9.1.2 - for _no_history problem + // $CompDevice->deleteByCriteria(array('items_id' => $id_item, + // 'itemtype' => $itemtype), 1); + foreach ($ocsSnmp['NETWORKS'] as $k => $net) { $dev["designation"] = $net['SLOT']; $dev["comment"] = $net['TYPE']; @@ -1792,17 +1768,17 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt $device_id = $device->import($dev); if ($device_id) { - - $CompDevice->add(array('items_id' => $id_item, + + $CompDevice->add(['items_id' => $id_item, 'itemtype' => $itemtype, 'mac' => $mac, 'entities_id' => $entity, 'devicenetworkcards_id' => $device_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } } - + if ($id_item > 0 && isset($ocsSnmp['SOFTWARES']) && (($cfg_ocs['importsnmp_computersoftwares'] && $action == "add") @@ -1817,8 +1793,8 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt $entity = $item->fields['entities_id']; } PluginOcsinventoryngOcsServer::updateSoftware($cfg_ocs, $id_item, $ocsSnmp, $entity, false); - - } + + } if ($id_item > 0 && isset($ocsSnmp['CPU']) && (($cfg_ocs['importsnmp_computerprocessors'] && $action == "add") @@ -1836,10 +1812,10 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt AND `itemtype` = '" . $itemtype . "'"; $DB->query($query); } -// CANNOT USE BEFORE 9.1.2 - for _no_history problem -// $CompDevice->deleteByCriteria(array('items_id' => $id_item, -// 'itemtype' => $itemtype), 1); - + // CANNOT USE BEFORE 9.1.2 - for _no_history problem + // $CompDevice->deleteByCriteria(array('items_id' => $id_item, + // 'itemtype' => $itemtype), 1); + foreach ($ocsSnmp['CPU'] as $k => $processor) { $dev["designation"] = $processor['TYPE']; $dev["manufacturers_id"] = Dropdown::importExternal('Manufacturer', PluginOcsinventoryngOcsServer::encodeOcsDataInUtf8($cfg_ocs['ocs_db_utf8'], $processor['MANUFACTURER'])); @@ -1864,18 +1840,17 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt $device_id = $device->import($dev); if ($device_id) { - - $CompDevice->add(array('items_id' => $id_item, + + $CompDevice->add(['items_id' => $id_item, 'itemtype' => $itemtype, 'frequency' => $speed, 'entities_id' => $entity, 'deviceprocessors_id' => $device_id, - 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']); + 'is_dynamic' => 1], [], $cfg_ocs['history_devices']); } } } - - + if ($id_item > 0 && isset($ocsSnmp['VIRTUALMACHINES']) && (($cfg_ocs['importsnmp_computervm'] && $action == "add") @@ -1884,13 +1859,13 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt || ($action == "update" && $cfg_ocs['linksnmp_computervm'] && $linked)) && count($ocsSnmp['VIRTUALMACHINES']) > 0 ) { - $already_processed = array(); + $already_processed = []; $virtualmachine = new ComputerVirtualMachine(); foreach ($ocsSnmp['VIRTUALMACHINES'] as $k => $ocsVirtualmachine) { - + $ocsVirtualmachine = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsVirtualmachine)); - $vm = array(); + $vm = []; $vm['name'] = $ocsVirtualmachine['NAME']; $vm['vcpu'] = $ocsVirtualmachine['CPU']; $vm['ram'] = $ocsVirtualmachine['MEMORY']; @@ -1921,7 +1896,7 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt } if (!$id) { $virtualmachine->reset(); - $id_vm = $virtualmachine->add($vm, array(), $cfg_ocs['history_vm']); + $id_vm = $virtualmachine->add($vm, [], $cfg_ocs['history_vm']); if ($id_vm) { $already_processed[] = $id_vm; } @@ -1943,13 +1918,13 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt } foreach ($DB->request($query) as $data) { //Delete all connexions - $virtualmachine->delete(array('id' => $data['id'], + $virtualmachine->delete(['id' => $data['id'], '_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, - '_no_history' => !$cfg_ocs['history_vm']), true, $cfg_ocs['history_vm']); + '_no_history' => !$cfg_ocs['history_vm']], true, $cfg_ocs['history_vm']); } } } - + if ($id_item > 0 && (($cfg_ocs['importsnmp_createport'] && $action == "add") || ($cfg_ocs['linksnmp_createport'] && $linked) @@ -1970,19 +1945,19 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt AND `itemtype` = 'NetworkPort'"; foreach ($DB->request($queryPort) as $networkNameID) { - + $ipAddress = new IPAddress(); - $ipAddress->deleteByCriteria(array('items_id' => $networkNameID['id'], - 'itemtype' => 'NetworkName'), 1); + $ipAddress->deleteByCriteria(['items_id' => $networkNameID['id'], + 'itemtype' => 'NetworkName'], 1); } - + $nn = new NetworkName(); - $nn->deleteByCriteria(array('items_id' => $networkPortID['id'], - 'itemtype' => 'NetworkPort'), 1); + $nn->deleteByCriteria(['items_id' => $networkPortID['id'], + 'itemtype' => 'NetworkPort'], 1); } $np = new NetworkPort(); - $np->deleteByCriteria(array('items_id' => $id_item, - 'itemtype' => $itemtype), 1); + $np->deleteByCriteria(['items_id' => $id_item, + 'itemtype' => $itemtype], 1); //Add network port $ip = $ocsSnmp['META']['IPADDR']; @@ -1997,18 +1972,18 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt if ($item->getFromDB($id_item)) { $entity = $item->fields['entities_id']; } - $port_input = array('name' => $ocsSnmp['META']['NAME'], + $port_input = ['name' => $ocsSnmp['META']['NAME'], 'mac' => $mac, 'items_id' => $id_item, 'itemtype' => $itemtype, 'instantiation_type' => "NetworkPortEthernet", "entities_id" => $entity, - "NetworkName__ipaddresses" => array("-100" => $ip), + "NetworkName__ipaddresses" => ["-100" => $ip], '_create_children' => 1, //'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; - $np->add($port_input, array(), $cfg_ocs['history_network']); + $np->add($port_input, [], $cfg_ocs['history_network']); } } @@ -2021,12 +1996,12 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt || ($action == "update" && $cfg_ocs['linksnmp_computerdisks'] && $linked)) && count($ocsSnmp['COMPUTERDISKS']) > 0 ) { - $already_processed = array(); + $already_processed = []; foreach ($ocsSnmp['COMPUTERDISKS'] as $k => $ocsComputerDisks) { $ocsComputerDisks = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsComputerDisks)); - $disk = array(); + $disk = []; $disk['computers_id'] = $id_item; $disk['name'] = $ocsComputerDisks['FILESYSTEM']; $disk['mountpoint'] = $ocsComputerDisks['VOLUMN']; @@ -2056,7 +2031,7 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt if (!$id) { $computerDisk->reset(); $disk['is_dynamic'] = 1; - $id_disk = $computerDisk->add($disk, array(), $cfg_ocs['history_drives']); + $id_disk = $computerDisk->add($disk, [], $cfg_ocs['history_drives']); $already_processed[] = $id_disk; } else { // Only update if needed @@ -2092,15 +2067,15 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt } foreach ($DB->request($query) as $data) { //Delete all connexions - $computerDisk->delete(array('id' => $data['id'], + $computerDisk->delete(['id' => $data['id'], '_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, - '_no_history' => !$cfg_ocs['history_drives']), + '_no_history' => !$cfg_ocs['history_drives']], true, $cfg_ocs['history_drives']); } return $id_item; } - + /** * @param $plugin_ocsinventoryng_ocsservers_id * @param $itemtype @@ -2112,16 +2087,15 @@ static function addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemt * @param bool $linked * @return int */ - static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) - { + static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype, $ID = 0, $ocsSnmp, $loc_id, $dom_id, $action, $linked = false, $cfg_ocs) { global $DB; - + $snmpDevice = new $itemtype(); - $input = array( + $input = [ "is_dynamic" => 1, "entities_id" => (isset($_SESSION['glpiactive_entity'])?$_SESSION['glpiactive_entity']:0) - ); + ]; if (($cfg_ocs['importsnmp_name'] && $action == "add") || ($cfg_ocs['linksnmp_name'] && $linked) @@ -2155,16 +2129,16 @@ static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype $id_item = 0; if ($action == "add") { - $id_item = $snmpDevice->add($input, array('unicity_error_message' => true), $cfg_ocs['history_hardware']); + $id_item = $snmpDevice->add($input, ['unicity_error_message' => true], $cfg_ocs['history_hardware']); } else { $input["id"] = $ID; $id_item = $ID; if ($snmpDevice->getFromDB($id_item)) { $input["entities_id"] = $snmpDevice->fields['entities_id']; } - - $snmpDevice->update($input, $cfg_ocs['history_hardware'], array('unicity_error_message' => false, - '_no_history' => !$cfg_ocs['history_hardware'])); + + $snmpDevice->update($input, $cfg_ocs['history_hardware'], ['unicity_error_message' => false, + '_no_history' => !$cfg_ocs['history_hardware']]); } if ($id_item > 0 @@ -2173,7 +2147,7 @@ static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype || ($action == "update" && $cfg_ocs['importsnmp_createport'] && !$linked) || ($action == "update" && $cfg_ocs['linksnmp_createport'] && $linked)) ) { - + //Delete Existing network config $query = "SELECT `id` FROM `glpi_networkports` @@ -2188,19 +2162,19 @@ static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype AND `itemtype` = 'NetworkPort'"; foreach ($DB->request($queryPort) as $networkNameID) { - + $ipAddress = new IPAddress(); - $ipAddress->deleteByCriteria(array('items_id' => $networkNameID['id'], - 'itemtype' => 'NetworkName'), 1); + $ipAddress->deleteByCriteria(['items_id' => $networkNameID['id'], + 'itemtype' => 'NetworkName'], 1); } - + $nn = new NetworkName(); - $nn->deleteByCriteria(array('items_id' => $networkPortID['id'], - 'itemtype' => 'NetworkPort'), 1); + $nn->deleteByCriteria(['items_id' => $networkPortID['id'], + 'itemtype' => 'NetworkPort'], 1); } $np = new NetworkPort(); - $np->deleteByCriteria(array('items_id' => $id_item, - 'itemtype' => $itemtype), 1); + $np->deleteByCriteria(['items_id' => $id_item, + 'itemtype' => $itemtype], 1); //Add network port $ip = $ocsSnmp['META']['IPADDR']; @@ -2215,18 +2189,18 @@ static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype if ($item->getFromDB($id_item)) { $entity = $item->fields['entities_id']; } - $port_input = array('name' => $ocsSnmp['META']['NAME'], + $port_input = ['name' => $ocsSnmp['META']['NAME'], 'mac' => $mac, 'items_id' => $id_item, 'itemtype' => $itemtype, 'instantiation_type' => "NetworkPortEthernet", "entities_id" => $entity, - "NetworkName__ipaddresses" => array("-100" => $ip), + "NetworkName__ipaddresses" => ["-100" => $ip], '_create_children' => 1, //'is_dynamic' => 1, - 'is_deleted' => 0); + 'is_deleted' => 0]; - $np->add($port_input, array(), $cfg_ocs['history_network']); + $np->add($port_input, [], $cfg_ocs['history_network']); } } @@ -2238,8 +2212,7 @@ static function addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype * @param $plugin_ocsinventoryng_ocsservers_id * @return array */ - static function updateSnmp($ID, $plugin_ocsinventoryng_ocsservers_id) - { + static function updateSnmp($ID, $plugin_ocsinventoryng_ocsservers_id) { global $DB; $query = "SELECT * FROM `glpi_plugin_ocsinventoryng_snmpocslinks` @@ -2272,56 +2245,55 @@ static function updateSnmp($ID, $plugin_ocsinventoryng_ocsservers_id) } if ($itemtype == "Printer") { - self::addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked,$cfg_ocs); + self::addOrUpdatePrinter($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked, $cfg_ocs); $now = date("Y-m-d H:i:s"); $sql = "UPDATE `glpi_plugin_ocsinventoryng_snmpocslinks` SET `last_update` = '" . $now . "' WHERE `id` = " . $ID . ";"; $DB->query($sql); - return array('status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, //'entities_id' => $data['entities_id'], - ); + ]; } else if ($itemtype == "NetworkEquipment") { - self::addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked,$cfg_ocs); + self::addOrUpdateNetworkEquipment($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked, $cfg_ocs); $now = date("Y-m-d H:i:s"); $sql = "UPDATE `glpi_plugin_ocsinventoryng_snmpocslinks` SET `last_update` = '" . $now . "' WHERE `id` = " . $ID . ";"; $DB->query($sql); - return array('status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, //'entities_id' => $data['entities_id'], - ); + ]; } else if ($itemtype == "Computer") { - self::addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked,$cfg_ocs); + self::addOrUpdateComputer($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked, $cfg_ocs); $now = date("Y-m-d H:i:s"); $sql = "UPDATE `glpi_plugin_ocsinventoryng_snmpocslinks` SET `last_update` = '" . $now . "' WHERE `id` = " . $ID . ";"; $DB->query($sql); - return array('status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, //'entities_id' => $data['entities_id'], - ); + ]; } else if ($itemtype == "Peripheral" || $itemtype == "Phone" ) { - self::addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked,$cfg_ocs); + self::addOrUpdateOther($plugin_ocsinventoryng_ocsservers_id, $itemtype, $items_id, $ocsSnmp, $loc_id, $dom_id, "update", $linked, $cfg_ocs); $now = date("Y-m-d H:i:s"); $sql = "UPDATE `glpi_plugin_ocsinventoryng_snmpocslinks` SET `last_update` = '" . $now . "' WHERE `id` = " . $ID . ";"; $DB->query($sql); - return array('status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_SYNCHRONIZED, //'entities_id' => $data['entities_id'], - ); + ]; } - - return array('status' => PluginOcsinventoryngOcsServer::SNMP_NOTUPDATED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_NOTUPDATED, //'entities_id' => $data['entities_id'], - ); + ]; } /** @@ -2332,10 +2304,9 @@ static function updateSnmp($ID, $plugin_ocsinventoryng_ocsservers_id) * @internal param the $manufacturer supplier choice * @internal param the $type device type */ - static function searchForm($params) - { + static function searchForm($params) { global $CFG_GLPI; - + // Default values of parameters $p['itemtype'] = ''; $p['ip'] = ''; @@ -2356,7 +2327,7 @@ static function searchForm($params) echo ""; echo "\n"; } /* if ($p['change_import_mode'] && !$tolinked){ @@ -2680,28 +2650,27 @@ static function showSnmpDeviceToAdd($params) if (getItemForItemtype($tab["type"])) { $type = $tab["type"]; $options['name'] = "tolink_items[" . $tab["id"] . "]"; - $used = array(); + $used = []; $self = new self; - + if ($item = $self->getFromDBbyName($tab["type"], $tab["name"])) { $ido = (isset($item->fields['id'])) ? $item->fields['id'] : 0; - + if ($ido > 0) { $query = "SELECT * FROM `glpi_plugin_ocsinventoryng_snmpocslinks` WHERE `itemtype` = '".$tab["type"]."' AND `items_id` = '".$ido."' "; - + $result = $DB->query($query); if ($DB->numrows($result) > 0) { $used[] = $ido; } else { - + $options['value'] = $ido; } } } - - + $options['used'] = $used; $type::dropdown($options); @@ -2715,15 +2684,14 @@ static function showSnmpDeviceToAdd($params) $mynamei = "itemtype"; $myname = "tolink_items[" . $tab["id"] . "]"; - $rand = Dropdown::showItemTypes($mynamei, self::$snmptypes, array('rand' => $mtrand)); + $rand = Dropdown::showItemTypes($mynamei, self::$snmptypes, ['rand' => $mtrand]); - - $p = array('itemtype' => '__VALUE__', + $p = ['itemtype' => '__VALUE__', //'entity_restrict' => $entity_restrict, 'id' => $tab["id"], 'rand' => $rand, - 'myname' => $myname); -//print_r($p); + 'myname' => $myname]; + //print_r($p); Ajax::updateItemOnSelectEvent("dropdown_$mynamei$rand", "results_$mynamei$rand", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "\n"; echo "\n"; @@ -2787,8 +2755,7 @@ static function showSnmpDeviceToAdd($params) * @param $name * @return itemtype */ - function getFromDBbyName($itemtype, $name) - { + function getFromDBbyName($itemtype, $name) { $item = getItemForItemtype($itemtype); $item->getFromDBByQuery("WHERE `" . getTableForItemType($itemtype) . "`.`name` = '$name' "); return $item; @@ -2800,8 +2767,7 @@ function getFromDBbyName($itemtype, $name) * @param $start * @return bool|void */ - static function showSnmpDeviceToUpdate($plugin_ocsinventoryng_ocsservers_id, $check, $start) - { + static function showSnmpDeviceToUpdate($plugin_ocsinventoryng_ocsservers_id, $check, $start) { global $DB, $CFG_GLPI; PluginOcsinventoryngOcsServer::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); @@ -2821,25 +2787,25 @@ static function showSnmpDeviceToUpdate($plugin_ocsinventoryng_ocsservers_id, $ch return; } - $already_linked_ids = array(); + $already_linked_ids = []; while ($data = $DB->fetch_assoc($already_linked_result)) { $already_linked_ids [] = $data['ocsid']; } // Fetch linked items from ocs $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($plugin_ocsinventoryng_ocsservers_id); - $ocsResult = $ocsClient->getSnmp(array( + $ocsResult = $ocsClient->getSnmp([ 'ORDER' => 'LASTDATE', - 'FILTER' => array( + 'FILTER' => [ 'IDS' => $already_linked_ids, - ) - )); + ] + ]); if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP']) > 0) { // Get all ids of the returned items - $ocs_snmp_ids = array(); - $hardware = array(); + $ocs_snmp_ids = []; + $hardware = []; $snmps = array_slice($ocsResult['SNMP'], $start, $_SESSION['glpilist_limit']); foreach ($snmps as $snmp) { @@ -2865,14 +2831,14 @@ static function showSnmpDeviceToUpdate($plugin_ocsinventoryng_ocsservers_id, $ch $result = $DB->query($query); // Get all links between glpi and OCS - $already_linked = array(); + $already_linked = []; if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_assoc($result)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); $format = 'Y-m-d H:i:s'; -// $last_glpi_update = DateTime::createFromFormat($format, $data['last_update']); -// $last_ocs_inventory = DateTime::createFromFormat($format, $ocs_snmp_inv[$data['ocs_id']]); + // $last_glpi_update = DateTime::createFromFormat($format, $data['last_update']); + // $last_ocs_inventory = DateTime::createFromFormat($format, $ocs_snmp_inv[$data['ocs_id']]); //TODOSNMP comment for test //if ($last_ocs_inventory > $last_glpi_update) { $already_linked[$data['id']] = $data; @@ -2959,8 +2925,7 @@ static function showSnmpDeviceToUpdate($plugin_ocsinventoryng_ocsservers_id, $ch * @internal param int $glpi_computers_id : glpi computer id * @return bool|item */ - static function ocsSnmpLink($ocsid, $plugin_ocsinventoryng_ocsservers_id, $items_id, $itemtype) - { + static function ocsSnmpLink($ocsid, $plugin_ocsinventoryng_ocsservers_id, $items_id, $itemtype) { global $DB; PluginOcsinventoryngOcsServer::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); @@ -2994,8 +2959,7 @@ static function ocsSnmpLink($ocsid, $plugin_ocsinventoryng_ocsservers_id, $items * @internal param $computers_id * */ - static function linkSnmpDevice($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params) - { + static function linkSnmpDevice($ocsid, $plugin_ocsinventoryng_ocsservers_id, $params) { PluginOcsinventoryngOcsServer::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($plugin_ocsinventoryng_ocsservers_id); @@ -3051,8 +3015,7 @@ static function linkSnmpDevice($ocsid, $plugin_ocsinventoryng_ocsservers_id, $pa // Set OCS checksum to max value $ocsClient->setChecksum(PluginOcsinventoryngOcsClient::CHECKSUM_ALL, $ocsid); */ - if ( - //$ocs_id_change + if (//$ocs_id_change //|| $p['itemtype'] != -1 && $p['items_id'] > 0 && ($idlink = self::ocsSnmpLink($ocsid, $plugin_ocsinventoryng_ocsservers_id, $p['items_id'], $p['itemtype'])) @@ -3156,9 +3119,9 @@ static function linkSnmpDevice($ocsid, $plugin_ocsinventoryng_ocsservers_id, $pa } */ self::updateSnmp($idlink, $plugin_ocsinventoryng_ocsservers_id); - return array('status' => PluginOcsinventoryngOcsServer::SNMP_LINKED, + return ['status' => PluginOcsinventoryngOcsServer::SNMP_LINKED, //'entities_id' => $data['entities_id'], - ); + ]; } /* } else { @@ -3169,4 +3132,4 @@ static function linkSnmpDevice($ocsid, $plugin_ocsinventoryng_ocsservers_id, $pa } */ return false; } -} \ No newline at end of file +} diff --git a/inc/teamviewer.class.php b/inc/teamviewer.class.php index 4067f877..33509774 100644 --- a/inc/teamviewer.class.php +++ b/inc/teamviewer.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -48,7 +48,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -112,7 +112,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
"; - if ($result = $DB->request('glpi_plugin_ocsinventoryng_teamviewers', array('computers_id' => $ID))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_teamviewers', ['computers_id' => $ID])) { echo "
"; Html::showSimpleForm($target, 'force_ocssnmp_resynch', _sx('button', 'Force SNMP synchronization', 'ocsinventoryng'), - array('items_id' => $items_id, + ['items_id' => $items_id, 'itemtype' => $item->getType(), 'id' => $data["id"], - 'plugin_ocsinventoryng_ocsservers_id' => $data["plugin_ocsinventoryng_ocsservers_id"])); + 'plugin_ocsinventoryng_ocsservers_id' => $data["plugin_ocsinventoryng_ocsservers_id"]]); echo "
" . __('Cartridges informations', 'ocsinventoryng') . ""; echo __('By itemtype', 'ocsinventoryng'); echo ""; - Dropdown::showItemTypes("itemtype", self::$snmptypes, array('value' => $p['itemtype'])); + Dropdown::showItemTypes("itemtype", self::$snmptypes, ['value' => $p['itemtype']]); echo ""; @@ -2386,15 +2357,14 @@ static function searchForm($params) /** * @param $params */ - static function showSnmpDeviceToAdd($params) - { + static function showSnmpDeviceToAdd($params) { global $DB, $CFG_GLPI; // Default values of parameters - $p['link'] = array(); - $p['field'] = array(); - $p['contains'] = array(); - $p['searchtype'] = array(); + $p['link'] = []; + $p['field'] = []; + $p['contains'] = []; + $p['searchtype'] = []; $p['sort'] = '1'; $p['order'] = 'ASC'; $p['start'] = 0; @@ -2436,23 +2406,23 @@ static function showSnmpDeviceToAdd($params) FROM `glpi_plugin_ocsinventoryng_snmpocslinks` WHERE `plugin_ocsinventoryng_ocsservers_id` = '" . $plugin_ocsinventoryng_ocsservers_id . "'"; $result_glpi = $DB->query($query_glpi); - $already_linked = array(); + $already_linked = []; if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_array($result_glpi)) { $already_linked [] = $data["ocs_id"]; } } - $snmpOptions = array( + $snmpOptions = [ 'ORDER' => 'LASTDATE', - 'FILTER' => array( + 'FILTER' => [ 'EXCLUDE_IDS' => $already_linked - ), - 'DISPLAY' => array( + ], + 'DISPLAY' => [ 'CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS - ), + ], 'ORDER' => 'NAME' - ); + ]; //if ($cfg_ocs["tag_limit"] and $tag_limit = explode("$", trim($cfg_ocs["tag_limit"]))) { // $snmpOptions['FILTER']['TAGS'] = $tag_limit; @@ -2467,7 +2437,7 @@ static function showSnmpDeviceToAdd($params) if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP'])) { // Get all hardware from OCS DB - $hardware = array(); + $hardware = []; $snmp = array_slice($ocsResult['SNMP'], $start, $_SESSION['glpilist_limit']); foreach ($snmp as $data) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); @@ -2620,7 +2590,7 @@ static function showSnmpDeviceToAdd($params) } $type = "toimport_itemtype[" . $tab["id"] . "]"; - Dropdown::showItemTypes($type, self::$snmptypes, array('value' => $value)); + Dropdown::showItemTypes($type, self::$snmptypes, ['value' => $value]); echo "
"; $colspan = 2; echo "
" . self::getTypeName($result->numrows()) . @@ -149,7 +149,6 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "

"; - if ($result->numrows() != 0) { $restrict = $comp->getEntityID(); @@ -195,7 +194,6 @@ static function showForComputer(Computer $comp, $withtemplate = '') { static function showForSimpleForItem(Computer $comp, $withtemplate = '') { global $DB; - $ID = $comp->fields['id']; if (!$comp->getFromDB($ID) @@ -203,7 +201,7 @@ static function showForSimpleForItem(Computer $comp, $withtemplate = '') { return false; } - if ($result = $DB->request('glpi_plugin_ocsinventoryng_teamviewers', array('computers_id' => $ID))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_teamviewers', ['computers_id' => $ID])) { if ($result->numrows() != 0) { foreach ($result as $data) { @@ -256,9 +254,9 @@ static function generateLinkContents($link, CommonDBTM $item) { if (strstr($link, "[TWID]")) { $link = str_replace("[TWID]", $item->fields['twid'], $link); - return array($link); + return [$link]; } return parent::generateLinkContents($link, $item); } -} \ No newline at end of file +} diff --git a/inc/thread.class.php b/inc/thread.class.php index 37e4c349..38fce1d9 100644 --- a/inc/thread.class.php +++ b/inc/thread.class.php @@ -10,7 +10,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -40,21 +40,19 @@ class PluginOcsinventoryngThread extends CommonDBTM * @param int $nb * @return translated */ - static function getTypeName($nb = 0) - { + static function getTypeName($nb = 0) { return _n('OCSNG server', 'OCSNG servers', $nb, 'ocsinventoryng'); } /** * @param $processid **/ - function deleteThreadsByProcessId($processid) - { + function deleteThreadsByProcessId($processid) { global $DB; - foreach ($DB->request($this->getTable(), array('processid' => $processid)) as $data) { + foreach ($DB->request($this->getTable(), ['processid' => $processid]) as $data) { // Requires to clean details - $this->delete(array('id' => $data['id']), true); + $this->delete(['id' => $data['id']], true); } } @@ -62,16 +60,14 @@ function deleteThreadsByProcessId($processid) /** * */ - function cleanDBonPurge() - { + function cleanDBonPurge() { PluginOcsinventoryngDetail::deleteThreadDetailsByProcessID($this->fields['id']); } - function title() - { + function title() { - $buttons = array(); + $buttons = []; $title = ""; $buttons["thread.php"] = __('Back to processes list', 'ocsinventoryng'); Html::displayTitle("", "", $title, $buttons); @@ -83,8 +79,7 @@ function title() * @param $pid * @internal param array $options */ - function showForm($pid) - { + function showForm($pid) { global $DB; $config = new PluginOcsinventoryngConfig(); @@ -203,8 +198,7 @@ function showForm($pid) * * @return int */ - function getProcessStatus($pid) - { + function getProcessStatus($pid) { global $DB; $sql = "SELECT `status` @@ -232,8 +226,7 @@ function getProcessStatus($pid) * * @return bool */ - function deleteOldProcesses($delete_frequency) - { + function deleteOldProcesses($delete_frequency) { global $DB; $nbdel = 0; @@ -258,8 +251,7 @@ function deleteOldProcesses($delete_frequency) * @param $target * @param int $plugin_ocsinventoryng_ocsservers_id */ - function showProcesses($target, $plugin_ocsinventoryng_ocsservers_id = 0) - { + function showProcesses($target, $plugin_ocsinventoryng_ocsservers_id = 0) { global $DB, $CFG_GLPI; $canedit = Session::haveRight("plugin_ocsinventoryng", UPDATE); @@ -422,7 +414,7 @@ function showProcesses($target, $plugin_ocsinventoryng_ocsservers_id = 0) if ($canedit) { Html::openArrowMassives("processes"); - Html::closeArrowMassives(array("delete_processes" => _x('button', 'Delete permanently'))); + Html::closeArrowMassives(["delete_processes" => _x('button', 'Delete permanently')]); } Html::closeForm(); } @@ -440,8 +432,7 @@ function showProcesses($target, $plugin_ocsinventoryng_ocsservers_id = 0) * @param $time **/ function showshowStat($duree, &$imported, &$synchronized, &$linked, &$failed, &$notupdated, - &$notunique, &$linkedrefused, &$time) - { + &$notunique, &$linkedrefused, &$time) { $title = __('Statistics'); if ($duree < 9999) { @@ -507,8 +498,7 @@ function showshowStat($duree, &$imported, &$synchronized, &$linked, &$failed, &$ /** * @return bool */ - function showErrorLog() - { + function showErrorLog() { $fic = GLPI_LOG_DIR . "/ocsng_fullsync.log"; if (!is_file($fic)) { @@ -518,7 +508,7 @@ function showErrorLog() $size = filesize($fic); if ($size > 20000) { - $logfile = file_get_contents($fic, 0, NULL, $size - 20000, 20000); + $logfile = file_get_contents($fic, 0, null, $size - 20000, 20000); $events = explode("\n", $logfile); // Remove fist partial event array_shift($events); @@ -563,8 +553,7 @@ function showErrorLog() /** * @return bool */ - function lognothing() - { + function lognothing() { echo "
"; echo ""; @@ -579,8 +568,7 @@ function lognothing() /** * @param $status **/ - function displayProcessStatusIcon($status) - { + function displayProcessStatusIcon($status) { global $CFG_GLPI; switch ($status) { @@ -604,15 +592,14 @@ function displayProcessStatusIcon($status) * * @return array */ - static function cronInfo($name) - { + static function cronInfo($name) { switch ($name) { case "CleanOldThreads" : - return array('description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Clean processes', 'ocsinventoryng'), - 'parameter' => __('Delete processes after', 'ocsinventoryng')); + return ['description' => __('OCSNG', 'ocsinventoryng') . " - " . __('Clean processes', 'ocsinventoryng'), + 'parameter' => __('Delete processes after', 'ocsinventoryng')]; } - return array(); + return []; } @@ -624,8 +611,7 @@ static function cronInfo($name) * @return integer : 0 (nothing to do) * >0 (endded) **/ - static function cronCleanOldThreads($task) - { + static function cronCleanOldThreads($task) { $thread = new self(); $nb = $thread->deleteOldProcesses($task->fields['param']); @@ -642,8 +628,7 @@ static function cronCleanOldThreads($task) * * @return string **/ - static function timestampToStringShort($time) - { + static function timestampToStringShort($time) { $sign = ''; if ($time < 0) { @@ -663,4 +648,4 @@ static function timestampToStringShort($time) } -} \ No newline at end of file +} diff --git a/inc/winupdate.class.php b/inc/winupdate.class.php index 8fdf1ac9..b52d610a 100644 --- a/inc/winupdate.class.php +++ b/inc/winupdate.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -111,7 +111,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
"; - if ($result = $DB->request('glpi_plugin_ocsinventoryng_winupdates', array('computers_id' => $ID))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_winupdates', ['computers_id' => $ID])) { echo "
"; $colspan = 5; echo "
" . self::getTypeName($result->numrows()) . @@ -183,4 +183,4 @@ static function getAuoptionsName($value) { return $value; } } -} \ No newline at end of file +} diff --git a/inc/winuser.class.php b/inc/winuser.class.php index 62222aa3..e074dd0f 100644 --- a/inc/winuser.class.php +++ b/inc/winuser.class.php @@ -9,7 +9,7 @@ ------------------------------------------------------------------------- LICENSE - + This file is part of ocsinventoryng. ocsinventoryng is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ static function getTypeName($nb = 0) { function cleanDBonPurge() { $self = new self(); - $self->deleteByCriteria(array('computers_id' => $this->fields['id'])); + $self->deleteByCriteria(['computers_id' => $this->fields['id']]); } @@ -111,7 +111,7 @@ static function showForComputer(Computer $comp, $withtemplate = '') { echo "
"; - if ($result = $DB->request('glpi_plugin_ocsinventoryng_winusers', array('computers_id' => $ID, 'ORDER' => 'type'))) { + if ($result = $DB->request('glpi_plugin_ocsinventoryng_winusers', ['computers_id' => $ID, 'ORDER' => 'type'])) { echo ""; $colspan = 5; echo "
" . self::getTypeName($result->numrows()) . @@ -152,4 +152,4 @@ static function showForComputer(Computer $comp, $withtemplate = '') { } echo ""; } -} \ No newline at end of file +} diff --git a/setup.php b/setup.php index ed9eabf7..fe8de0ee 100644 --- a/setup.php +++ b/setup.php @@ -40,51 +40,51 @@ function plugin_init_ocsinventoryng() { global $PLUGIN_HOOKS, $CFG_GLPI, $DB; $PLUGIN_HOOKS['csrf_compliant']['ocsinventoryng'] = true; - $PLUGIN_HOOKS['use_rules']['ocsinventoryng'] = array('RuleImportEntity', 'RuleImportComputer'); + $PLUGIN_HOOKS['use_rules']['ocsinventoryng'] = ['RuleImportEntity', 'RuleImportComputer']; - $PLUGIN_HOOKS['change_profile']['ocsinventoryng'] = array('PluginOcsinventoryngProfile', - 'initProfile'); + $PLUGIN_HOOKS['change_profile']['ocsinventoryng'] = ['PluginOcsinventoryngProfile', + 'initProfile']; - $PLUGIN_HOOKS['import_item']['ocsinventoryng'] = array('Computer'); + $PLUGIN_HOOKS['import_item']['ocsinventoryng'] = ['Computer']; $PLUGIN_HOOKS['autoinventory_information']['ocsinventoryng'] - = array('Computer' => array('PluginOcsinventoryngOcslink', 'showSimpleForItem'), - 'ComputerDisk' => array('PluginOcsinventoryngOcslink', 'showSimpleForChild'), - 'ComputerVirtualMachine' => array('PluginOcsinventoryngOcslink', 'showSimpleForChild'), - 'Printer' => array('PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem'), - 'NetworkEquipment' => array('PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem'), - 'Peripheral' => array('PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem'), - 'Phone' => array('PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem')); + = ['Computer' => ['PluginOcsinventoryngOcslink', 'showSimpleForItem'], + 'ComputerDisk' => ['PluginOcsinventoryngOcslink', 'showSimpleForChild'], + 'ComputerVirtualMachine' => ['PluginOcsinventoryngOcslink', 'showSimpleForChild'], + 'Printer' => ['PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem'], + 'NetworkEquipment' => ['PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem'], + 'Peripheral' => ['PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem'], + 'Phone' => ['PluginOcsinventoryngSnmpOcslink', 'showSimpleForItem']]; //Locks management $PLUGIN_HOOKS['display_locked_fields']['ocsinventoryng'] = 'plugin_ocsinventoryng_showLocksForItem'; $PLUGIN_HOOKS['unlock_fields']['ocsinventoryng'] = 'plugin_ocsinventoryng_unlockFields'; Plugin::registerClass('PluginOcsinventoryngOcslink', - array('forwardentityfrom' => 'Computer', - 'addtabon' => 'Computer')); + ['forwardentityfrom' => 'Computer', + 'addtabon' => 'Computer']); Plugin::registerClass('PluginOcsinventoryngRegistryKey', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); if ($DB->tableExists('glpi_plugin_ocsinventoryng_winupdates')) { Plugin::registerClass('PluginOcsinventoryngWinupdate', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); } if ($DB->tableExists('glpi_plugin_ocsinventoryng_proxysettings')) { Plugin::registerClass('PluginOcsinventoryngProxysetting', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); } if ($DB->tableExists('glpi_plugin_ocsinventoryng_winusers')) { Plugin::registerClass('PluginOcsinventoryngWinuser', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); } if ($DB->tableExists('glpi_plugin_ocsinventoryng_teamviewers')) { Plugin::registerClass('PluginOcsinventoryngTeamviewer', - array('addtabon' => 'Computer', - 'link_types' => true)); + ['addtabon' => 'Computer', + 'link_types' => true]); if (class_exists('PluginOcsinventoryngTeamviewer')) { Link::registerTag(PluginOcsinventoryngTeamviewer::$tags); @@ -97,45 +97,45 @@ function plugin_init_ocsinventoryng() { if ($DB->tableExists('glpi_plugin_ocsinventoryng_networkshares')) { Plugin::registerClass('PluginOcsinventoryngNetworkshare', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); } if ($DB->tableExists('glpi_plugin_ocsinventoryng_runningprocesses')) { Plugin::registerClass('PluginOcsinventoryngRunningprocess', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); } if ($DB->tableExists('glpi_plugin_ocsinventoryng_services')) { Plugin::registerClass('PluginOcsinventoryngService', - array('addtabon' => 'Computer')); + ['addtabon' => 'Computer']); } Plugin::registerClass('PluginOcsinventoryngOcsServer', - array('massiveaction_noupdate_types' => true, - 'systeminformations_types' => true)); + ['massiveaction_noupdate_types' => true, + 'systeminformations_types' => true]); Plugin::registerClass('PluginOcsinventoryngProfile', - array('addtabon' => 'Profile')); + ['addtabon' => 'Profile']); Plugin::registerClass('PluginOcsinventoryngNotimportedcomputer', - array('massiveaction_noupdate_types' => true, + ['massiveaction_noupdate_types' => true, 'massiveaction_nodelete_types' => true, - 'notificationtemplates_types' => true)); + 'notificationtemplates_types' => true]); Plugin::registerClass('PluginOcsinventoryngRuleImportEntity', - array('massiveaction_noupdate_types' => true, + ['massiveaction_noupdate_types' => true, 'massiveaction_nodelete_types' => true, - 'notificationtemplates_types' => true)); + 'notificationtemplates_types' => true]); Plugin::registerClass('PluginOcsinventoryngDetail', - array('massiveaction_noupdate_types' => true, - 'massiveaction_nodelete_types' => true)); + ['massiveaction_noupdate_types' => true, + 'massiveaction_nodelete_types' => true]); Plugin::registerClass('PluginOcsinventoryngNetworkPort', - array('networkport_instantiations' => true)); + ['networkport_instantiations' => true]); Plugin::registerClass('PluginOcsinventoryngSnmpOcslink', - array('addtabon' => array('Computer', 'Printer', 'NetworkEquipment', 'Peripheral', 'Phone'))); + ['addtabon' => ['Computer', 'Printer', 'NetworkEquipment', 'Peripheral', 'Phone']]); // transfer $PLUGIN_HOOKS['item_transfer']['ocsinventoryng'] = "plugin_ocsinventoryng_item_transfer"; @@ -147,7 +147,7 @@ function plugin_init_ocsinventoryng() { // Display a menu entry ? if (Session::haveRight("plugin_ocsinventoryng", READ)) { - $PLUGIN_HOOKS['menu_toadd']['ocsinventoryng'] = array('tools' => 'PluginOcsinventoryngMenu'); + $PLUGIN_HOOKS['menu_toadd']['ocsinventoryng'] = ['tools' => 'PluginOcsinventoryngMenu']; } if (Session::haveRight("plugin_ocsinventoryng", UPDATE) @@ -164,11 +164,11 @@ function plugin_init_ocsinventoryng() { $PLUGIN_HOOKS['post_init']['ocsinventoryng'] = 'plugin_ocsinventoryng_postinit'; if (class_exists('PluginMydashboardMenu')) { - $PLUGIN_HOOKS['mydashboard']['ocsinventoryng'] = array("PluginOcsinventoryngDashboard"); + $PLUGIN_HOOKS['mydashboard']['ocsinventoryng'] = ["PluginOcsinventoryngDashboard"]; } } - $CFG_GLPI['ocsinventoryng_devices_index'] = array(1 => 'Item_DeviceMotherboard', + $CFG_GLPI['ocsinventoryng_devices_index'] = [1 => 'Item_DeviceMotherboard', 2 => 'Item_DeviceProcessor', 3 => 'Item_DeviceMemory', 4 => 'Item_DeviceHardDrive', @@ -180,7 +180,7 @@ function plugin_init_ocsinventoryng() { 10 => 'Item_DevicePci', 11 => 'Item_DeviceCase', 12 => 'Item_DevicePowerSupply', - 13 => 'Item_DeviceFirmware'); + 13 => 'Item_DeviceFirmware']; } @@ -189,12 +189,12 @@ function plugin_init_ocsinventoryng() { **/ function plugin_version_ocsinventoryng() { - return array('name' => "OCS Inventory NG", + return ['name' => "OCS Inventory NG", 'version' => '1.4.4', 'author' => 'Gilles Dubois, Remi Collet, Nelly Mahu-Lasson, David Durieux, Xavier Caillaud, Walid Nouh, Arthur Jaouen', 'license' => 'GPLv2+', 'homepage' => 'https://github.com/pluginsGLPI/ocsinventoryng', - 'minGlpiVersion' => '9.2'); + 'minGlpiVersion' => '9.2']; } @@ -218,4 +218,4 @@ function plugin_ocsinventoryng_check_prerequisites() { */ function plugin_ocsinventoryng_check_config() { return true; -} \ No newline at end of file +}