/** * Get ips * *@return Array of ips instances **/ private function getIfaddrsDB() { global $DB; $pti = new PluginFusioninventoryIfaddr(); $query = "SELECT `ID`\n FROM `glpi_plugin_fusioninventory_networking_ifaddr`\n WHERE `FK_networking` = '" . $this->getValue('ID') . "';"; $ifaddrsIds = array(); if ($result = $DB->query($query)) { if ($DB->numrows($result) != 0) { while ($ifaddr = $DB->fetch_assoc($result)) { $pti->load($ifaddr['ID']); $ifaddrsIds[] = clone $pti; } } } return $ifaddrsIds; }
/** * Import IPS *@param $p_ips IPS code to import * *@return errors string to be alimented if import ko / '' if ok **/ function importIps($p_ips) { global $LANG; $errors = ''; $pti = new PluginFusioninventoryIfaddr(); foreach ($p_ips->children() as $name => $child) { switch ($child->getName()) { case 'IP': $ifaddrIndex = $this->ptd->getIfaddrIndex($child); if (is_int($ifaddrIndex)) { $oldIfaddr = $this->ptd->getIfaddr($ifaddrIndex); $pti->load($oldIfaddr->getValue('ID')); } else { $pti->load(); } $pti->setValue('ifaddr', $child); $this->ptd->addIfaddr(clone $pti, $ifaddrIndex); break; default: $errors .= $LANG['plugin_fusioninventory']["errors"][22] . ' IPS : ' . $child->getName() . "\n"; } } $this->ptd->saveIfaddrs(); return $errors; }