xoops forums

frankblack

Just can't stay away
Posted on: 2010/2/13 14:11
frankblack
frankblack (Show more)
Just can't stay away
Posts: 830
Since: 2005/6/13
#1

getGroups ...

... 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

Community Support Member
Posted on: 2010/2/13 14:47
ghia
ghia (Show more)
Community Support Member
Posts: 4946
Since: 2008/7/3 1
#2

Re: getGroups ...

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

Just can't stay away
Posted on: 2010/2/13 15:05
frankblack
frankblack (Show more)
Just can't stay away
Posts: 830
Since: 2005/6/13
#3

Re: getGroups ...

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

Community Support Member
Posted on: 2010/2/13 18:45
ghia
ghia (Show more)
Community Support Member
Posts: 4946
Since: 2008/7/3 1
#4

Re: getGroups ...

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

Moderator
Posted on: 2010/2/14 8:30
sailjapan
sailjapan (Show more)
Moderator
Posts: 1672
Since: 2005/11/16
#5

Re: getGroups ...

It'd be nice to have a 'Log this user out Now!' button...

redheadedrod

Home away from home
Posted on: 2010/2/14 14:27
redheadedrod
redheadedrod (Show more)
Home away from home
Posts: 1296
Since: 2008/2/26
#6

Re: getGroups ...

What happens if you delete their sessions file? Dont they sort of automatically get "logged out" as the session no longer exists?

Rodney

frankblack

Just can't stay away
Posted on: 2010/2/14 16:51
frankblack
frankblack (Show more)
Just can't stay away
Posts: 830
Since: 2005/6/13
#7

Re: getGroups ...

Added a feature request on sourceforge...