/** * Update lockable fields of an item * * @param $item CommonDBTM object * @param $withtemplate integer withtemplate param (default '') * * @return nothing **/ static function updateComputer(CommonDBTM $item, $withtemplate = '') { global $DB; // Manage changes for OCS if more than 1 element (date_mod) // Need dohistory==1 if dohistory==2 no locking fields if ($item->fields["is_dynamic"] && countElementsInTable('glpi_plugin_ocsinventoryng_ocslinks', "`computers_id`='" . $item->getID() . "'") && $item->dohistory == 1 && count($item->updates) > 1 && !isset($item->input["_nolock"])) { PluginOcsinventoryngOcsServer::mergeOcsArray($item->fields["id"], $item->updates, "computer_update"); } if (isset($item->input["_auto_update_ocs"])) { $query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n SET `use_auto_update` = '" . $item->input["_auto_update_ocs"] . "'\n WHERE `computers_id` = '" . $item->input["id"] . "'"; $DB->query($query); } }
/** * @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"); } } } }
/** * Update lockable fields of an item * * @param $item CommonDBTM object * @return nothing * @internal param int|string $withtemplate integer withtemplate param (default '') */ static function updateComputer(CommonDBTM $item) { global $DB; // Manage changes for OCS if more than 1 element (date_mod) // Need dohistory==1 if dohistory==2 no locking fields $ocslink = new self(); if ($item->fields["is_dynamic"] && $ocslink->getFromDBforComputer($item->getID()) && $item->dohistory == 1 && count($item->updates) > 1 && !isset($item->input["_nolock"])) { $cfg_ocs = PluginOcsinventoryngOcsServer::getConfig($ocslink->fields["plugin_ocsinventoryng_ocsservers_id"]); if ($cfg_ocs["use_locks"]) { PluginOcsinventoryngOcsServer::mergeOcsArray($item->fields["id"], $item->updates, "computer_update"); } } if (isset($item->input["_auto_update_ocs"])) { $query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n SET `use_auto_update` = '" . $item->input["_auto_update_ocs"] . "'\n WHERE `computers_id` = '" . $item->input["id"] . "'"; $DB->query($query); } }