Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe Access

Fonctions membres publiques statiques

static clearStatics ()
 
static check ($userId, $action, $assetKey=null, $preload=true)
 
static preload ($assetTypes='components', $reload=false)
 
static checkGroup ($groupId, $action, $assetKey=null, $preload=true)
 
static getAssetRules ($assetKey, $recursive=false, $recursiveParentAsset=true, $preload=true)
 
static getExtensionNameFromAsset ($assetKey)
 
static getAssetType ($assetKey)
 
static getGroupTitle ($groupId)
 
static getGroupsByUser ($userId, $recursive=true)
 
static getUsersByGroup ($groupId, $recursive=false)
 
static getAuthorisedViewLevels ($userId)
 
static getActionsFromFile ($file, $xpath="/access/section[@name='component']/")
 
static getActionsFromData ($data, $xpath="/access/section[@name='component']/")
 

Fonctions membres protégées statiques

static getAssetAncestors ($assetType, $assetId)
 
static preloadPermissions ($assetType, $reload=false)
 
static preloadComponents ()
 
static getGroupPath ($groupId)
 
static cleanAssetKey ($assetKey=null)
 
static getAssetId ($assetKey)
 
static getAssetName ($assetKey)
 

Attributs protégés statiques

static $viewLevels = array()
 
static $assetRules = array()
 
static $assetRulesIdentities = array()
 
static $assetPermissionsParentIdMapping = array()
 
static $preloadedAssetTypes = array()
 
static $identities = array()
 
static $userGroups = array()
 
static $userGroupPaths = array()
 
static $groupsByUser = array()
 
static $preloadedAssets = array()
 
static $rootAssetId = null
 

Description détaillée

Class that handles all access authorisation routines.

Depuis
1.7.0

Documentation des fonctions membres

◆ check()

static check (   $userId,
  $action,
  $assetKey = null,
  $preload = true 
)
static

Method to check if a user is authorised to perform an action, optionally on an asset.

Paramètres
integer$userIdId of the user for which to check authorisation.
string$actionThe name of the action to authorise.
integer | string$assetKeyThe asset key (asset id or asset name). null fallback to root asset.
boolean$preloadIndicates whether preloading should be used.
Renvoie
boolean|null True if allowed, false for an explicit deny, null for an implicit deny.
Depuis
1.7.0

Références $userId.

Référencé par UserModel\activate(), UserController\allowEdit(), User\authorise(), UserModel\block(), UserModel\delete(), et User\save().

◆ checkGroup()

static checkGroup (   $groupId,
  $action,
  $assetKey = null,
  $preload = true 
)
static

Method to check if a group is authorised to perform an action, optionally on an asset.

Paramètres
integer$groupIdThe path to the group for which to check authorisation.
string$actionThe name of the action to authorise.
integer | string$assetKeyThe asset key (asset id or asset name). null fallback to root asset.
boolean$preloadIndicates whether preloading should be used.
Renvoie
boolean True if authorised.
Depuis
1.7.0

Référencé par GroupController\allowEdit(), LevelController\allowEdit(), UserModel\batchUser(), LevelModel\canDelete(), UserHelper\checkSuperUserInUsers(), GroupModel\delete(), DeleteUserCommand\doExecute(), RemoveUserFromGroupCommand\doExecute(), UserMessagesField\getGroups(), DebuggroupModel\getItems(), GroupparentField\getOptions(), UsergrouplistField\getOptions(), User\groups(), GroupModel\save(), ComponentModel\save(), UserModel\save(), User\save(), et LevelModel\validate().

◆ cleanAssetKey()

static cleanAssetKey (   $assetKey = null)
staticprotected

Method to clean the asset key to make sure we always have something.

Paramètres
integer | string$assetKeyThe asset key (asset id or asset name). null fallback to root asset.
Renvoie
integer|string Asset id or asset name.
Depuis
3.7.0

Références Factory\getDbo(), et null.

◆ clearStatics()

static clearStatics ( )
static

Method for clearing static caches.

Renvoie
void
Depuis
1.7.3

Références null.

Référencé par User\clearAccessRights().

◆ getActionsFromData()

static getActionsFromData (   $data,
  $xpath = "/access/section[@name='component']/" 
)
static

Method to return a list of actions from a string or from an xml for which permissions can be set.

Paramètres
string | \SimpleXMLElement$dataThe XML string or an XML element.
string$xpathAn optional xpath to search for the fields.
Renvoie
boolean|array False if case of error or the list of actions available.
Depuis
3.0.0

Références $actions, et $data.

◆ getActionsFromFile()

static getActionsFromFile (   $file,
  $xpath = "/access/section[@name='component']/" 
)
static

Method to return a list of actions from a file for which permissions can be set.

Paramètres
string$fileThe path to the XML file.
string$xpathAn optional xpath to search for the fields.
Renvoie
boolean|array False if case of error or the list of actions available.
Depuis
3.0.0

Références $xml.

Référencé par ContentHelper\getActions(), DebugHelper\getDebugActions(), RulesRule\getFieldActions(), RulesField\getInput(), ComponentsFieldsField\getOptions(), ComponentsWorkflowField\getOptions(), et ComponentsFieldgroupField\getOptions().

◆ getAssetAncestors()

static getAssetAncestors (   $assetType,
  $assetId 
)
staticprotected

Method to recursively retrieve the list of parent Asset IDs for a particular Asset.

Paramètres
string$assetTypeThe asset type, or the asset name, or the extension of the asset (e.g. 'com_content.article', 'com_menus.menu.2', 'com_contact').
integer$assetIdThe numeric asset id.
Renvoie
array List of ancestor ids (includes original $assetId).
Depuis
1.6

Références $assetId, et $id.

◆ getAssetId()

static getAssetId (   $assetKey)
staticprotected

Method to get the asset id from the asset key.

Paramètres
integer | string$assetKeyThe asset key (asset id or asset name).
Renvoie
integer The asset id.
Depuis
3.7.0

Références Factory\getDbo(), et null.

◆ getAssetName()

static getAssetName (   $assetKey)
staticprotected

Method to get the asset name from the asset key.

Paramètres
integer | string$assetKeyThe asset key (asset id or asset name).
Renvoie
string The asset name (ex: com_content.article.8).
Depuis
3.7.0

Références elseif, Factory\getDbo(), et null.

◆ getAssetRules()

static getAssetRules (   $assetKey,
  $recursive = false,
  $recursiveParentAsset = true,
  $preload = true 
)
static

Method to return the Rules object for an asset. The returned object can optionally hold only the rules explicitly set for the asset or the summation of all inherited rules from parent assets and explicit rules.

Paramètres
integer | string$assetKeyThe asset key (asset id or asset name). null fallback to root asset.
boolean$recursiveTrue to return the rules object with inherited rules.
boolean$recursiveParentAssetTrue to calculate the rule also based on inherited component/extension rules.
boolean$preloadIndicates whether preloading should be used.
Renvoie
Rules Rules object for the asset.
Depuis
1.7.0
Note
The non preloading code will be removed in 4.0. All asset rules should use asset preloading.

Hashing the collected rules allows us to store only one instance of the Rules object for Assets that have the same exact permissions... it's a great way to save some memory.

Références $assetId, $db, $hash, $id, $query, $result, Log\add(), Factory\getDbo(), Profiler\getInstance(), Log\INFO, ParameterType\INTEGER, JDEBUG, name, null, et Log\WARNING.

Référencé par User\authorise(), RulesField\getInput(), et GroupModel\save().

◆ getAssetType()

static getAssetType (   $assetKey)
static

Method to get the asset type from the asset name.

For top level components this returns "components": 'com_content' returns 'components'

For other types: 'com_content.article.1' returns 'com_content.article' 'com_content.category.1' returns 'com_content.category'

Paramètres
integer | string$assetKeyThe asset key (asset id or asset name).
Renvoie
string The asset type (ex: com_content.article).
Depuis
1.6

◆ getAuthorisedViewLevels()

static getAuthorisedViewLevels (   $userId)
static

Method to return a list of view levels for which the user is authorised.

Paramètres
integer$userIdId of the user for which to get the list of authorised view levels.
Renvoie
array List of view levels for which the user is authorised.
Depuis
1.7.0

Références $authorised, $db, $groups, $id, $query, $user, $userId, elseif, Factory\getApplication(), Factory\getDbo(), et User\getInstance().

Référencé par User\getAuthorisedViewLevels(), ArticlesPopularHelper\getList(), et ArticlesCategoryHelper\getList().

◆ getExtensionNameFromAsset()

static getExtensionNameFromAsset (   $assetKey)
static

Method to get the extension name from the asset name.

Paramètres
integer | string$assetKeyThe asset key (asset id or asset name).
Renvoie
string The extension name (ex: com_content).
Depuis
1.6

◆ getGroupPath()

static getGroupPath (   $groupId)
staticprotected

Gets the parent groups that a leaf group belongs to in its branch back to the root of the tree (including the leaf group id).

Paramètres
mixed$groupIdAn integer or array of integers representing the identities to check.
Renvoie
mixed True if allowed, false for an explicit deny, null for an implicit deny.
Depuis
1.7.0

Références $groups, et UserGroupsHelper\getInstance().

◆ getGroupsByUser()

static getGroupsByUser (   $userId,
  $recursive = true 
)
static

Method to return a list of user groups mapped to a user. The returned list can optionally hold only the groups explicitly mapped to the user or all groups both explicitly mapped and inherited by the user.

Paramètres
integer$userIdId of the user for which to get the list of groups.
boolean$recursiveTrue to include inherited user groups.
Renvoie
array List of user group ids to which the user is mapped.
Depuis
1.7.0

Références $db, $query, $result, $userId, Factory\getDbo(), ComponentHelper\getParams(), ParameterType\INTEGER, et ArrayHelper\toInteger().

Référencé par GroupModel\delete(), RemoveUserFromGroupCommand\doExecute(), ComponentHelper\filterText(), User\getAuthorisedGroups(), AddUserToGroupCommand\getGroups(), RemoveUserFromGroupCommand\getGroups(), GroupModel\save(), ProfileModel\save(), et ApplicationModel\save().

◆ getGroupTitle()

static getGroupTitle (   $groupId)
static

Method to return the title of a user group

Paramètres
integer$groupIdId of the group for which to get the title of.
Renvoie
string The title of the group
Depuis
3.5

Références $db, $query, Factory\getDbo(), et ParameterType\INTEGER.

◆ getUsersByGroup()

static getUsersByGroup (   $groupId,
  $recursive = false 
)
static

Method to return a list of user Ids contained in a Group

Paramètres
integer$groupIdThe group Id
boolean$recursiveRecursively include all child groups (optional)
Renvoie
array
Depuis
1.7.0

Références $db, $query, $result, Factory\getDbo(), ParameterType\INTEGER, et ArrayHelper\toInteger().

◆ preload()

static preload (   $assetTypes = 'components',
  $reload = false 
)
static

Method to preload the Rules object for the given asset type.

Paramètres
integer | string | array$assetTypesThe type or name of the asset (e.g. 'com_content.article', 'com_menus.menu.2'). Also accepts the asset id. An array of asset type or a special 'components' string to load all component assets.
boolean$reloadSet to true to reload from database.
Renvoie
boolean True on success.
Depuis
1.6
Note
This method will return void in 4.0.

◆ preloadComponents()

static preloadComponents ( )
staticprotected

Method to preload the Rules objects for all components.

Note: This will only get the base permissions for the component. e.g. it will get 'com_content', but not 'com_content.article.1' or any more specific asset type rules.

Renvoie
array Array of component names that were preloaded.
Depuis
1.6

Références $component, $db, $query, ComponentHelper\getComponents(), Factory\getDbo(), Profiler\getInstance(), JDEBUG, null, et ParameterType\STRING.

◆ preloadPermissions()

static preloadPermissions (   $assetType,
  $reload = false 
)
staticprotected

Method to retrieve the Asset Rule strings for this particular Asset Type and stores them for later usage in getAssetRules(). Stores 2 arrays: one where the list has the Asset ID as the key and a second one where the Asset Name is the key.

Paramètres
string$assetTypeThe asset type, or the asset name, or the extension of the asset (e.g. 'com_content.article', 'com_menus.menu.2', 'com_contact').
boolean$reloadReload the preloaded assets.
Renvoie
void
Depuis
1.6

Références $db, $query, Factory\getDbo(), Profiler\getInstance(), et JDEBUG.

Documentation des champs

◆ $assetPermissionsParentIdMapping

$assetPermissionsParentIdMapping = array()
staticprotected

◆ $assetRules

$assetRules = array()
staticprotected

◆ $assetRulesIdentities

$assetRulesIdentities = array()
staticprotected

◆ $groupsByUser

$groupsByUser = array()
staticprotected

◆ $identities

$identities = array()
staticprotected

◆ $preloadedAssets

$preloadedAssets = array()
staticprotected

◆ $preloadedAssetTypes

$preloadedAssetTypes = array()
staticprotected

◆ $rootAssetId

$rootAssetId = null
staticprotected

◆ $userGroupPaths

$userGroupPaths = array()
staticprotected

◆ $userGroups

$userGroups = array()
staticprotected

◆ $viewLevels

$viewLevels = array()
staticprotected

La documentation de cette classe a été générée à partir du fichier suivant :