$_SESSION["change_import_mode"] = false; } //Changing the import mode if (isset($_POST["change_import_mode"])) { if ('id' == "false") { $_SESSION["change_import_mode"] = false; } else { $_SESSION["change_import_mode"] = true; } } if (isset($_SESSION["ocs_link"])) { if ($count = count($_SESSION["ocs_link"])) { $percent = min(100, round(100 * ($_SESSION["ocs_link_count"] - $count) / $_SESSION["ocs_link_count"], 0)); Html::displayProgressBar(400, $percent); $key = array_pop($_SESSION["ocs_link"]); PluginOcsinventoryngOcsServer::linkComputer($key["ocsid"], $_SESSION["plugin_ocsinventoryng_ocsservers_id"], $key["computers_id"]); Html::redirect($_SERVER['PHP_SELF']); } else { Html::displayProgressBar(400, 100); unset($_SESSION["ocs_link"]); echo "<div class='center b'>" . __('Successful importation') . "<br>"; echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . __('Back') . "</a></div>"; } } if (!isset($_POST["import_ok"])) { if (!isset($_GET['check'])) { $_GET['check'] = 'all'; } if (!isset($_GET['start'])) { $_GET['start'] = 0; }
/** * @param $params array **/ static function linkComputer($params = array()) { if (isset($params['id'])) { $notimported = new PluginOcsinventoryngNotimportedcomputer(); $notimported->getFromDB($params['id']); $changes = self::getOcsComputerInfos($notimported->fields); if (PluginOcsinventoryngOcsServer::linkComputer($notimported->fields['ocsid'], $notimported->fields['plugin_ocsinventoryng_ocsservers_id'], $params['computers_id'])) { $notimported->delete(array('id' => $params['id'])); //If serial has been changed in order to import computer if (in_array('serial', $changes)) { PluginOcsinventoryngOcsServer::mergeOcsArray($params['id'], array('serial'), "computer_update"); } } } }