function farm_asset_permission in farmOS 7
Implements hook_permission().
File
- modules/
farm/ farm_asset/ farm_asset.module, line 31 - Farm asset - A farm asset entity type.
Code
function farm_asset_permission() {
$perms = array(
'administer farm_asset module' => array(
'title' => t('Administer farm asset module'),
'description' => t('Gives full access to everything in the farm asset module.'),
'restrict access' => TRUE,
),
'administer farm_asset types' => array(
'title' => t('Administer farm asset types'),
'restrict access' => TRUE,
),
'view farm assets' => array(
'title' => t('View farm assets'),
'description' => t('Allows users to view the full list of farm assets.'),
),
);
// Add permissions for each farm_asset type.
foreach (farm_asset_types() as $farm_asset_type) {
$type = $farm_asset_type->type;
$ops = array(
'view',
'edit',
'delete',
);
$scopes = array(
'any',
'own',
);
$perms += array(
"create {$type} farm assets" => array(
'title' => t('Create new %type_name farm assets', array(
'%type_name' => $farm_asset_type->label,
)),
),
);
foreach ($ops as $op) {
foreach ($scopes as $scope) {
$perms += array(
"{$op} {$scope} {$type} farm assets" => array(
'title' => drupal_ucfirst($op) . ' ' . $scope . ' ' . t('%type_name farm assets', array(
'%type_name' => $farm_asset_type->label,
)),
),
);
}
}
}
return $perms;
}