fusioninventory-for-glpi icon indicating copy to clipboard operation
fusioninventory-for-glpi copied to clipboard

FusionInventory 9.3+1.3 Using location rules for locked field - minor issue

Open kotryakhov opened this issue 5 years ago • 1 comments

After setting up location rule (in my case for printers) i have seen that field location were updated, although i mark location field as blocked. I made code review in inventoryprinterlib.class.php and found that lockable fields were retrieved but info about blocked locations_id not applied In code below you can see it

      //Add the location if needed (play rule locations engine)
      $input = PluginFusioninventoryToolbox::addLocation($input);
      $printer->update($input, !$no_history);

I made a small change

      //Add the location if needed (play rule locations engine)
      if (!in_array("locations_id", $a_lockable)) {
         PluginFusioninventoryToolbox::logIfExtradebug(
         "pluginFusioninventory-rules-new-location",
         "Locked field locations_id was not found!\n"."Data:\n".print_r($a_ret, true)
         );
         $input = PluginFusioninventoryToolbox::addLocation($input);
      }
      $printer->update($input, $no_history);

May be it useful for any other items, like computers and etc.

kotryakhov avatar Mar 26 '19 23:03 kotryakhov

Thank you very much! This bug is still present in 9.5+3.0 and your code fixes it nicely.

nbriche avatar Dec 01 '21 09:12 nbriche