Handles building content permissions for nodes.

Any type of node permission may be applied to any node. However, when calculated, only the known permissions for the specified node type are used. For example, gallery permissions could be applied to a forum, causing those permissions to be inherited to any child galleries. However, when compiled, the forum only has forum permissions.

package XenForo_Permissions

 Methods

Builds the node permissions for a user collection.

rebuildContentPermissions(\XenForo_Model_Permission $permissionModel, array $userGroupIds, integer $userId, array $permissionsGrouped, array $globalPerms) : array

Parameters

$permissionModel

\XenForo_Model_Permission

Permission model that called this.

$userGroupIds

array

List of user groups for the collection

$userId

integer

User ID for the collection, if there are custom permissions

$permissionsGrouped

array

List of all valid permissions, grouped

$globalPerms

array

The global permissions that apply to this combination

Returns

array

Allows the node data to be injected manually.

setNodeDataManually(array $nodeTypes, array $nodeTree, array $nodePermissionEntries) 

Generally only needed for testing.

Parameters

$nodeTypes

array

$nodeTree

array

$nodePermissionEntries

array

Adjusts base (inherited) content_allow values to allow only.

_adjustBasePermissionAllows(array $basePermissions) : array

This allows them to be revoked.

Parameters

$basePermissions

array

Returns

arrayAdjusted base perms

Recursively builds node tree permissions for the specified combination.

_buildNodeTreePermissions(integer $userId, array $userGroupIds, array $basePermissions, array $permissionsGrouped, integer $parentId) : array

Note that nodes will have permissions for all node types, but the final permissions for a node only include that node's permissions.

Parameters

$userId

integer

$userGroupIds

array

$basePermissions

array

Base permissions, coming from global or parent; [group][permission] => allow/unset/etc

$permissionsGrouped

array

List of all valid permissions, grouped

$parentId

integer

ID of the parent node.

Returns

arrayFinal permissions (true/false), format: [node id][permission] => value

Force a node-wide reset to override content allow settings from the permissions.

_forceNodeWideResetOverride(array $nodeWideEntries, array $nodePermissions) : array

This is used to cause reset to take priority over content allow from a parent, but not content allow from this node.

Parameters

$nodeWideEntries

array

$nodePermissions

array

Returns

arrayUpdated node permissions

Gets the node model object.

_getNodeModel() : \XenForo_Model_Node

Get node-wide permissions for this node.

_getNodeWideEntries($nodeId) : array

Parameters

$nodeId

Returns

array

Get all user group entries that apply to this node for the specified user groups.

_getUserGroupNodeEntries(integer $nodeId, array $userGroupIds) : array

Parameters

$nodeId

integer

$userGroupIds

array

Returns

array

Gets all user entries that apply to this node for the specified user ID.

_getUserNodeEntries($nodeId, $userId) : array

Parameters

$nodeId

$userId

Returns

array

Sets up the necessary information about the node tree, existing permission entries, etc.

_nodeSetup() 

Only runs if not initialized.

 Properties

 

Global perms that apply to this call to rebuild the permissions.

$_globalPerms : array

These permissions can be manipulated if necessary and the global permissions will actually be modified.

 

All node permission entries for the tree, grouped by system, user group, and user.

$_nodePermissionEntries : array

 

The node tree hierarchy.

$_nodeTree : array

This data is traversed to build permissions.

 

List of node types.

$_nodeTypes : array

 

Tracks whether we've initialized the node data.

$_nodesInitialized : boolean

Many calls to rebuildContentPermissions() may happen on one object.

 

Permission model

$_permissionModel : \XenForo_Model_Permission