/** * Function to uninstall an object * * @param $computers_id the computer's ID in GLPI * * @return nothing **/ static function deleteFusionInventoryLink($itemtype, $items_id) { if (function_exists('plugin_pre_item_purge_fusioninventory')) { $item = new $itemtype(); $item->getFromDB($items_id); $agent = new PluginFusioninventoryAgent(); $agents = $agent->getAgentsFromComputers(array($items_id)); // clean item associated to agents plugin_pre_item_purge_fusioninventory($item); if ($itemtype == 'Computer') { // remove agent(s) foreach ($agents as $current_agent) { $agent->deleteByCriteria(array('id' => $current_agent['id']), true); } // remove licences $pfComputerLicenseInfo = new PluginFusioninventoryComputerLicenseInfo(); $pfComputerLicenseInfo->deleteByCriteria(array('computers_id' => $items_id)); // remove batteries $pfInventoryComputerBatteries = new PluginFusioninventoryInventoryComputerBatteries(); $pfInventoryComputerBatteries->deleteByCriteria(array('computers_id' => $items_id)); // Delete links between two computerstorages $pfInventoryComputerStorageStorageStorage = new PluginFusioninventoryInventoryComputerStorage_Storage(); $tab_ids = $pfInventoryComputerStorageStorageStorage->getOpposites($items_id); if (!empty($tab_ids)) { //because getOpposites can return 0 foreach ($tab_ids as $inventorycomputerstorages_id) { $storage->deleteByCriteria(array('plugin_fusioninventory_inventorycomputerstorages_id_1' => $inventorycomputerstorages_id)); $storage->deleteByCriteria(array('plugin_fusioninventory_inventorycomputerstorages_id_2' => $inventorycomputerstorages_id)); } } // ** Delete computerstorages ** $pfInventoryComputerStorage = new PluginFusioninventoryInventoryComputerStorage(); $pfInventoryComputerStorage->deleteByCriteria(array('computers_id' => $items_id)); } } }
function getStorageLinks($a_link, $id, $lev, $a_position) { $pficStorage_Storage = new PluginFusioninventoryInventoryComputerStorage_Storage(); $a_par = $pficStorage_Storage->getParent($id, $lev); foreach ($a_par as $parid => $parlev) { for ($j = 0; $j < count($a_position[$parid]); $j++) { $a_link[] = $parid . "-" . $j; } $a_link = $this->getStorageLinks($a_link, $parid, $parlev, $a_position); } return $a_link; }