You are here

function space_og::access_feature in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces_og/plugins/space_og.inc \space_og::access_feature()
  2. 7 spaces_og/plugins/space_og.inc \space_og::access_feature()

Override of access_feature().

Overrides space_type::access_feature

File

spaces_og/plugins/space_og.inc, line 95

Class

space_og
Organic groups integration for Spaces.

Code

function access_feature($op = 'view', $feature, $account = NULL) {
  $access = parent::access_feature($op, $feature, $account);
  global $user;
  $account = isset($account) ? $account : $user;

  // Only allow access if: user can administer OG, group is public,
  // or user is a member.
  $membership = FALSE;
  if ($membership = og_get_group_membership($this->og->gid, 'user', $account->uid)) {
    $membership = $membership->state;
  }
  $access = $access && (user_access('administer group') || $this->group->{OG_ACCESS_FIELD}[LANGUAGE_NONE][0]['value'] == OG_CONTENT_ACCESS_PUBLIC || $membership);

  // Additional check for group membership if authoring content in this group.
  if ($op === 'create') {
    return $access && og_is_member($this->og->gid, 'user', $account);
  }
  return $access;
}