/** * Load an existing networking switch * *@return nothing **/ function load($p_id = '') { global $DB; parent::load($p_id); $this->ifaddrs = $this->getIfaddrsDB(); $this->ports = $this->getPortsDB(); $query = "SELECT `ID`\n FROM `glpi_plugin_fusioninventory_networking`\n WHERE `FK_networking` = '" . $this->getValue('ID') . "';"; if ($result = $DB->query($query)) { if ($DB->numrows($result) != 0) { $fusioninventory = $DB->fetch_assoc($result); $this->oFusionInventory_networking->load($fusioninventory['ID']); $this->ptcdLinkedObjects[] = $this->oFusionInventory_networking; } } }
/** * Get cartridges * *@return Array of cartridges **/ private function getCartridgesDB() { global $DB; $ptc = new PluginFusioninventoryCommonDBTM('glpi_plugin_fusioninventory_printers_cartridges'); $query = "SELECT `ID`\n FROM `glpi_plugin_fusioninventory_printers_cartridges`\n WHERE `FK_printers` = '" . $this->getValue('ID') . "';"; $cartridgesIds = array(); if ($result = $DB->query($query)) { if ($DB->numrows($result) != 0) { while ($cartridge = $DB->fetch_assoc($result)) { $ptc->load($cartridge['ID']); $cartridgesIds[] = clone $ptc; } } } return $cartridgesIds; }
/** * Load an optionnaly existing port * *@return nothing **/ function load($p_id = '') { global $DB; parent::load($p_id); if (is_numeric($p_id)) { // port exists $query = "SELECT `ID`\n FROM `glpi_plugin_fusioninventory_networking_ports`\n WHERE `FK_networking_ports` = '" . $p_id . "';"; if ($result = $DB->query($query)) { if ($DB->numrows($result) != 0) { $portFusionInventory = $DB->fetch_assoc($result); $this->fusioninventory_networking_ports_ID = $portFusionInventory['ID']; $this->oFusionInventory_networking_ports->load($this->fusioninventory_networking_ports_ID); $this->ptcdLinkedObjects[] = $this->oFusionInventory_networking_ports; } else { // $this->fusioninventory_networking_ports_ID = NULL; // $this->oFusionInventory_networking_ports->load(); // $this->ptcdLinkedObjects[]=$this->oFusionInventory_networking_ports; $this->fusioninventory_networking_ports_ID = $this->addDBFusionInventory(); $this->oFusionInventory_networking_ports->load($this->fusioninventory_networking_ports_ID); $this->ptcdLinkedObjects[] = $this->oFusionInventory_networking_ports; } } } else { $this->fusioninventory_networking_ports_ID = NULL; $this->oFusionInventory_networking_ports->load(); $this->ptcdLinkedObjects[] = $this->oFusionInventory_networking_ports; } }
/** * Import CARTRIDGES *@param $p_cartridges CARTRIDGES code to import * *@return errors string to be alimented if import ko / '' if ok **/ function importCartridges($p_cartridges) { global $LANG; $errors = ''; foreach ($p_cartridges->children() as $name => $child) { switch ($name) { case 'TONERBLACK': case 'TONERBLACK2': case 'TONERCYAN': case 'TONERMAGENTA': case 'TONERYELLOW': case 'WASTETONER': case 'CARTRIDGEBLACK': case 'CARTRIDGEBLACKPHOTO': case 'CARTRIDGECYAN': case 'CARTRIDGECYANLIGHT': case 'CARTRIDGEMAGENTA': case 'CARTRIDGEMAGENTALIGHT': case 'CARTRIDGEYELLOW': case 'MAINTENANCEKIT': case 'DRUMBLACK': case 'DRUMCYAN': case 'DRUMMAGENTA': case 'DRUMYELLOW': $ptc = new PluginFusioninventoryCommonDBTM("glpi_plugin_fusioninventory_printers_cartridges"); $cartridgeIndex = $this->ptd->getCartridgeIndex($name); if (is_int($cartridgeIndex)) { $oldCartridge = $this->ptd->getCartridge($cartridgeIndex); //TODO ??? $ptc->load($oldCartridge->getValue('ID')); } else { $ptc->addCommon(TRUE); //TODO ??? $ptc->setValue('FK_printers', $this->deviceId); } $ptc->setValue('object_name', $name); $ptc->setValue('state', $child, $ptc, 0); $this->ptd->addCartridge($ptc, $cartridgeIndex); break; default: $errors .= $LANG['plugin_fusioninventory']["errors"][22] . ' CARTRIDGES : ' . $name . "\n"; } } return $errors; }