function plugin_pre_item_update_resources($item) { if (!isset($item->input["_UpdateFromResource_"])) { $restrict = "`itemtype` = '" . get_class($item) . "'\n AND `items_id` = '" . $item->getField('id') . "'"; $items = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict); if (!empty($items)) { foreach ($items as $device) { $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->GetfromDB($device["plugin_resources_resources_id"]); if (isset($PluginResourcesResource->fields["locations_id"]) && isset($item->input["locations_id"])) { if ($item->input["locations_id"] != 0 && $PluginResourcesResource->fields["locations_id"] != $item->input["locations_id"]) { $values = array(); $values["id"] = $device["plugin_resources_resources_id"]; $values["locations_id"] = $item->input["locations_id"]; $values["withtemplate"] = 0; $values["_UpdateFromUser_"] = 1; $PluginResourcesResource->update($values); Session::addMessageAfterRedirect(__("Modification of the associated resource's location", "resources"), true); } } } } } }