function eck_permission in Entity Construction Kit (ECK) 7
Same name and namespace in other branches
- 7.3 eck.permissions.inc \eck_permission()
- 7.2 eck.module \eck_permission()
Implements hook_permission().
A pretty through set of permission you can set permissiona at each level: entity_type, bundle, entity and for each action of the CRUD
File
- ./
eck.module, line 91 - ENTITY CONSTRUCTION KIT
Code
function eck_permission() {
module_load_include('inc', 'eck', 'eck.entity_type');
module_load_include('inc', 'eck', 'eck.bundle');
$perms = array();
$perms['administer entity types'] = array(
'title' => t('Administer Entity Types'),
'restrict access' => TRUE,
);
$perms['add entity types'] = array(
'title' => t('Add Entity Types'),
'restrict access' => TRUE,
);
foreach (eck__entity_type__load() as $entity_type) {
foreach (array(
'administer' => 'Administer',
'add' => "Add",
) as $op => $op_label) {
$perms["{$op} {$entity_type->name} bundles"] = array(
'title' => "{$op_label} {$entity_type->label} Bundles",
);
}
foreach (eck__bundle__load($entity_type->name) as $bundle) {
foreach (array(
'administer' => 'Administer',
'add' => "Add",
'view' => 'View',
'edit' => 'Edit',
'delete' => 'Delete',
) as $op => $op_label) {
$perms["{$op} {$entity_type->name} {$bundle->name} entities"] = array(
'title' => "{$op_label} {$entity_type->label} {$bundle->label} Entities",
);
}
}
}
return $perms;
}