Welcome to Geeklog Wednesday, April 08 2020 @ 08:50 am EDT

Geeklog Forums

Plugin detecting when a user is added/removed from a group


Status: offline

mevans

Forum User
Full Member
Registered: 08/02/04
Posts: 393
Location:Texas
I would like to implement a feature in Media Gallery where I need to detect when a user is added or removed from a group.

The plugin API has the PLG_userInfoChanged() call, but in GL 1.3.x, it is called before the group assignments are done, so it won't work for what I need.

But, in GL 1.4 I see it is called after the group assignments in admin/user.php, but only if the $userChanged variable is true. Unfortunately, $userChanged is not set to true in the group assignments, there doesn't seem to be any check to see if the groups changed, just a global rebuild of the user's group assignments. I actually understand why you don't try to detect if the groups changed, too much overhead and very little value.

So, any chance in one of the GL 1.4 releases PLG_userInfoChanged() could be called without checking for $userChanged? I would assume it to be the responsibility of the plugin to determine if anything it cares about has changed and act appropriately.

Thanks!
Mark
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 22/03/04
Posts: 1512
Quote by mevans: I would like to implement a feature in Media Gallery where I need to detect when a user is added or removed from a group.
will PLG_groupChanged() not do the trick?
 Quote

Status: offline

mevans

Forum User
Full Member
Registered: 08/02/04
Posts: 393
Location:Texas
Quote by machinari: will PLG_groupChanged() not do the trick?


I don't think so, from reading the code, it appears it is called if you make a specific change to a group, not necessarily when a user is added to a group. For example, looking at the GL 1.4 code for user.php, all the user's group assignments are deleted, then rebuilt from the selected groups in the form. No calls to PLG_groupChanged() are made at that point.

If you edit the group, any group attribute changes will trigger a call to PLG_groupChanged(), but editing the group membership does not trigger a PLG_groupChanged() call.

I think the best approach would be to make a PLG_userInfoChanged() call in user.php, this way you can pickup both profile changes and group assignment changes. The only problem is that this call would have to be made without really knowing if anything actually changed since there is no method right now to determine if group assignments changed in the user edit.

Actually, you got me thinking. Just adding a call to PLG_userInfoChanged() in users.php will not accomplish the goal. Since users can also be added in group.php in the editusers() function, there would have to be a call made there for each user that is added/removed from a group. Probably too much overhead to implement that.

Maybe I should investigate using additional variables to the user profile to accomplish what I want.


Thanks!
Mark
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 22/03/04
Posts: 1512
Quote by mevans:
If you edit the group, any group attribute changes will trigger a call to PLG_groupChanged(), but editing the group membership does not trigger a PLG_groupChanged() call.
I would call that an incomplete implementation of the API and submit a bug report, or at least a feature request, which seems to be what you've done here.

the quick fix, though not practical for everybody who is going to install your plugin, would be to include the API call in the function savegroupusers().
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
I believe there already is a Feature Request for this (hi Turias) but, as Mark noted, it isn't so easy to implement due to the way group changes are currently handled and has thus fallen by the wayside ...

bye, Dirk
 Quote

All times are EDT. The time is now 08:50 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content