function user_relationships_user_access in User Relationships 7
Check if a user has a given permission.
Parameters
$permission: The permission that should be checked. Use @relationship for the relationship type placeholder.
$relationship: For which relationship type the permission should be checked. If NULL, all relationship types are checked and TRUE is returned if $account has the permission for at least one relationship type.
$account: The account to check, if not given use currently logged in user.
Return value
TRUE if the user has the given permission for that relationship type or for any type if no specific relationship was passed in, FALSE otherwise.
7 calls to user_relationships_user_access()
- user_relationships_can_receive in ./
user_relationships.module - Check whether a user is allowed to receive a certain relationship type.
- user_relationships_can_request in ./
user_relationships.module - Check whether a user is allowed to request a certain relationship type.
- user_relationships_ui_actions_between in user_relationships_ui/
user_relationships_ui.module - List of possible relationship actions with between two users.
- user_relationships_ui_check_access in user_relationships_ui/
user_relationships_ui.module - Check access callback
- user_relationships_ui_user_view in user_relationships_ui/
user_relationships_ui.module
1 string reference to 'user_relationships_user_access'
- _user_relationship_service_definition in user_relationship_service/
user_relationship_service.module
File
- ./
user_relationships.module, line 922 - User Relationships API. Module shell.
Code
function user_relationships_user_access($permission, $relationship = NULL, $account = NULL) {
if (!$account) {
global $user;
$account = $user;
}
if ($relationship) {
$relationships = array(
$relationship,
);
}
else {
$relationships = user_relationships_types_load();
}
foreach ($relationships as $r) {
$relationship_permission = str_replace('@relationship', $r->machine_name, $permission);
if (user_access($relationship_permission, $account)) {
return TRUE;
}
}
}