PDA

View Full Version : Permission for specific Usergroup


TheAdminMarket
07-10-2015, 02:10 PM
Hello,

Does anybody knows the syntax to get a specific permission for a specific usergroup (not for the active user).

eg the code below returns True/False for the Permission "Vote" in "Gallery" for the active user.

if ($permissions['gallery'] & $vbulletin->bf_ugp['gallery']['vote'])
{
echo 'Yes';
} else {
echo 'No';
}


I want the same but (eg) for Usergroupid 12

Thank you

MarkFL
07-10-2015, 02:28 PM
Have you tried looking at the array:

$vbulletin->usergroupcache[12]

TheAdminMarket
07-10-2015, 02:46 PM
Have you tried looking at the array:

$vbulletin->usergroupcache[12]

Yes but it show the same value that I can retrieve from the database eg gallery => 3
I think that is something about "unserialize" but don't remember it. Have used it 5 years ago. Long time to remember it.

MarkFL
07-10-2015, 02:54 PM
Yes but it show the same value that I can retrieve from the database eg gallery => 3
I think that is something about "unserialize" but don't remember it. Have used it 5 years ago. Long time to remember it.

Ah, okay...I wish I could help further but I have never "unserialized" the numeric permissions values to get a particular sub-permission.

Hopefully someone here knows, as I would also be interested in knowing how that works. :D

TheAdminMarket
07-10-2015, 03:03 PM
Ah, okay...I wish I could help further but I have never "unserialized" the numeric permissions values to get a particular sub-permission.

Hopefully someone here knows, as I would also be interested in knowing how that works. :D

Anyway thank you :)

kh99
07-10-2015, 06:25 PM
They're bitfields, not serialized values, so if you have the permission number for a group (and it could very well be 3), then you can check it by using
if ($vbulletin->usergroupcache[12]['gallery'] & $vbulletin->bf_ugp['gallery']['vote'])
{
// they have vote permission
}


I don't know if $vbulletin->usergroupcache[12]['gallery'] is right or not. It's not clear from what's posted above.

TheAdminMarket
07-10-2015, 06:35 PM
They're bitfields, not serialized values, so if you have the permission number for a group (and it could very well be 3), then you can check it by using
if ($vbulletin->usergroupcache[12]['gallery'] & $vbulletin->bf_ugp['gallery']['vote'])
{
// they have vote permission
}


I don't know if $vbulletin->usergroupcache[12]['gallery'] is right or not. It's not clear from what's posted above.

Works !! Thank you.