english/libraries/joomla/access/access.php
/**
	 * Method to check if a user is authorised to perform an action, optionally on an asset.
	 *
	 * @param   integer  $userId  Id of the user for which to check authorisation.
	 * @param   string   $action  The name of the action to authorise.
	 * @param   mixed    $asset   Integer asset id or the name of the asset as a string.  Defaults to the global asset node.
	 *
	 * @return  boolean  True if authorised.
	 *
	 * @since   11.1
	 */
Method to check if a user is authorised to perform an action, optionally on an asset.
@param   integer  $userId  Id of the user for which to check authorisation.
@param   string   $action  The name of the action to authorise.
@param   mixed    $asset   Integer asset id or the name of the asset as a string.  Defaults to the global asset node.

@return  boolean  True if authorised.


Method to check if a user is authorised to perform an action optionally on an asset . @param integer $userId Id of the user for which to check authorisation . @param string $action The name of the action to authorise . @param mixed $asset Integer asset id or the name of the asset as a string . Defaults to the global asset node . @return boolean True if authorised .
public static function check($userId, $action, $asset = null)
	{
		$userId = (int) $userId;
		$action = strtolower(preg_replace('#[\s\-]+#', '.', trim($action)));
		$asset  = strtolower(preg_replace('#[\s\-]+#', '.', trim($asset)));
		if (empty($asset)) {
			$asset = 1;
		}
		if (empty(self::$assetRules[$asset])) {
			self::$assetRules[$asset] = self::getAssetRules($asset, true);
		}
		$identities = self::getGroupsByUser($userId);
		array_unshift($identities, $userId * -1);
		return self::$assetRules[$asset]->allow($action, $identities);
	}
public static function check ( $ userId , $ action , $ asset = null ) { $ userId = ( int ) $ userId ; $ action = strtolower ( preg_replace ( '#[\s\-]+#' , '.' , trim ( $ action ) ) ) ; $ asset = strtolower ( preg_replace ( '#[\s\-]+#' , '.' , trim ( $ asset ) ) ) ; if ( empty ( $ asset ) ) { $ asset = 1 ; } if ( empty ( self :: $ assetRules [ $ asset ] ) ) { self :: $ assetRules [ $ asset ] = self :: getAssetRules ( $ asset , true ) ; } $ identities = self :: getGroupsByUser ( $ userId ) ; array_unshift ( $ identities , $ userId * - 1 ) ; return self :: $ assetRules [ $ asset ] -> allow ( $ action , $ identities ) ; }
Method to check if a user is authorised to perform an action, optionally on an asset.
Method to check if a user is authorised to perform an action optionally on an asset .
// Sanitise inputs. // Default to the root asset node. // Get the rules for the asset recursively to root if not already retrieved. // Get all groups against which the user is mapped.