function biblio_access in Bibliography Module 7.3
Same name and namespace in other branches
- 5 biblio.module \biblio_access()
- 6.2 biblio.module \biblio_access()
- 6 biblio.module \biblio_access()
- 7 biblio.module \biblio_access()
- 7.2 biblio.module \biblio_access()
Access function for the biblio entity.
Parameters
$op: The type of the operation.
Biblio $entity: The entity object.
$account: The user object.
$entity_type: The entity type.
Return value
bool Return TRUE/FALSE if the user has the privilege for this action.
2 string references to 'biblio_access'
- biblio_entity_info in ./
biblio.module - Implements hook_entity_info().
- biblio_ui_menu in modules/
biblio_ui/ biblio_ui.module - Implements hook_menu().
File
- ./
biblio.module, line 454 - Maintains bibliographic lists.
Code
function biblio_access($op, Biblio $entity = NULL, $account = NULL, $entity_type = NULL) {
global $user;
$account = $account ? $account : user_load($user->uid);
if (user_access('administer biblio', $account)) {
return TRUE;
}
$strings = array(
'create' => 'create biblio content',
'update' => 'edit biblio content',
'delete' => 'delete biblio content',
'view' => 'access biblio content',
);
$string = $strings[$op];
// When checking the access on the biblio entity we need to check if the user
// can delete/update entries which created by himself/other users.
if (is_object($entity) && in_array($op, array(
'update',
'delete',
))) {
if (!user_access($string, $account) && $entity->uid == $account->uid) {
// The user can't delete/update any publication. We need to check if the
// user can update/delete his own biblio entries.
$string = $op == 'delete' ? 'delete own biblio content' : 'edit own biblio content';
}
}
return user_access($string, $account);
}