class vB_UserContext

vB_UserContext

Traits

Constants

USERGROUP_GUESTS

USERLEVEL_SUPERADMIN

USERLEVEL_ADMIN

USERLEVEL_SUPERMODERATOR

USERLEVEL_MODERATOR

USERLEVEL_REGUSER

USERLEVEL_GUEST

Properties

protected $userid
protected vB_dB_Assertor $assertor
protected vB_Datastore $datastore
protected array $config
protected vB_PermissionContext $permissionContext
protected $admin_info
protected $canRead
protected $cantRead
protected $selfOnly
protected $usergroups
protected $permissions
protected $channelPermissions
protected $superAdmins
protected $canModerate
protected $groupInTopic
protected $contentTypes
protected $canCreateTypes
protected $canPost
protected $noComments
protected $moderatorPerms
protected $moderatorBitMasks
protected $channelAccess
protected $channelPermsFrom
protected $userIsSuperAdmin
protected $isForumModerator
protected $superMod
protected $globalPerms
protected $countFields
protected array $superAdminsCheckPerms The following permissions should always be checked even if current user is a Superadmin

Methods

__sleep()

No description

__wakeup()

No description

__construct($userid, $assertor, $datastore, $config)

Constructor

reloadUserPerms(boolean $forceReload = false)

Initializes the user context with the permissions for the selected user.

mixed
getContributorGroups($nodeid)

This gives a list of all the groups that can create a starter somewhere.

clearChannelPermissions(int $usergroupid = false)

Clears all existing permissions. Needed primarily in test.

reloadGroupInTopic()

Reloads the groupInTopic data. Needed primarily in test.

Mixed
fetchGroupInTopic(Mixed $nodeid = null)

Fetch group in topic

boolean
hasPermission(string $group, string $permission)

Checks for a specific usergroup permission

integer
fetchUserId()

Get the userid

mixed
fetchUserGroups()

Return the usergroups for this user

integer
getPermissionsFrom(integer $groupid, integer $nodeid, integer $parentid = false)

This function finds where permissions are set for a given node.

int
getChannelLimitPermission($permissiongroup, $permission, $nodeid, $parents = false, $parentid = false)

Checks for a specific permission in a specific channel

mixed
checkModPerm(string $permissiongroup, string $permission, int $nodeid = null)

Checks to see if the user has the appropriate moderator permission from the moderators table

mixed
getUsergroupLimit(string $permission)

Checks for a limit-type permission in the usergroup table- e.g. maximum number of images.

boolean|integer
getChannelPermission(string $permissiongroup, string $permission, int $nodeid, mixed $parents = false, int $parentid = false)

Checks for a specific permission in a specific channel

mixed
getChannelLimits($nodeid, $permission = '', $parents = false)

This returns the 5 limit-type settings at the channel level- edit_time, skip_moderate, maxstartertags, maxothertags and maxtags

int|string|null
getChannelIdOfNode(int|string $nodeid)

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

mixed
getLimit($permission)

Checks for a limit-type permission- e.g. maximum number of images.

bool
isGloballyIgnored()

Returns whether the user is globally ignored

bool
isAdministrator()

Returns whether the user is administrator Adapted from adminfunctions.php::can_administer

bool
isSuperMod()

Returns whether the current user is a super moderator

hasModeratorPermission($permission, $channelid = 0)

No description

boolean
hasAdminPermission(string $permission)

Checks the administrator table for individual administrator permission (all the different areas of the admin cp that they can access)

mixed
getReadChannels(integer $nodeid = false)

This returns a list of channels where this user can read, and an array where they can't.

mixed
getCanModerate()

This returns a list of channels where this user can moderate, and an array where they can't.

isForumModerator()

No description

isModerator()

No description

canUpload(int $size, string $extension, int $nodeid = false)

Checks to see if a user can upload a file for attachment

bool
isSuperAdmin()

check whether current user is super admin. Don't allow request for a different user.

getModeratorPerms(mixed $node)

This returns an array of moderator or moderator-like permissions

mixed
getCanCreate(int $nodeid)

Lists the content types the current user can create at a node.

checkChannelSettings(mixed $channel, mixed $parent)

For posts to blog-type channel, checks allow_post if applicable

mixed
getAllChannelAccess()

This returns an array with the access for this user, reflecting usergroup and groupintopic permissions.

rebuildGroupAccess()

Convenience- since userContext is available everywhere, this calls permissionContext->public rebuildGroupAccess

getUserLevel()

Gets user hierarchy level It is used when ignoring a user, the hierarchy is as follows (VBV-1503):

mixed
fetchPermsForChannels($channels)

Fetches an array of permissions for a list of channels, which will be passed in slightly adjusted form to the getFullContent methods

mixed
getAttachmentPermissions(string $extension, int $nodeid = false)

Check for attachment limits/permissions for a given extension.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 110
__construct($userid, $assertor, $datastore, $config)

Constructor

Parameters

$userid -- if the user is invalid guest user permissions (userid 0) will be used instead
$assertor
$datastore
$config

at line 140
reloadUserPerms(boolean $forceReload = false)

Initializes the user context with the permissions for the selected user.

This is used for the initial constructor and can be used to refresh permissions if they have changed.

Parameters

boolean $forceReload -- Do not use cached permissions

at line 287
mixed getContributorGroups($nodeid)

This gives a list of all the groups that can create a starter somewhere.

@param int the nodeid we're interested in. It's best if this is the channel id.

Parameters

$nodeid

Return Value

mixed array of integers- each is a usergroupid.

at line 308
clearChannelPermissions(int $usergroupid = false)

Clears all existing permissions. Needed primarily in test.

Parameters

int $usergroupid optional usergroup

at line 340
reloadGroupInTopic()

Reloads the groupInTopic data. Needed primarily in test.

at line 363
Mixed fetchGroupInTopic(Mixed $nodeid = null)

Fetch group in topic

Parameters

Mixed $nodeid Nodeid, to retrieve single item

Return Value

Mixed

at line 388
boolean hasPermission(string $group, string $permission)

Checks for a specific usergroup permission

For admin permissions use the hasAdminPermission method except for cancontrolpanel and ismoderator permission

Parameters

string $group the name of the permission group
string $permission the name of the permission

Return Value

boolean

at line 415
integer fetchUserId()

Get the userid

Return Value

integer

at line 425
mixed fetchUserGroups()

Return the usergroups for this user

Return Value

mixed array of usergroupid's

at line 438
integer getPermissionsFrom(integer $groupid, integer $nodeid, integer $parentid = false)

This function finds where permissions are set for a given node.

Parameters

integer $groupid the usergroupid being checked
integer $nodeid the nodeid being checked
integer $parentid parentid- if we have this we can possibly skip a getNode call

Return Value

integer the nodeid were permissions are checked.

at line 506
int getChannelLimitPermission($permissiongroup, $permission, $nodeid, $parents = false, $parentid = false)

Checks for a specific permission in a specific channel

Parameters

$permissiongroup
$permission
$nodeid
$parents
$parentid

Return Value

int permission numeric value

at line 646
protected mixed checkModPerm(string $permissiongroup, string $permission, int $nodeid = null)

Checks to see if the user has the appropriate moderator permission from the moderators table

Parameters

string $permissiongroup
string $permission
int $nodeid (optional, if not specified, will return a list of nodes on which the user has the permission)

Return Value

mixed
  • It returns a boolean indicating if we have permission or an array with nodeids for which we have permission.

at line 716
mixed getUsergroupLimit(string $permission)

Checks for a limit-type permission in the usergroup table- e.g. maximum number of images.

Parameters

string $permission the name of the permission

Return Value

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

at line 761
boolean|integer getChannelPermission(string $permissiongroup, string $permission, int $nodeid, mixed $parents = false, int $parentid = false)

Checks for a specific permission in a specific channel

Parameters

string $permissiongroup the name of the permission group
string $permission the name of the permission
int $nodeid the channel to check. Note that we may inherit from a parent.
mixed $parents optional array of either closure table records, node table records, or integer representing the ancestor nodeid's
int $parentid optional immediate parent nodeid

Return Value

boolean|integer

at line 834
mixed getChannelLimits($nodeid, $permission = '', $parents = false)

This returns the 5 limit-type settings at the channel level- edit_time, skip_moderate, maxstartertags, maxothertags and maxtags

Parameters

$nodeid
$permission
$parents

Return Value

mixed 2 element array

at line 876
protected int|string|null getChannelIdOfNode(int|string $nodeid)

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

Parameters

int|string $nodeid

Return Value

int|string|null

at line 919
mixed getLimit($permission)

Checks for a limit-type permission- e.g. maximum number of images.

Parameters

$permission

Return Value

mixed

at line 960
bool isGloballyIgnored()

Returns whether the user is globally ignored

Return Value

bool

at line 979
bool isAdministrator()

Returns whether the user is administrator Adapted from adminfunctions.php::can_administer

Return Value

bool

at line 991
bool isSuperMod()

Returns whether the current user is a super moderator

Return Value

bool

at line 997
hasModeratorPermission($permission, $channelid = 0)

Parameters

$permission
$channelid

at line 1031
boolean hasAdminPermission(string $permission)

Checks the administrator table for individual administrator permission (all the different areas of the admin cp that they can access)

Parameters

string $permission the name of the permission

Return Value

boolean

at line 1082
mixed getReadChannels(integer $nodeid = false)

This returns a list of channels where this user can read, and an array where they can't.

Parameters

integer $nodeid limit to this channel

Return Value

mixed array of ('can'=> array of integers, 'cannot' => array of integers)

at line 1192
mixed getCanModerate()

This returns a list of channels where this user can moderate, and an array where they can't.

Return Value

mixed array of ('can'=> array of integers, 'cannot' => array of integers)

at line 1343
isForumModerator()

at line 1360
isModerator()

at line 1389
canUpload(int $size, string $extension, int $nodeid = false)

Checks to see if a user can upload a file for attachment

Parameters

int $size size of the file
string $extension file extension
int $nodeid channelid to which this will be attached. Optional

at line 1406
bool isSuperAdmin()

check whether current user is super admin. Don't allow request for a different user.

Return Value

bool

at line 1418
getModeratorPerms(mixed $node)

This returns an array of moderator or moderator-like permissions

Parameters

mixed $node a node record. has at least nodeid and contenttypeid. May include channelid or parentid.

@return     mixed   array of string -> integer values;

at line 1557
mixed getCanCreate(int $nodeid)

Lists the content types the current user can create at a node.

Parameters

int $nodeid the nodeid to be checked

Return Value

mixed array of contenttypes

at line 2008
protected checkChannelSettings(mixed $channel, mixed $parent)

For posts to blog-type channel, checks allow_post if applicable

Parameters

mixed $channel the channel to which we are posting
mixed $parent the parent of this potential post

at line 2039
mixed getAllChannelAccess()

This returns an array with the access for this user, reflecting usergroup and groupintopic permissions.

$param boolean whether to force reload

Return Value

mixed Each element contains three arrays: canview, canaccess, and selfonly. Each is an array of nodeids where the user has that access

at line 2208
rebuildGroupAccess()

Convenience- since userContext is available everywhere, this calls permissionContext->public rebuildGroupAccess

at line 2220
getUserLevel()

Gets user hierarchy level It is used when ignoring a user, the hierarchy is as follows (VBV-1503):

SuperAdmin -> Admin -> Super moderator -> Moderator -> Regular user

at line 2254
mixed fetchPermsForChannels($channels)

Fetches an array of permissions for a list of channels, which will be passed in slightly adjusted form to the getFullContent methods

@param mixed array of integers

Parameters

$channels

Return Value

mixed array of permission. parentid => permissions. permissions are either 0/1 or array of string => 0/1

at line 2349
mixed getAttachmentPermissions(string $extension, int $nodeid = false)

Check for attachment limits/permissions for a given extension.

Note: This is only constrained to the attachmenttype and attachmentpermission tables. The create permissions for all attachments are handled in the channels. TODO: Make this part of the channel permissions

Parameters

string $extension the extension to check for
int $nodeid node id. in case of groupInTopic

Return Value

mixed false if the extension is not allowed or the user doesn't have permission to use it. Otherwise an array of limits.