You are here

function og_access_node_grants in Organic groups 6.2

Same name and namespace in other branches
  1. 5.8 og_access.module \og_access_node_grants()
  2. 5 og_access.module \og_access_node_grants()
  3. 5.3 og_access.module \og_access_node_grants()
  4. 5.7 og_access.module \og_access_node_grants()
  5. 6 modules/og_access/og_access.module \og_access_node_grants()
  6. 7.2 og_access/og_access.module \og_access_node_grants()
  7. 7 og_access/og_access.module \og_access_node_grants()

Implementation of hook_node_grants().

File

modules/og_access/og_access.module, line 267

Code

function og_access_node_grants($account, $op) {
  if ($op == 'view') {
    $grants['og_public'][] = 0;

    // everyone can see a public node
  }

  // Subscribers get an admin or non-admin grant for each subscription
  if ($subscriptions = og_get_subscriptions($account->uid)) {
    foreach ($subscriptions as $key => $val) {

      // Admins don't need to receive the subscriber grant since they can perform all operations.
      if ($val['is_admin']) {
        $grants['og_admin'][] = $key;
      }
      else {
        $grants['og_subscriber'][] = $key;
      }
    }
  }
  return isset($grants) ? $grants : array();
}