function entityqueue_access in Entityqueue 7
Access callback for the entity API.
Parameters
$op: The operation being performed. One of 'view', 'update', 'create' or 'delete'.
$entity: Optionally an entity to check access for. If no entity is given, it will be determined whether access is allowed for all entities of the given type.
$account: The user to check for. Leave it to NULL to check for the global user.
$entity_type: The entity type of the entity to check for.
Return value
bool TRUE if the user has permission for $op, FALSE otherwise.
See also
2 string references to 'entityqueue_access'
- entityqueue_entityqueue_export_ui_ctools_export_ui in plugins/
ctools/ export_ui/ entityqueue_export_ui.inc - Implements HOOK_PLUGIN_ctools_export_ui().
- entityqueue_entity_info in ./
entityqueue.module - Implements hook_entity_info().
File
- ./
entityqueue.module, line 451 - Allows users to collect entities in arbitrarily ordered lists.
Code
function entityqueue_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
if (empty($account)) {
global $user;
$account = $user;
}
$administer = user_access('administer entityqueue', $account);
if ($administer || user_access('manipulate all entityqueues', $account)) {
return TRUE;
}
if ($op == 'view' && user_access('manipulate entityqueues', $account)) {
return TRUE;
}
if (!(isset($entity) && is_object($entity))) {
return FALSE;
}
if (!isset($entity->queue)) {
watchdog('entityqueue', 'Missing queue property of entity object in entityqueue_access().', NULL, WATCHDOG_DEBUG);
return FALSE;
}
// For view, if they don't have the 'manipulate entityqueues' permission,
// check all other operations.
if ($op == 'view') {
foreach (array(
'update',
'create',
'delete',
) as $subop) {
if (user_access("{$subop} {$entity->queue} entityqueue", $account)) {
return TRUE;
}
}
}
return user_access("{$op} {$entity->queue} entityqueue", $account);
}