class Access

Class that handles all access authorisation routines.

Methods

static  void
clearStatics()

Method for clearing static caches.

static  boolean|null
check( integer $userId, string $action, integer|string $assetKey = null, boolean $preload = true)

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

static  boolean
preload( integer|string|array $assetTypes = 'components', boolean $reload = false)

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

static  boolean
checkGroup( integer $groupId, string $action, integer|string $assetKey = null, boolean $preload = true)

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

static  Rules
getAssetRules( integer|string $assetKey, boolean $recursive = false, boolean $recursiveParentAsset = true, boolean $preload = true)

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.

static  string
getExtensionNameFromAsset( integer|string $assetKey)

Method to get the extension name from the asset name.

static  string
getAssetType( integer|string $assetKey)

Method to get the asset type from the asset name.

static  string
getGroupTitle( integer $groupId)

Method to return the title of a user group

static  array
getGroupsByUser( integer $userId, boolean $recursive = true)

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.

static  array
getUsersByGroup( integer $groupId, boolean $recursive = false)

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

static  array
getAuthorisedViewLevels( integer $userId)

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

static  array
getActions( string $component, string $section = 'component')

Method to return a list of actions for which permissions can be set given a component and section.

static  boolean|array
getActionsFromFile( string $file, string $xpath = '/access/section[@name=\'component\']/')

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

static  boolean|array
getActionsFromData( string|SimpleXMLElement $data, string $xpath = '/access/section[@name=\'component\']/')

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

Details

static void clearStatics()

Method for clearing static caches.

Return Value

void

static boolean|null check( integer $userId, string $action, integer|string $assetKey = null, boolean $preload = true)

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

Parameters

integer $userId Id of the user for which to check authorisation.
string $action The name of the action to authorise.
integer|string $assetKey The asset key (asset id or asset name). null fallback to root asset.
boolean $preload Indicates whether preloading should be used.

Return Value

boolean|null True if allowed, false for an explicit deny, null for an implicit deny.

static boolean preload( integer|string|array $assetTypes = 'components', boolean $reload = false)

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

Parameters

integer|string|array $assetTypes The type or name of the asset (e.g. 'comcontent.article', 'commenus.menu.2'). Also accepts the asset id. An array of asset type or a special 'components' string to load all component assets.
boolean $reload Set to true to reload from database.

Return Value

boolean True on success.

static boolean checkGroup( integer $groupId, string $action, integer|string $assetKey = null, boolean $preload = true)

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

Parameters

integer $groupId The path to the group for which to check authorisation.
string $action The name of the action to authorise.
integer|string $assetKey The asset key (asset id or asset name). null fallback to root asset.
boolean $preload Indicates whether preloading should be used.

Return Value

boolean True if authorised.

static Rules getAssetRules( integer|string $assetKey, boolean $recursive = false, boolean $recursiveParentAsset = true, boolean $preload = true)

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.

Parameters

integer|string $assetKey The asset key (asset id or asset name). null fallback to root asset.
boolean $recursive True to return the rules object with inherited rules.
boolean $recursiveParentAsset True to calculate the rule also based on inherited component/extension rules.
boolean $preload Indicates whether preloading should be used.

Return Value

Rules Rules object for the asset.

static string getExtensionNameFromAsset( integer|string $assetKey)

Method to get the extension name from the asset name.

Parameters

integer|string $assetKey The asset key (asset id or asset name).

Return Value

string The extension name (ex: com_content).

static string getAssetType( integer|string $assetKey)

Method to get the asset type from the asset name.

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

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

Parameters

integer|string $assetKey The asset key (asset id or asset name).

Return Value

string The asset type (ex: com_content.article).

static string getGroupTitle( integer $groupId)

Method to return the title of a user group

Parameters

integer $groupId Id of the group for which to get the title of.

Return Value

string Tthe title of the group

static array getGroupsByUser( integer $userId, boolean $recursive = true)

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.

Parameters

integer $userId Id of the user for which to get the list of groups.
boolean $recursive True to include inherited user groups.

Return Value

array List of user group ids to which the user is mapped.

static array getUsersByGroup( integer $groupId, boolean $recursive = false)

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

Parameters

integer $groupId The group Id
boolean $recursive Recursively include all child groups (optional)

Return Value

array

static array getAuthorisedViewLevels( integer $userId)

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

Parameters

integer $userId Id of the user for which to get the list of authorised view levels.

Return Value

array List of view levels for which the user is authorised.

static array getActions( string $component, string $section = 'component')

Method to return a list of actions for which permissions can be set given a component and section.

Parameters

string $component The component from which to retrieve the actions.
string $section The name of the section within the component from which to retrieve the actions.

Return Value

array List of actions available for the given component and section.

static boolean|array getActionsFromFile( string $file, string $xpath = '/access/section[@name=\'component\']/')

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

Parameters

string $file The path to the XML file.
string $xpath An optional xpath to search for the fields.

Return Value

boolean|array False if case of error or the list of actions available.

static boolean|array getActionsFromData( string|SimpleXMLElement $data, string $xpath = '/access/section[@name=\'component\']/')

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

Parameters

string|SimpleXMLElement $data The XML string or an XML element.
string $xpath An optional xpath to search for the fields.

Return Value

boolean|array False if case of error or the list of actions available.