pluginsGLPI / geninventorynumber

Inventorynumber generation
GNU General Public License v3.0
8 stars 14 forks source link

Fix update check #48

Closed cconard96 closed 2 years ago

cconard96 commented 2 years ago

fixes #42

12 years ago, GLPI stopped receiving a return value form pre_item hooks and instead modified the input/fields directly. 6 years ago, the preItemUpdate function removed the return values and previously it was returning ['noright'] if the user did NOT have the plugin's UPDATE right. This cancelled the update (before the change 12 years ago).

I'm not sure the right check make sense. The plugin documentation says that you cannot modify the inventory number for itemtypes managed by this plugin. However, the right check as it was would let everyone without the UPDATE right for the plugin (regenerate) change it. The opposite check makes a bit more sense but doesn't align with the documentation.

Without the check, if the number is managed for that itemtype, nobody can manually change it except through massive action which is what the documentation specifies. It also only cares if the inventory number is changed and not any of the other fields.

cconard96 commented 2 years ago

@kabassanov Does this align with what you expected too?

kabassanov commented 2 years ago

@cconard96 Yes, it does.

cedric-anne commented 2 years ago

Unless I am wrong, after reading again the code, the logic should be: if user has right to regenerate the inventory number, do nothing, else, revert the otherserial to previous value.

So, basically, removal of the ! as mentionned in first issue comment seems to be the correct fix.

kabassanov commented 2 years ago

Hi Cedric-Anne,

That was my first impression, but it still allows user with plugin UPDATE right to put any value in the field and not only to automatically regenerate inventory number.

cedric-anne commented 2 years ago

Without the check, if the number is managed for that itemtype, nobody can manually change it except through massive action which is what the documentation specifies.

Where did you find this documentation ?

cconard96 commented 2 years ago

https://github.com/pluginsGLPI/geninventorynumber/wiki/English-documentation#how-does-it-works