/**
  * Function to update NetworkEquipment
  *
  * @param array $a_inventory data fron agent inventory
  * @param id $items_id id of the networkequipment
  *
  * @return nothing
  */
 function updateNetworkEquipment($a_inventory, $items_id)
 {
     global $DB;
     $networkEquipment = new NetworkEquipment();
     $pfNetworkEquipment = new PluginFusioninventoryNetworkEquipment();
     $networkEquipment->getFromDB($items_id);
     if (!isset($_SESSION['glpiactiveentities_string'])) {
         $_SESSION['glpiactiveentities_string'] = $networkEquipment->fields['entities_id'];
     }
     if (!isset($_SESSION['glpiactiveentities'])) {
         $_SESSION['glpiactiveentities'] = array($networkEquipment->fields['entities_id']);
     }
     if (!isset($_SESSION['glpiactive_entity'])) {
         $_SESSION['glpiactive_entity'] = $networkEquipment->fields['entities_id'];
     }
     // * NetworkEquipment
     $db_networkequipment = $networkEquipment->fields;
     $a_lockable = PluginFusioninventoryLock::getLockFields('glpi_networkequipments', $items_id);
     $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['NetworkEquipment'], $db_networkequipment, $a_lockable);
     $a_inventory['NetworkEquipment'] = $a_ret[0];
     $mac = $a_inventory['NetworkEquipment']['mac'];
     unset($a_inventory['NetworkEquipment']['mac']);
     $input = $a_inventory['NetworkEquipment'];
     $input['id'] = $items_id;
     $networkEquipment->update($input);
     $this->internalPorts($a_inventory['internalport'], $items_id, $mac, 'Internal');
     // * NetworkEquipment fusion (ext)
     $db_networkequipment = array();
     $query = "SELECT *\n            FROM `" . getTableForItemType("PluginFusioninventoryNetworkEquipment") . "`\n            WHERE `networkequipments_id` = '{$items_id}'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_assoc($result)) {
         foreach ($data as $key => $value) {
             $db_networkequipment[$key] = Toolbox::addslashes_deep($value);
         }
     }
     if (count($db_networkequipment) == '0') {
         // Add
         $a_inventory['PluginFusioninventoryNetworkEquipment']['networkequipments_id'] = $items_id;
         $pfNetworkEquipment->add($a_inventory['PluginFusioninventoryNetworkEquipment']);
     } else {
         // Update
         $idtmp = $db_networkequipment['id'];
         unset($db_networkequipment['id']);
         unset($db_networkequipment['networkequipments_id']);
         unset($db_networkequipment['plugin_fusioninventory_configsecurities_id']);
         $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['PluginFusioninventoryNetworkEquipment'], $db_networkequipment);
         $a_inventory['PluginFusioninventoryNetworkEquipment'] = $a_ret[0];
         $input = $a_inventory['PluginFusioninventoryNetworkEquipment'];
         $input['id'] = $idtmp;
         $pfNetworkEquipment->update($input);
     }
     // * Ports
     $this->importPorts($a_inventory, $items_id);
 }
예제 #2
0
        $netdevice->check($_POST["id"], DELETE);
        $netdevice->delete($_POST);
        Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $netdevice->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $netdevice->check($_POST["id"], DELETE);
            $netdevice->restore($_POST);
            Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $netdevice->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $netdevice->check($_POST["id"], PURGE);
                $netdevice->delete($_POST, 1);
                Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $netdevice->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $netdevice->check($_POST["id"], UPDATE);
                    $netdevice->update($_POST);
                    Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    Html::back();
                } else {
                    Html::header(NetworkEquipment::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "networkequipment");
                    $netdevice->display(array('id' => $_GET["id"], 'withtemplate' => $_GET["withtemplate"]));
                    Html::footer();
                }
            }
        }
    }
}