frankblack frankblack
  • Just can't stay away
  • Just can't stay away
  • Joined: 2005/6/13 4:03
  • From D-Schiefbahn
  • Group: Registered Users
  • Posts: 830
  • Posted on: 2010/2/13 9:11
getGroups ... #1
... should get the groups the current user is in. Right?

To get the groups array you can use this code:
$groupsb = (is_object($xoopsUser)) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
echo 
implode(' ',$groupsb);


Test case 1: my user admin with uid 1 is in the groups admins and registered users, so what do you expect to be printed?

Right! 1 2

Test case 2: my user admin with uid 1 is in the groups admins, so what do you expect to be printed?

Right! 1

WRONG! It prints 1 2

Why is this so? I can't find any solution for this "odd" behaviour. When this is expected behaviour, then this is bollocks. I made a fresh install of 2.4.4 to avoid any collisions and if I remember correctly in the 2.0 series it worked as I expected.
ghia ghia
  • Community Support Member
  • Community Support Member
  • Joined: 2008/7/3 15:19
  • From Belgium
  • Group: Registered Users
  • Posts: 4946
  • Posted on: 2010/2/13 9:47
Re: getGroups ... #2
As it should return the group link records, are you sure for case 2 the link to registered users was deleted?
Check with phpMyAdmin the records returned by:
SELECT groupid FROM xoops_groups_users_link WHERE uid1;
(xoops_ = prefix_)

PS: It is possible that you need to log out and in to see the effects of group manipulation!
frankblack frankblack
  • Just can't stay away
  • Just can't stay away
  • Joined: 2005/6/13 4:03
  • From D-Schiefbahn
  • Group: Registered Users
  • Posts: 830
  • Posted on: 2010/2/13 10:05
Re: getGroups ... #3
You are correct ghia. You have to log out or manually kill the session/cookies to see an effect. Feeling a bit uncomfortable with this anyway. I know that this is a scenario which will happen not to often (or never): Let's assume the admin gave user frankblack accidently admin rights. frankblack logs in and has admin rights. The admin notices his mistakes and moves frankblack out of the admin group, but while frankblack is online he has still access to admin area?

Theoretically spoken...
ghia ghia
  • Community Support Member
  • Community Support Member
  • Joined: 2008/7/3 15:19
  • From Belgium
  • Group: Registered Users
  • Posts: 4946
  • Posted on: 2010/2/13 13:45
Re: getGroups ... #4
I have this here sometimes on XOOPS also. You have a spammer and deny his rights to post, but he can continue posting until he get logged out.
sailjapan sailjapan
  • Moderator
  • Moderator
  • Joined: 2005/11/16 6:27
  • From Osaka
  • Group: Registered Users
  • Posts: 1672
  • Posted on: 2010/2/14 3:30
Re: getGroups ... #5
It'd be nice to have a 'Log this user out Now!' button...
redheadedrod redheadedrod
  • Home away from home
  • Home away from home
  • Joined: 2008/2/26 11:05
  • From Grand Rapids, MI
  • Group: Registered Users
  • Posts: 1296
  • Posted on: 2010/2/14 9:27
Re: getGroups ... #6
What happens if you delete their sessions file? Dont they sort of automatically get "logged out" as the session no longer exists?

Rodney
frankblack frankblack
  • Just can't stay away
  • Just can't stay away
  • Joined: 2005/6/13 4:03
  • From D-Schiefbahn
  • Group: Registered Users
  • Posts: 830
  • Posted on: 2010/2/14 11:51
Re: getGroups ... #7
Added a feature request on sourceforge...
How to effectively post a question in the Xoops forums? - Read here...
Design by: XOOPS UI/UX Team