/** * Import data * * @param $arrayinventory array to import * * @return TRUE (import ok) / FALSE (import ko) **/ function import($arrayinventory) { $pfAgent = new PluginFusioninventoryAgent(); PluginFusioninventoryToolbox::logIfExtradebug('pluginFusioninventory-communication', 'Function import().'); $this->message = $arrayinventory; $errors = ''; $xmltag = $this->message['QUERY']; if ($xmltag == "NETDISCOVERY") { $xmltag = "NETWORKDISCOVERY"; } if ($xmltag == "SNMPQUERY" or $xmltag == "SNMPINVENTORY") { $xmltag = "NETWORKINVENTORY"; } if (!isset($_SESSION['plugin_fusioninventory_agents_id'])) { $agent = $pfAgent->InfosByKey($this->message['DEVICEID']); } else { $agent = array('id' => $_SESSION['plugin_fusioninventory_agents_id']); } if ($xmltag == "PROLOG") { return FALSE; } if (isset($this->message['CONTENT']['MODULEVERSION'])) { $pfAgent->setAgentVersions($agent['id'], $xmltag, $this->message['CONTENT']['MODULEVERSION']); } else { if (isset($this->message['CONTENT']['VERSIONCLIENT'])) { $version = str_replace("FusionInventory-Agent_", "", $this->message['CONTENT']['VERSIONCLIENT']); $pfAgent->setAgentVersions($agent['id'], $xmltag, $version); } } if (isset($this->message->CONTENT->MODULEVERSION)) { $pfAgent->setAgentVersions($agent['id'], $xmltag, (string) $this->message->CONTENT->MODULEVERSION); } else { if (isset($this->message->CONTENT->VERSIONCLIENT)) { $version = str_replace("FusionInventory-Agent_", "", (string) $this->message->CONTENT->VERSIONCLIENT); $pfAgent->setAgentVersions($agent['id'], $xmltag, $version); } } if (isset($_SESSION['glpi_plugin_fusioninventory']['xmltags']["{$xmltag}"])) { $moduleClass = $_SESSION['glpi_plugin_fusioninventory']['xmltags']["{$xmltag}"]; $moduleCommunication = new $moduleClass(); $errors .= $moduleCommunication->import($this->message['DEVICEID'], $this->message['CONTENT'], $arrayinventory); } else { $errors .= __('Unattended element in', 'fusioninventory') . ' QUERY : *' . $xmltag . "*\n"; } $result = TRUE; // TODO manage this error ( = delete it) if ($errors != '') { echo $errors; if (isset($_SESSION['glpi_plugin_fusioninventory_processnumber'])) { $result = TRUE; } else { // It's PROLOG $result = FALSE; } } return $result; }