You are here

function group_access in Group 7

Determine whether the user has a given privilege for a group.

Important: Group access should always trump user access. If a user has the right to view nodes of type Page, he can still face an 'Access denied' message if he tries to view a Page of a private group.

Parameters

string $permission: The permission, such as "administer group", being checked for.

Group $group: The group to check the permission on.

object $account: (optional) The account to check, if not given use currently logged in user.

Return value

bool Whether the user has the requested permission.

22 calls to group_access()
ggroup_add_subgroup_access in modules/ggroup/ggroup.router.inc
Access callback for group/%group/subgroup/add/%group_type.
ginvite_by_mail_form_validate in modules/ginvite/forms/ginvite.inc
Validate handler for ginvite_by_mail_form().
gnode_add_node_access in modules/gnode/gnode.router.inc
Access callback for group/%group/node/add/%.
gnode_group_node_create_access in modules/gnode/gnode.module
Determines whether a user could create a node in a Group context.
gnode_group_node_create_gids in modules/gnode/gnode.module
Retrieve all group ids a user can create a node of a given type in.

... See full list

3 string references to 'group_access'
gadd_menu in modules/gadd/gadd.router.inc
Implements hook_menu().
ginvite_menu in modules/ginvite/ginvite.router.inc
Implements hook_menu().
GroupMembershipUIController::hook_menu in classes/group_membership.ui_controller.inc
Provides definitions for implementing hook_menu().

File

helpers/group.inc, line 24
Group related helper functions.

Code

function group_access($permission, Group $group, $account = NULL) {
  global $user;
  if (!isset($account)) {
    $account = $user;
  }
  return user_access('bypass group access', $account) || $group
    ->userHasPermission($account->uid, $permission);
}