glpi icon indicating copy to clipboard operation
glpi copied to clipboard

Log full profile information to user record on profile add or suppression

Open kabassanov opened this issue 2 years ago • 6 comments

When a profile is attached to a user account, it is defined by both entity and the profile itseilf. Actually, only this second part is logged to the user history and this information is meaningless without the entity environment it is attached to.

The proposd approach is probably not the best one and any other way to do this is welcome.

kabassanov avatar Aug 26 '22 17:08 kabassanov

It looks like the issue is just that the post_addItem function in CommonDBRelation uses the 1st item of the relation, which in this case is the Profile, when adding the log event so the friendly name of the Profile is used rather than the Profile_User (which already accounts for the entity and recursivity). You mentioned on Discord that is used to show this information in the log, but I cannot find the version where this may have changed.

I'm wondering if there could be something simple missing somewhere to restore the functionality if it was there before, or at least avoid having a specific exception here and duplicating logic already done in the Profile_User's computeFriendlyName.

cconard96 avatar Aug 26 '22 22:08 cconard96

It looks like the issue is just that the post_addItem function in CommonDBRelation uses the 1st item of the relation, which in this case is the Profile,

This is a Profile_User object with the first item is a User Object and the second one: a Profile Object... Or we don't talk about the same thing.

when adding the log event so the friendly name of the Profile is used rather than the Profile_User (which already accounts for the entity and recursivity). You mentioned on Discord that is used to show this information in the log, but I cannot find the version where this may have changed.

As loyal user of GLPI since 2008, I used several versions... The trace I talked about was from 2014, so probably a very old implementation of GLPI...

I'm wondering if there could be something simple missing somewhere to restore the functionality if it was there before, or at least avoid having a specific exception here and duplicating logic already done in the Profile_User's computeFriendlyName.

No idea...

kabassanov avatar Aug 27 '22 10:08 kabassanov

@kabassanov are you going to work on this or should we close?

trasher avatar Sep 21 '22 06:09 trasher

@kabassanov are you going to work on this or should we close?

Need to fix it before closing... And move it forward in my todo list...

kabassanov avatar Sep 21 '22 07:09 kabassanov

I wonder where we should keep histories for these modifications? In the user history, in the profile history, in the entity history?

kabassanov avatar Sep 22 '22 10:09 kabassanov

@trasher , I changed the way this patch completes user-profile-entity logs. It is OK for me. I had to force IDs displays while retreiving User, Profile or Entity informations, because without this some tests fail. The reason is that post_addItem method is called during login procedure (for user synchronisation) and getNameID function is looking for not existing (at this time) $_SESSION["glpiis_ids_visible"] if not forcing display...

kabassanov avatar Oct 05 '22 13:10 kabassanov

Apart this, seems good 👍🏽

orthagh avatar Oct 06 '22 06:10 orthagh

@kabassanov

I rebased branch, simplified code and added tests. Could I force-push to your branch, or should I create a new pull request ?

cedric-anne avatar Jun 12 '23 11:06 cedric-anne

@kabassanov

I rebased branch, simplified code and added tests. Could I force-push to your branch, or should I create a new pull request ?

Yes, you can.

kabassanov avatar Jun 12 '23 11:06 kabassanov