/** * Update Admin Info retrieve config * * @param $tab data array **/ function updateAdminInfo($tab) { if (isset($tab["import_location"]) || isset($tab["import_otherserial"]) || isset($tab["import_group"]) || isset($tab["import_network"]) || isset($tab["import_contact_num"])) { $adm = new PluginOcsinventoryngOcsAdminInfosLink(); $adm->cleanForOcsServer($tab["id"]); if (isset($tab["import_location"])) { if ($tab["import_location"] != "") { $adm = new PluginOcsinventoryngOcsAdminInfosLink(); $adm->fields["plugin_ocsinventoryng_ocsservers_id"] = $tab["id"]; $adm->fields["glpi_column"] = "locations_id"; $adm->fields["ocs_column"] = $tab["import_location"]; $isNewAdm = $adm->addToDB(); } } if (isset($tab["import_otherserial"])) { if ($tab["import_otherserial"] != "") { $adm = new PluginOcsinventoryngOcsAdminInfosLink(); $adm->fields["plugin_ocsinventoryng_ocsservers_id"] = $tab["id"]; $adm->fields["glpi_column"] = "otherserial"; $adm->fields["ocs_column"] = $tab["import_otherserial"]; $isNewAdm = $adm->addToDB(); } } if (isset($tab["import_group"])) { if ($tab["import_group"] != "") { $adm = new PluginOcsinventoryngOcsAdminInfosLink(); $adm->fields["plugin_ocsinventoryng_ocsservers_id"] = $tab["id"]; $adm->fields["glpi_column"] = "groups_id"; $adm->fields["ocs_column"] = $tab["import_group"]; $isNewAdm = $adm->addToDB(); } } if (isset($tab["import_network"])) { if ($tab["import_network"] != "") { $adm = new PluginOcsinventoryngOcsAdminInfosLink(); $adm->fields["plugin_ocsinventoryng_ocsservers_id"] = $tab["id"]; $adm->fields["glpi_column"] = "networks_id"; $adm->fields["ocs_column"] = $tab["import_network"]; $isNewAdm = $adm->addToDB(); } } if (isset($tab["import_contact_num"])) { if ($tab["import_contact_num"] != "") { $adm = new PluginOcsinventoryngOcsAdminInfosLink(); $adm->fields["plugin_ocsinventoryng_ocsservers_id"] = $tab["id"]; $adm->fields["glpi_column"] = "contact_num"; $adm->fields["ocs_column"] = $tab["import_contact_num"]; $isNewAdm = $adm->addToDB(); } } } }
/** * Update the administrative informations * * This function erase old data and import the new ones about administrative informations * * @param $computers_id integer : glpi computer id. * @param $plugin_ocsinventoryng_ocsservers_id integer : ocs server id * @param $computer_updates array : already updated fields of the computer * @param $ocsComputer * @return Nothing . * @internal param int $ocsid : ocs computer id (ID). * @internal param array $cfg_ocs : configuration ocs of the server * @internal param int $entity : entity of the computer * @internal param bool $dohistory : log changes? * */ static function updateAdministrativeInfoUseDate($computers_id, $plugin_ocsinventoryng_ocsservers_id, $computer_updates, $ocsComputer) { global $DB; self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); //check link between ocs and glpi column $queryListUpdate = "SELECT *\n FROM `glpi_plugin_ocsinventoryng_ocsadmininfoslinks`\n WHERE `plugin_ocsinventoryng_ocsservers_id` = '{$plugin_ocsinventoryng_ocsservers_id}' "; $result = $DB->query($queryListUpdate); if ($DB->numrows($result) > 0) { if (isset($ocsComputer['HARDWARE'])) { $metas = $ocsComputer['HARDWARE']; foreach ($metas as $key => $meta) { //update data while ($links_glpi_ocs = $DB->fetch_array($result)) { //get info from ocs $ocs_column = $links_glpi_ocs['ocs_column']; $glpi_column = $links_glpi_ocs['glpi_column']; if ($computer_updates && array_key_exists($ocs_column, $metas) && !in_array($glpi_column, $computer_updates)) { if (isset($metas[$ocs_column])) { $var = addslashes($metas[$ocs_column]); } else { $var = ""; } switch ($glpi_column) { case "use_date": $date = str_replace($metas['NAME'] . "-", "", $var); $computer_updates = PluginOcsinventoryngOcsAdminInfosLink::addInfocomsForComputer($computers_id, $date, $computer_updates); break; } } } } } } return $computer_updates; }