Back to Access class

Method checkGroup

public static bool
checkGroup
(mixed $groupId, mixed $action, mixed $assetKey = null, mixed $preload = true)
Method to check if a group is authorised to perform an action, optionally on an asset.
Parameters
  • int $groupId The path to the group for which to check authorisation.
  • string $action The name of the action to authorise.
  • int|string $assetKey The asset key (asset id or asset name). null fallback to root asset.
  • bool $preload Indicates whether preloading should be used.
Returns
  • bool True if authorised.
Since
  • 1.7.0
Class: Access
Project: Joomla

Method checkGroup - Source code

/**
 * Method to check if a group is authorised to perform an action, optionally on an asset.
 *
 * @param   integer         $groupId   The path to the group for which to check authorisation.
 * @param   string          $action    The name of the action to authorise.
 * @param   integer|string  $assetKey  The asset key (asset id or asset name). null fallback to root asset.
 * @param   boolean         $preload   Indicates whether preloading should be used.
 *
 * @return  boolean  True if authorised.
 *
 * @since   1.7.0
 */
public static function checkGroup($groupId, $action, $assetKey = null, $preload = true)
{
    // Sanitize input.
    $groupId = (int) $groupId;
    $action = strtolower(preg_replace('#[\\s\\-]+#', '.', trim($action)));
    return self::getAssetRules($assetKey, true, true, $preload)->allow($action, self::getGroupPath($groupId));
}