You are here

function hook_farm_access_perms in farmOS 7

Defines farm access permissions. Use farm_access_entity_perms() to generate permissions for common entity types.

Parameters

string $role: The role name to add permissions for.

Return value

array Returns an array of farm access permissions.

See also

farm_access_entity_perms()

Related topics

22 functions implement hook_farm_access_perms()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

farm_access_farm_access_perms in modules/farm/farm_access/farm_access.module
Implements hook_farm_access_perms().
farm_api_farm_access_perms in modules/farm/farm_api/farm_api.farm_access.inc
Implements hook_farm_access_perms().
farm_area_farm_access_perms in modules/farm/farm_area/farm_area.module
Implements hook_farm_access_perms().
farm_area_generate_farm_access_perms in modules/farm/farm_area/farm_area_generate/farm_area_generate.module
Implements hook_farm_access_perms().
farm_area_import_farm_access_perms in modules/farm/farm_area/farm_area_import/farm_area_import.module
Implements hook_farm_access_perms().

... See full list

2 invocations of hook_farm_access_perms()
farm_access_available_perms in modules/farm/farm_access/farm_access.module
Gets a list of all available farm permissions.
farm_access_modules_enabled in modules/farm/farm_access/farm_access.module
Implements hook_modules_enabled().

File

modules/farm/farm_access/farm_access.api.php, line 84
Hooks provided by farm_access.

Code

function hook_farm_access_perms($role) {

  // Grant the 'view mymodule records' permission to all roles.
  $perms[] = 'view mymodule records';

  // Load the list of farm roles.
  $roles = farm_access_roles();

  // Grant the 'configure mymodule' permission to roles with config access.
  if (!empty($roles[$role]['access']['config'])) {
    $perms[] = 'configure mymodule';
  }
  return $perms;
}