/** * Import data * *@param $p_xml XML code to import *@param &$p_errors errors string to be alimented if import ko *@return true (import ok) / false (import ko) **/ function import($p_xml, &$p_errors = '') { global $LANG; $this->addLog('Function import().'); // TODO : gérer l'encodage, la version // Do not manage <REQUEST> element (always the same) $this->setXML($p_xml); $errors = ''; if (isset($this->sxml->CONTENT->PROCESSNUMBER)) { $_SESSION['glpi_plugin_fusioninventory_processnumber'] = $this->sxml->CONTENT->PROCESSNUMBER; } switch ($this->sxml->QUERY) { case 'SNMPQUERY': $errors .= $this->importContent($this->sxml->CONTENT); break; case 'NETDISCOVERY': $pti = new PluginFusioninventoryImportExport(); $errors .= $pti->import_netdiscovery($this->sxml->CONTENT, $this->sxml->DEVICEID); break; case 'INVENTORY': $this->sendInventoryToOcsServer($p_xml); break; case 'QUERY': break; default: $errors .= $LANG['plugin_fusioninventory']["errors"][22] . ' QUERY : *' . $this->sxml->QUERY . "*\n"; } $result = true; if ($errors != '') { if (isset($_SESSION['glpi_plugin_fusioninventory_processnumber'])) { $result = true; $ptap = new PluginFusioninventoryAgentsProcesses(); $ptap->updateProcess($_SESSION['glpi_plugin_fusioninventory_processnumber'], array('comments' => $errors)); } else { // It's PROLOG $result = false; } } return $result; }