Log in

View Full Version : Moderator Permissions -how to work out what the numbers mean in the moderator table?


Spinball
02-09-2012, 10:50 AM
I'm guessing they use the MySQL OPTION code and work in a similar way to user options.
Anyone got a table of what numbers mean what?
Thanks.

kh99
02-09-2012, 12:26 PM
If you look in file includes/xml/bitfield_vbulletin.xml for <group name="moderatorpermissions"> and <group name="moderatorpermissions2">, you'll see constants defined for each bit of the permissions and permissions2 columns. In the vbulletin scripts these are available in $vbulletin->bf_misc_moderatorpermissions and $vbulletin->bf_misc_moderatorpermissions2. So for instance if you read a moderator's permission value for a given forum and you want to check if they have caneditposts permission, then you'd do something like:

if ($permission & $vbulletin->bf_misc_moderatorpermissions['caneditposts'])
{
}


or if you're going to the database directly and you don't have $vbulletin,

if ($permission & 1) // 1 is value of caneditposts from bitfield_vbulletin.xml
{
}


you might also want to look at functions can_moderate() and fetch_moderator_permissions() in includes/functions.php (or if you're including global.php in your script, you might just want to call thoses functions to do the check).

Spinball
02-09-2012, 01:45 PM
Many thanks, that's solved it for me:
SELECT username
FROM user , moderator
WHERE user.userid = moderator.userid
AND permissions &4096
The users who can ban. Smashing.