Permission model.
Models don't share that much, so most implementations will be adding methods onto this class. This class simply provides helper methods for common actions.
| package | XenForo_Permissions |
|---|
__construct()
Use create() statically unless you know what you're doing.
| inherited_from | \XenForo_Model::__construct() |
|---|
addFetchOptionJoin(array $fetchOptions, integer $join)
Join should be one of the constants.
| inherited_from | \XenForo_Model::addFetchOptionJoin() |
|---|
array
integer
addPositionLimit(string $table, integer $limit, integer $offset, string $column) : string
It no limit value is specified, nothing will be returned.
This must be added within a WHERE clause. If a clause is required, it will begin with "AND", so ensure there is a condition before it.
| inherited_from | \XenForo_Model::addPositionLimit() |
|---|
stringName of the table alias to prefix. May be blank for no table reference.
integerNumber of records to limit to; ignored if <= 0
integerOffset from the start of the records. 0+
stringName of the column that is storing the position
stringPosition limit clause if neededappendPermissionsAddOnXml(\DOMElement $rootNode, string $addOnId)
stringAdd-on ID to be exported
assertValidCutOffOperator(string $operator)
| inherited_from | \XenForo_Model::assertValidCutOffOperator() |
|---|
string
buildPermissionCacheForCombination(array $permissionsGrouped, array $systemEntries, array $groupEntries, array $userEntries, array $basePermissions, array $preDependencyCache) : array
arrayList of system-wide permission entries
arrayList of user-specific permission entries (if any)
arrayBase set of permissions to use as a starting point
arrayOutputs the permissions before dependency checks - useful for hierarchies
arrayPermission cache detailscanWritePermissionsDevelopmentFile($fileName) : boolean
If the file does not exist, it checks whether the parent directory is writable.
booleancanonicalizePermissionCache(array $cache) : array
This is the actual representation to be used externally.
arrayPermission cache info with allow/unset/deny/etc values
arrayPermission cache with true/false valuesclearContentPermissionTypeHandlers()
create(string $class) : \XenForo_Model
The class must exist or be autoloadable or an exception will be thrown.
| inherited_from | \XenForo_Model::create() |
|---|
stringClass to load
deletePermissionCombination(integer $combinationId)
integer
deletePermissionsForAddOn(string $addOnId)
string
fetchAllKeyed(string $sql, string $key, mixed $bind, string $nullPrefix) : array
The 'key' parameter provides the column name with which to key the result. For example, calling fetchAllKeyed('SELECT item_id, title, date FROM table', 'item_id') would result in an array keyed by item_id: [$itemId] => array('item_id' => $itemId, 'title' => $title, 'date' => $date)
Note that the specified key must exist in the query result, or it will be ignored.
| inherited_from | \XenForo_Model::fetchAllKeyed() |
|---|
stringSQL to execute
stringColumn with which to key the results array
mixedParameters for the SQL
stringIf the key is null, prefix the counter with this
arrayfindOrCreatePermissionCombination(integer $userId, array $userGroupIds, boolean $buildOnCreate) : integer
The user ID should only be provided if permissions exist for that user.
integerUser ID, if there are user-specific permissions
arrayList of user group IDs
booleanBuild permission combo cache if created
integerPermission combination IDfindOrCreatePermissionCombinationFromUser(array $user, boolean $buildOnCreate, boolean $checkForUserPerms) : integer
arrayUser info
booleanBuild the permission combo cache if it must be created
booleanIf false, assumes there are no user perms (optimization)
integerPermission combination IDgetAllContentPermissionEntriesByTypeGrouped($permissionType) : array
This is generally only needed for internal cache rebuilds.
Note that entries with a value of "unset" will not be returned by this.
arrayFormat: ['users'][user id][content id][group][permission] => permission value;
['userGroups'][user group id][content id][group][permission] => permission value;
['system'][content id][group][permission] => permission valuegetAllContentPermissionEntriesForUserCollectionGrouped(string $contentTypeId, integer $contentId, integer $userGroupId, integer $userId) : array
string
integer
integer
integer
arrayFormat: [permission_group_id][permission_id] => permission_infogetAllGlobalPermissionEntriesForUserCollectionGrouped(integer $userGroupId, integer $userId) : array
integer
integer
arrayFormat: [permission_group_id][permission_id] => permission_infogetAllPermissionCombinations() : array
Note that this function does not return the cached permission data!
arrayFormat: [] => permission combo info (id, user, user group list)getAllPermissionEntriesGrouped() : array
This is generally only needed for internal cache rebuilds.
Note that entries with a value of "unset" will not be returned by this.
arrayFormat: ['users'][user id][group][permission] => permission value;
['userGroups'][user group id][group][permission] => permission value;
['system'][group][permission] => permission valuegetAllPermissionGroups() : array
arrayFormat: [] => permission group infogetAllPermissionInterfaceGroups() : array
arrayFormat: [interface group id] => interface group infogetAllPermissions() : array
Proper display order cannot be gained unless the permissions are grouped into their interface groups.
arrayFormat: [] => permission infogetAllPermissionsGrouped() : array
This does not return based on interface groups.
arrayFormat: [permission group id][permission id] => permission infogetAllPermissionsWithValues(integer $userGroupId, integer $userId) : array
integer
integer
arrayFormat: [] => permission info, permission_value/permission_value_int from entry,
value/value_int for effective valuegetConditionsForClause(array $sqlConditions) : string
This always returns a value that can be used in a clause such as WHERE.
| inherited_from | \XenForo_Model::getConditionsForClause() |
|---|
array
stringgetContentPermissionEntryById(integer $id) : array | false
integer
arrayfalsePermission entry infogetContentPermissionTypeHandlers() : array
arrayFormat: [permission type id] => XenForo_ContentPermission_Interface objectgetContentPermissionTypes() : array
arrayFormat: [content type] => permission handler class namegetContentPermissionsWithValues(string $contentTypeId, integer $contentId, mixed | array $permissionGroups, integer $userGroupId, integer $userId) : array
string
integer
mixedarrayIf array, only pulls permissions from the specified groups; otherwise, all
integer
integer
arrayFormat: [] => permission info, permission_value/permission_value_int from entry,
value/value_int for effective valuegetContentTypeField(string $contentType, string $fieldName) : string | false
| inherited_from | \XenForo_Model::getContentTypeField() |
|---|
string
string
stringfalse
getContentTypesWithField(string $fieldName) : array
| inherited_from | \XenForo_Model::getContentTypesWithField() |
|---|
string
arrayFormat: [content type] => field valuegetDefaultPermission() : array
arraygetDefaultPermissionGroup() : array
arraygetDefaultPermissionInterfaceGroup() : array
arraygetDefaultPermissionsForInterface() : array
arrayFormat: [interface group id] => interface group info + key:permissions => [] => permission info with effective valuegetInterfaceGroupedPermissions(array $permissions, array $interfaceGroups) : array
array
array
arrayFormat: [interface group id] => interface group info + key:permissions => [] => permission info with effective valuegetModelFromCache(string $class) : \XenForo_Model
If it does not exist, it will be instantiated.
| inherited_from | \XenForo_Model::getModelFromCache() |
|---|
stringName of the class to load
getOrderByClause(array $choices, array $fetchOptions, string $defaultOrderSql) : string
| inherited_from | \XenForo_Model::getOrderByClause() |
|---|
array
array
string
stringOrder by clause or empty stringgetPermissionAndInterfaceGroupedPermissions(array $permissions, array $interfaceGroups) : array
This is needed when a system requires all permissions in one or more permission groups for display, but keeping the permissions together based on permission group.
array
array
arrayFormat: [permission group id][interface group id] => interface group info, with key permissions => permissions in interface groupgetPermissionByGroupAndId(string $permissionGroupId, string $permissionId) : array | false
Both the group and the permission ID are required for unique identification.
string
string
arrayfalse
getPermissionChoices(string $type, boolean $contentSpecific) : array
stringType of permission. Values: system, user, userGroup
booleanTrue if dealing with content-specific permissions.
arrayKey-value pairs of choices for this type of permissiongetPermissionCombinationById(integer $combinationId) : false | array
integer
falsearrayPermission combination if, it it existsgetPermissionCombinationByUserId(integer $userId) : false | array
Returns false if no user ID is specified.
integer
falsearrayPermission combo infogetPermissionCombinationIdByUserRole(integer $userId, array $userGroupIds) : integer | false
integer
array
integerfalseCombination ID or falsegetPermissionCombinationsByUserGroupId(integer $userGroupId) : array
integer
arrayFormat: [permission_combination_id] => permission combination infogetPermissionEntryById(integer $id) : array | false
integer
arrayfalsePermission entry infogetPermissionGroupById(string $permissionGroupId) : array | false
string
arrayfalse
getPermissionGroupMasterTitlePhraseValue(string $permissionGroupId) : string
string
stringgetPermissionGroupNames() : array
arrayFormat: [group id] => namegetPermissionGroupTitlePhraseName(string $permissionGroupId) : string
string
stringgetPermissionGroupsByAddOn(string $addOnId) : array
string
arrayFormat: [] => permission group infogetPermissionGroupsByIds(array $groupIds) : array
array
arrayFormat: [section id] => infogetPermissionInterfaceGroupById(string $interfaceGroupId) : array | false
string
arrayfalse
getPermissionInterfaceGroupMasterTitlePhraseValue(string $interfaceGroupId) : string
string
stringgetPermissionInterfaceGroupNames() : array
arrayFormat: [interface group id] => namegetPermissionInterfaceGroupTitlePhraseName(string $interfaceGroupId) : string
string
stringgetPermissionInterfaceGroupsByAddOn(string $addOnId) : array
string
arrayFormat: [] => permission interface group infogetPermissionInterfaceGroupsByIds(array $groupIds) : array
array
arrayFormat: [section id] => infogetPermissionMasterTitlePhraseValue(string $permissionGroupId, string $permissionId) : string
string
string
stringgetPermissionTitlePhraseName(string $permissionGroupId, string $permissionId) : string
string
string
stringgetPermissionsByAddOn(string $addOnId) : array
string
arrayFormat: [] => permission infogetPermissionsByPairs(array $pairs) : array
Key 0 must be the group and key 1 must be the permission.
arrayFormat: [] => [0 => group id, 1 => permission id]
arrayArray of permissions grouped: [group id][permission id] => infogetPermissionsDevelopmentFileName() : string
stringgetUserCollectionContentPermissionsForGroupedInterface(string $contentTypeId, integer $contentId, mixed | string | array $permissionGroups, integer $userGroupId, integer $userId) : array
string
integer
mixedstringarrayIf array, only those permission groups; if string, only that group; otherwise, all
integer
integer
arrayFormat: [permission group id][interface group id] => interface group info, with key permissions => permissions in interface groupgetUserCollectionContentPermissionsForInterface(string $contentTypeId, integer $contentId, mixed | string | array $permissionGroups, integer $userGroupId, integer $userId) : array
string
integer
mixedstringarrayIf array, only those permission groups; if string, only that group; otherwise, all
integer
integer
arrayFormat: [interface group id] => interface group info + key:permissions => [] => permission info with effective valuegetUserCollectionPermissionsForInterface(integer $userGroupId, integer $userId) : array
integer
integer
arrayFormat: [interface group id] => interface group info + key:permissions => [] => permission info with effective valuegetUserCombinationsWithContentPermissions($contentType, $contentId)
getUsersWithContentUserPermissions($contentType, $contentId)
getUsersWithGlobalUserPermissions() : array
array[user id] => infogetViewNodeContentPermission(integer $nodeId, integer $userGroupId, integer $userId) : array
This permission is a bit weird since it doesn't fit in the expected groups, so it has to be handled specially.
integer
integer
integer
arrayimportPermissionsAddOnXml(\SimpleXMLElement $xml, string $addOnId)
stringAdd-on to import for
importPermissionsDevelopmentXml(string $fileName)
stringFile to read the XML from
limitQueryResults(string $query, integer $limit, integer $offset) : string
If the limit value is 0 or less, no clause is applied.
| inherited_from | \XenForo_Model::limitQueryResults() |
|---|
stringSQL query to run
integerNumber of records to limit to; ignored if <= 0
integerOffset from the start of the records. 0+
stringQuery with limit applied if necessaryprepareLimitFetchOptions(array $fetchOptions) : array
Includes: limit, offset, page, and perPage.
| inherited_from | \XenForo_Model::prepareLimitFetchOptions() |
|---|
arrayUnprepared options
arrayLimit options; keys: limit, offsetpreparePermission(array $permission) : array
array
arraypreparePermissionGroup(array $permissionGroup) : array
array
arraypreparePermissionGroups(array $permissionGroups) : array
arrayFormat: [] => permission group info
arraypreparePermissionInterfaceGroup(array $interfaceGroup) : array
array
arraypreparePermissionInterfaceGroups(array $interfaceGroups) : array
arrayFormat: [] => interface group info
arraypreparePermissions(array $permissions) : array
arrayFormat: [] => permission info
arraypreparePermissionsGrouped(array $permissions) : array
arrayFormat: [group id][] => permission info
arrayPrepared arrayprepareStateLimitFromConditions(array $fetchOptions, string $table, string $stateField, string $userField) : string
Looks for keys "deleted" and "moderated".
| inherited_from | \XenForo_Model::prepareStateLimitFromConditions() |
|---|
array
stringName of the table to prefix the state and user fields with
stringName of the field that holds the state
stringName of the field that holds the user ID
stringSQL condition to limit staterebuildContentPermissionCombination(array $combination, array $permissionsGrouped, array $permCache)
This function will rebuild permissions for all types of content and all pieces of content for that type.
arrayArray of combination information
arrayList of permissions, grouped
arrayGlobal permission cache for this combination, with values of unset, etc. May be modified by ref.
rebuildPermissionCache(integer $maxExecution, integer $startCombinationId) : boolean | integer
integerLimit execution time
integerIf specified, starts the rebuild at the specified combination ID
booleanintegerTrue when totally complete; the next combination ID to start with otherwiserebuildPermissionCacheForUserGroup(integer $userGroupId) : boolean
integer
booleanTrue on successrebuildPermissionCacheForUserId(integer $userId) : boolean
A combination with this user ID must exist for a rebuild to be triggered.
integer
booleanTrue on success (false if no cache needs to be updated)rebuildPermissionCombination(array $combination, array $permissionsGrouped, array $entries) : array
arrayPermission combination info
arrayList of valid permissions, grouped
arrayList of permission entries, with keys system/users/userGroups
arrayPermission cache for this combination.resetLocalCacheData($name)
This can be used if you know when some cached data has expired.
| inherited_from | \XenForo_Model::resetLocalCacheData() |
|---|
setAllowCachedRead(boolean $allowCachedRead)
This may be controllable on an individual level basis, if the implementation allows it.
| inherited_from | \XenForo_Model::setAllowCachedRead() |
|---|
boolean
setLocalCacheData(string $name, $value)
This should only be used if you know what you're doing or for testing purposes!
Note that you cannot get the existing data via the public interface. If you think you need the set data, use a new object. It defaults to empty. :)
| inherited_from | \XenForo_Model::setLocalCacheData() |
|---|
string
standardizeNodePermissionsAndUserId(integer $nodeId, array | null $permissions, integer | null $userId)
If an invalid permission set or user ID is provided, the current visitor's will be used.
| inherited_from | \XenForo_Model::standardizeNodePermissionsAndUserId() |
|---|
integerNode permissions are for
arraynullPermissions for node or null to use current visitor's permissions
integernullUser permissions belong to or null to use current visitor
standardizePermissionCombinationIdAndUserId(integer | null $permissionCombinationId, integer | null $userId)
If null, users current visitor's values.
| inherited_from | \XenForo_Model::standardizePermissionCombinationIdAndUserId() |
|---|
integernullPermission combination ID or null to use current visitor
integernullUser permissions belong to or null to use current visitor
standardizePermissionsAndUserId(array | null $permissions, integer | null $userId)
If an invalid permission set or user ID is provided, the current visitor's will be used.
| inherited_from | \XenForo_Model::standardizePermissionsAndUserId() |
|---|
arraynullGlobal pPermissions or null to use current visitor's permissions
integernullUser permissions belong to or null to use current visitor
standardizeViewingUserReference(array $viewingUser)
This array must contain all basic user info (preferably all user info) and include global permissions in a "permissions" key. If not an array or missing a user_id, the visitor's values will be used.
| inherited_from | \XenForo_Model::standardizeViewingUserReference() |
|---|
arraynull
standardizeViewingUserReferenceForNode(integer $nodeId, array $viewingUser, array $nodePermissions)
| inherited_from | \XenForo_Model::standardizeViewingUserReferenceForNode() |
|---|
integer
arraynullViewing user; if null, use visitor
arraynullPermissions for this node; if null, use visitor's
unserializePermissionsInList(array $items, string $serializedKey, string $targetKey) : array
| inherited_from | \XenForo_Model::unserializePermissionsInList() |
|---|
arrayList of items
stringKey where serialized permissions are
stringKey where unserialized permissions will go
arrayList of items with permissions unserializedupdateContentPermissionsForUserCollection(array $newPermissions, string $contentTypeId, integer $contentId, integer $userGroupId, integer $userId) : boolean
arrayPermissions to update, format: [permission_group_id][permission_id] => value
string
integer
integer
integer
booleanupdateGlobalPermissionsForUserCollection(array $newPermissions, integer $userGroupId, integer $userId) : boolean
arrayPermissions to update, format: [permission_group_id][permission_id] => value
integer
integer
booleanupdateUserPermissionCombination(integer | array $userId, boolean $buildOnCreate, boolean $checkForUserPerms) : false | integer
integerarrayInteger user ID or array of user info
booleanIf true, the permission cache for a combination will be built if it's created
booleanIf false, doesn't look for user perms. Mostly an optimization
falseintegerCombination ID for the user if possibleupdateUserPermissionCombinations(array $userIds, boolean $buildOnCreate)
array
boolean
_getCache(boolean $forceCachedRead) : \Zend_Cache_Core | \Zend_Cache_Frontend | false
If cache reads are disabled, this will return false.
| inherited_from | \XenForo_Model::_getCache() |
|---|
booleanIf true, the global "allow cached read" value is ignored
\Zend_Cache_Core\Zend_Cache_Frontendfalse
_getDb() : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_Model::_getDb() |
|---|
\Zend_Db_Adapter_Abstract_getLocalCacheData(string $name) : mixed
| inherited_from | \XenForo_Model::_getLocalCacheData() |
|---|
string
mixed_getMergedPermissionPriorityValue(string | int $existingValue, string | int $newValue, string $permissionType) : string | int
stringintExisting value for the permission (int, or unset/allow/etc)
stringintNew value for the permission (int, unset/allow/etc)
string"integer" or "flag"
stringintEffective value for the permission, using the priority list_getPermissionPriorityValueFromList(string $existingValue, array $permissionEntries, string $permissionType, string $permissionGroupId, string $permissionId, string $dependPermissionId) : string
For flag permissions, higher priority (lower numbers) will take priority over the already existing values. For integers, -1 (unlimited) is highest priority; otherwise, higher numbers are better.
stringExisting permission value (strings like unset, allow, deny, etc)
arrayList of permission entries to look through. First key is group, second is permission ID.
stringType of permission (integer or flag)
stringPermission Group ID to check
stringPermission ID to check
stringThe permission this one depends on; if this permission is not active, this permission is ignored
stringNew priority value_prepareCombinationUserGroupList(array $userGroupIds) : string
arrayList of user group IDs
stringComma delimited, sorted string of user group IDs_sanitizeUserIdAndUserGroupForQuery(integer $userGroupId, integer $userId)
Only one of the user group and user ID may be specified; if both are specified, the user ID takes precedence. If neither are specified, this relates to system-wide permissions.
integerModified by reference
integerModified by reference
_updatePermissionsForUserCollection(array $newPermissions, array $existingEntries, integer $userGroupId, integer $userId, string $dwName, array $bulkData) : boolean
arrayPermissions to update, format: [permission_group_id][permission_id] => value
arrayExisting permission entries for this collection
integer
integer
stringName of the data writer to use to insert/update data
arrayBulk data to give to the datawriter
boolean$_allowCachedRead : boolean
If not, it should be retrieved from the source.
| inherited_from | \XenForo_Model::$$_allowCachedRead |
|---|
$_cache : \Zend_Cache_Core | \Zend_Cache_Frontend
| inherited_from | \XenForo_Model::$$_cache |
|---|
$_db : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_Model::$$_db |
|---|
$_localCacheData : array
This data is generally treated as canonical, even if {$_allowCachedRead} is false.
| inherited_from | \XenForo_Model::$$_localCacheData |
|---|
$_modelCache : array
| inherited_from | \XenForo_Model::$$_modelCache |
|---|