function units_ui_entity_access in Units of Measurement 7
Same name and namespace in other branches
- 7.2 units_ui.module \units_ui_entity_access()
Access callback for entity types 'units_measure' and 'units_unit'.
This access callback overrides one defined in units.module once units_ui module becomes enabled. This access callback respects permissions defined in units_ui module.
Parameters
string $op: The operation being performed. One of 'view', 'update', 'create' or 'delete'
object $entity: Entity object on which the operation is requested to be performed
object $account: Fully loaded user object of the account who requests to perform the operation
string $entity_type: Entity type on which the operation is requested to be performed
Return value
bool Whether access has been granted
1 string reference to 'units_ui_entity_access'
- units_ui_entity_info_alter in ./
units_ui.module - Implements hook_entity_info_alter().
File
- ./
units_ui.module, line 127 - Provide UI for managing available units and conversions between them.
Code
function units_ui_entity_access($op, $entity, $account, $entity_type) {
switch ($entity_type) {
case 'units_measure':
$perm = 'administer measures';
break;
case 'units_unit':
$perm = 'administer units';
break;
}
if (!isset($perm)) {
// Seems like this access callback is triggered on an unexpected entity
// type.
return FALSE;
}
switch ($op) {
case 'view':
return TRUE;
break;
case 'update':
case 'create':
case 'delete':
return user_access($perm, $account);
break;
}
// Just in case, fallback on negative response. Although normally this
// statement should never be reached.
return FALSE;
}