vB_UserContext
in package
Uses
vB_Trait_NoSerialize
vB_UserContext
Table of Contents
- USERGROUP_GUESTS = 1
- USERLEVEL_ADMIN = 4
- USERLEVEL_GUEST = 0
- USERLEVEL_MODERATOR = 2
- USERLEVEL_REGUSER = 1
- USERLEVEL_SUPERADMIN = 5
- USERLEVEL_SUPERMODERATOR = 3
- $admin_info : mixed
- $assertor : vB_dB_Assertor
- $canCreateTypes : mixed
- $canModerate : mixed
- $canPost : mixed
- $canRead : mixed
- $cantRead : mixed
- $channelAccess : mixed
- $channelPermissions : mixed
- $channelPermsFrom : mixed
- $config : array<string|int, mixed>
- $contentTypes : mixed
- $countFields : mixed
- $datastore : vB_Datastore
- $globalPerms : mixed
- $groupInTopic : mixed
- $isForumModerator : mixed
- $moderatorBitMasks : mixed
- $moderatorPerms : mixed
- $noComments : mixed
- $permissionContext : vB_PermissionContext
- $permissions : mixed
- $selfOnly : mixed
- $superAdmins : mixed
- $superAdminsCheckPerms : array<string|int, mixed>
- The following permissions should always be checked even if current user is a Superadmin
- $superMod : mixed
- $usergroups : mixed
- $userid : mixed
- $userIsSuperAdmin : mixed
- __construct() : mixed
- Constructor
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- canUpload() : mixed
- Checks to see if a user can upload a file for attachment
- clearChannelPermissions() : mixed
- Clears all existing permissions. Needed primarily in test.
- fetchGroupInTopic() : mixed
- Fetch group in topic
- fetchPermsForChannels() : mixed
- Fetches an array of permissions for a list of channels, which will be passed in slightly adjusted form to the getFullContent methods
- fetchUserGroups() : mixed
- Return the usergroups for this user
- fetchUserId() : int
- Get the userid
- getAllChannelAccess() : mixed
- This returns an array with the access for this user, reflecting usergroup and groupintopic permissions.
- getAttachmentPermissions() : mixed
- Check for attachment limits/permissions for a given extension.
- getCanCreate() : mixed
- Lists the content types the current user can create at a node.
- getCanModerate() : mixed
- This returns a list of channels where this user can moderate, and an array where they can't.
- getChannelLimitPermission() : int
- Checks for a specific permission in a specific channel
- getChannelLimits() : mixed
- This returns the 5 limit-type settings at the channel level- edit_time, maxstartertags, maxothertags and maxtags
- getChannelPermission() : bool|int
- Checks for a specific permission in a specific channel
- getContributorGroups() : mixed
- This gives a list of all the groups that can create a starter somewhere.
- getLimit() : mixed
- Checks for a limit-type permission- e.g. maximum number of images.
- getModeratorPerms() : mixed
- This returns an array of moderator or moderator-like permissions
- getPermissionsFrom() : int
- This function finds where permissions are set for a given node.
- getReadChannels() : mixed
- This returns a list of channels where this user can read, and an array where they can't.
- getUsergroupLimit() : mixed
- Checks for a limit-type permission in the usergroup table- e.g. maximum number of images.
- getUserLevel() : mixed
- Gets user hierarchy level It is used when ignoring a user, the hierarchy is as follows (VBV-1503):
- hasAdminPermission() : bool
- Checks the administrator table for individual administrator permission (all the different areas of the admin cp that they can access)
- hasModeratorPermission() : mixed
- hasPermission() : bool
- Checks for a specific usergroup permission
- isAdministrator() : bool
- Returns whether the user is administrator Adapted from adminfunctions.php::can_administer
- isForumModerator() : mixed
- isGloballyIgnored() : bool
- Returns whether the user is globally ignored
- isModerator() : mixed
- isSuperAdmin() : bool
- check whether current user is super admin. Don't allow request for a different user.
- isSuperMod() : bool
- Returns whether the current user is a super moderator
- rebuildGroupAccess() : mixed
- Convenience- since userContext is available everywhere, this calls permissionContext->public rebuildGroupAccess
- reloadGroupInTopic() : mixed
- Reloads the groupInTopic data. Needed primarily in test.
- reloadUserPerms() : mixed
- Initializes the user context with the permissions for the selected user.
- checkChannelSettings() : mixed
- For posts to blog-type channel, checks allow_post if applicable
- checkModPerm() : mixed
- Checks to see if the user has the appropriate moderator permission from the moderators table
- getChannelIdOfNode() : int|string|null
- From a given nodeid, fetch the channel of the nodeid. If the nodeid is already returns a channel, returns the nodeid back (not necessarily as the same primative).
- basicAdminControl() : int
- Returns whether the user is administrator Adapted from adminfunctions.php::can_administer Returns 1 if it has full admin privileges, -1 if it doesn't, or 0 if further controls are required.
Constants
USERGROUP_GUESTS
public
mixed
USERGROUP_GUESTS
= 1
USERLEVEL_ADMIN
public
mixed
USERLEVEL_ADMIN
= 4
USERLEVEL_GUEST
public
mixed
USERLEVEL_GUEST
= ""
USERLEVEL_MODERATOR
public
mixed
USERLEVEL_MODERATOR
= 2
USERLEVEL_REGUSER
public
mixed
USERLEVEL_REGUSER
= 1
USERLEVEL_SUPERADMIN
public
mixed
USERLEVEL_SUPERADMIN
= 5
USERLEVEL_SUPERMODERATOR
public
mixed
USERLEVEL_SUPERMODERATOR
= 3
Properties
$admin_info
protected
mixed
$admin_info
=
ull
$assertor
protected
vB_dB_Assertor
$assertor
$canCreateTypes
protected
mixed
$canCreateTypes
= array()
$canModerate
protected
mixed
$canModerate
= alse
$canPost
protected
mixed
$canPost
= array()
$canRead
protected
mixed
$canRead
= alse
$cantRead
protected
mixed
$cantRead
= alse
$channelAccess
protected
mixed
$channelAccess
= alse
$channelPermissions
protected
mixed
$channelPermissions
= array()
$channelPermsFrom
protected
mixed
$channelPermsFrom
= alse
$config
protected
array<string|int, mixed>
$config
$contentTypes
protected
mixed
$contentTypes
= array()
$countFields
protected
mixed
$countFields
= array('edit_time' => 'hours', 'maxtags' => 'count', 'maxstartertags' => 'count', 'maxothertags' => 'count', 'maxattachments' => 'count', 'maxchannels' => 'count', 'channeliconmaxsize' => 'count')
$datastore
protected
vB_Datastore
$datastore
$globalPerms
protected
mixed
$globalPerms
= alse
$groupInTopic
protected
mixed
$groupInTopic
= array()
$isForumModerator
protected
mixed
$isForumModerator
$moderatorBitMasks
protected
mixed
$moderatorBitMasks
= alse
$moderatorPerms
protected
mixed
$moderatorPerms
= array()
$noComments
protected
mixed
$noComments
= array()
$permissionContext
protected
vB_PermissionContext
$permissionContext
$permissions
protected
mixed
$permissions
= alse
$selfOnly
protected
mixed
$selfOnly
= alse
$superAdmins
protected
mixed
$superAdmins
= array()
$superAdminsCheckPerms
The following permissions should always be checked even if current user is a Superadmin
protected
array<string|int, mixed>
$superAdminsCheckPerms
= array('requirehvcheck' => 1, 'showeditedby' => 1, 'canbeusernoted' => 1, 'allowhtml' => 1)
$superMod
protected
mixed
$superMod
= array()
$usergroups
protected
mixed
$usergroups
$userid
protected
mixed
$userid
$userIsSuperAdmin
protected
mixed
$userIsSuperAdmin
= alse
Methods
__construct()
Constructor
public
__construct( $userid, $assertor, $datastore, $config) : mixed
Parameters
- $userid :
-
-- if the user is invalid guest user permissions (userid 0) will be used instead
- $assertor :
- $datastore :
- $config :
Return values
mixed —__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —canUpload()
Checks to see if a user can upload a file for attachment
public
canUpload(mixed $size, mixed $extension[, mixed $nodeid = false ]) : mixed
Parameters
- $size : mixed
- $extension : mixed
- $nodeid : mixed = false
Return values
mixed —clearChannelPermissions()
Clears all existing permissions. Needed primarily in test.
public
clearChannelPermissions([mixed $usergroupid = false ]) : mixed
Parameters
- $usergroupid : mixed = false
Return values
mixed —fetchGroupInTopic()
Fetch group in topic
public
fetchGroupInTopic([mixed $nodeid = null ]) : mixed
Parameters
- $nodeid : mixed = null
Return values
mixed —fetchPermsForChannels()
Fetches an array of permissions for a list of channels, which will be passed in slightly adjusted form to the getFullContent methods
public
fetchPermsForChannels(mixed $channels) : mixed
@param mixed array of integers
Parameters
- $channels : mixed
Return values
mixed —array of permission. parentid => permissions. permissions are either 0/1 or array of string => 0/1
fetchUserGroups()
Return the usergroups for this user
public
fetchUserGroups() : mixed
Return values
mixed —array of usergroupid's
fetchUserId()
Get the userid
public
fetchUserId() : int
Return values
int —getAllChannelAccess()
This returns an array with the access for this user, reflecting usergroup and groupintopic permissions.
public
getAllChannelAccess() : mixed
$param boolean whether to force reload
Return values
mixed —Each element contains three arrays: canview, canaccess, and selfonly. Each is an array of nodeids where the user has that access
getAttachmentPermissions()
Check for attachment limits/permissions for a given extension.
public
getAttachmentPermissions(mixed $extension[, mixed $nodeid = false ]) : mixed
Note: This is only constrained to the attachmenttype and attachmentpermission tables. The create permissions for all attachments are handled in the channels.
Parameters
- $extension : mixed
- $nodeid : mixed = false
Return values
mixed —false if the extension is not allowed or the user doesn't have permission to use it. Otherwise an array of limits.
getCanCreate()
Lists the content types the current user can create at a node.
public
getCanCreate(mixed $nodeid) : mixed
Parameters
- $nodeid : mixed
Return values
mixed —array of contenttypes
getCanModerate()
This returns a list of channels where this user can moderate, and an array where they can't.
public
getCanModerate() : mixed
Return values
mixed —array of ('can'=> array of integers, 'cannot' => array of integers)
getChannelLimitPermission()
Checks for a specific permission in a specific channel
public
getChannelLimitPermission(mixed $permissiongroup, mixed $permission, mixed $nodeid[, mixed $parents = false ][, mixed $parentid = false ]) : int
Parameters
- $permissiongroup : mixed
- $permission : mixed
- $nodeid : mixed
- $parents : mixed = false
- $parentid : mixed = false
Return values
int —permission numeric value
getChannelLimits()
This returns the 5 limit-type settings at the channel level- edit_time, maxstartertags, maxothertags and maxtags
public
getChannelLimits(mixed $nodeid[, mixed $permission = '' ][, mixed $parents = false ]) : mixed
Parameters
- $nodeid : mixed
- $permission : mixed = ''
- $parents : mixed = false
Return values
mixed —2 element array
getChannelPermission()
Checks for a specific permission in a specific channel
public
getChannelPermission(mixed $permissiongroup, mixed $permission, mixed $nodeid[, mixed $parents = false ][, mixed $parentid = false ]) : bool|int
Parameters
- $permissiongroup : mixed
- $permission : mixed
- $nodeid : mixed
- $parents : mixed = false
- $parentid : mixed = false
Return values
bool|int —getContributorGroups()
This gives a list of all the groups that can create a starter somewhere.
public
getContributorGroups(mixed $nodeid) : mixed
@param int the nodeid we're interested in. It's best if this is the channel id.
Parameters
- $nodeid : mixed
Return values
mixed —array of integers- each is a usergroupid.
getLimit()
Checks for a limit-type permission- e.g. maximum number of images.
public
getLimit(mixed $permission) : mixed
Parameters
- $permission : mixed
Return values
mixed —getModeratorPerms()
This returns an array of moderator or moderator-like permissions
public
getModeratorPerms(mixed $node) : mixed
Parameters
- $node : mixed
Return values
mixed —getPermissionsFrom()
This function finds where permissions are set for a given node.
public
getPermissionsFrom(mixed $groupid, mixed $nodeid[, mixed $parentid = false ]) : int
Parameters
- $groupid : mixed
- $nodeid : mixed
- $parentid : mixed = false
Return values
int —the nodeid were permissions are checked.
getReadChannels()
This returns a list of channels where this user can read, and an array where they can't.
public
getReadChannels([mixed $nodeid = false ]) : mixed
Parameters
- $nodeid : mixed = false
Return values
mixed —array of ('can'=> array of integers, 'cannot' => array of integers)
getUsergroupLimit()
Checks for a limit-type permission in the usergroup table- e.g. maximum number of images.
public
getUsergroupLimit(mixed $permission) : mixed
Parameters
- $permission : mixed
Return values
mixed —false if this is not a valid request, -1 if there is no setting for this user's group or groups, or an integer
getUserLevel()
Gets user hierarchy level It is used when ignoring a user, the hierarchy is as follows (VBV-1503):
public
getUserLevel() : mixed
SuperAdmin -> Admin -> Super moderator -> Moderator -> Regular user
Return values
mixed —hasAdminPermission()
Checks the administrator table for individual administrator permission (all the different areas of the admin cp that they can access)
public
hasAdminPermission(mixed $permission) : bool
Parameters
- $permission : mixed
Return values
bool —hasModeratorPermission()
public
hasModeratorPermission(mixed $permission, mixed $channelid) : mixed
Parameters
- $permission : mixed
- $channelid : mixed
Return values
mixed —hasPermission()
Checks for a specific usergroup permission
public
hasPermission(mixed $group, mixed $permission) : bool
For admin permissions use the hasAdminPermission method except for cancontrolpanel and ismoderator permission
Parameters
- $group : mixed
- $permission : mixed
Return values
bool —isAdministrator()
Returns whether the user is administrator Adapted from adminfunctions.php::can_administer
public
isAdministrator() : bool
Return values
bool —isForumModerator()
public
isForumModerator() : mixed
Return values
mixed —isGloballyIgnored()
Returns whether the user is globally ignored
public
isGloballyIgnored() : bool
Return values
bool —isModerator()
public
isModerator() : mixed
Return values
mixed —isSuperAdmin()
check whether current user is super admin. Don't allow request for a different user.
public
isSuperAdmin() : bool
Return values
bool —isSuperMod()
Returns whether the current user is a super moderator
public
isSuperMod() : bool
Return values
bool —rebuildGroupAccess()
Convenience- since userContext is available everywhere, this calls permissionContext->public rebuildGroupAccess
public
rebuildGroupAccess() : mixed
Return values
mixed —reloadGroupInTopic()
Reloads the groupInTopic data. Needed primarily in test.
public
reloadGroupInTopic() : mixed
Return values
mixed —reloadUserPerms()
Initializes the user context with the permissions for the selected user.
public
reloadUserPerms([bool $forceReload = false ]) : mixed
This is used for the initial constructor and can be used to refresh permissions if they have changed.
Parameters
- $forceReload : bool = false
-
-- Do not use cached permissions
Return values
mixed —checkChannelSettings()
For posts to blog-type channel, checks allow_post if applicable
protected
checkChannelSettings(mixed $channel, mixed $parent) : mixed
Parameters
- $channel : mixed
- $parent : mixed
Return values
mixed —checkModPerm()
Checks to see if the user has the appropriate moderator permission from the moderators table
protected
checkModPerm(string $permissiongroup, string $permission[, int $nodeid = null ]) : mixed
Parameters
- $permissiongroup : string
- $permission : string
- $nodeid : int = null
-
(optional, if not specified, will return a list of nodes on which the user has the permission)
Return values
mixed —- It returns a boolean indicating if we have permission or an array with nodeids for which we have permission.
getChannelIdOfNode()
From a given nodeid, fetch the channel of the nodeid. If the nodeid is already returns a channel, returns the nodeid back (not necessarily as the same primative).
protected
getChannelIdOfNode(int|string $nodeid) : int|string|null
Parameters
- $nodeid : int|string
Return values
int|string|null —basicAdminControl()
Returns whether the user is administrator Adapted from adminfunctions.php::can_administer Returns 1 if it has full admin privileges, -1 if it doesn't, or 0 if further controls are required.
private
basicAdminControl() : int