You are here

function og_node_access_records in Organic groups 5.2

File

./og.module, line 1989

Code

function og_node_access_records($node) {

  // don't write records if og access control is disabled or the node type is omitted or node is a group
  if (og_is_omitted_type($node->type) || !variable_get('og_enabled', FALSE)) {
    return;
  }
  if (og_is_group_type($node->type)) {

    // this grant allows group admins to manage stuff
    $grants[] = array(
      'realm' => 'og_subscriber',
      'gid' => $node->nid,
      'grant_view' => 1,
      'grant_update' => 1,
      'grant_delete' => 1,
    );

    // this one lets everyone see group homepage. see 'private groups' issue if you don't want this. we need help.
    $grants[] = array(
      'realm' => 'og_public',
      'gid' => 0,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
    );
  }
  elseif (is_array($node->og_groups)) {

    // applies to non group nodes
    foreach ($node->og_groups as $gid) {

      // we write a broad grant here but og_node_grants() only issues it selectively.
      $grants[] = array(
        'realm' => 'og_subscriber',
        'gid' => $gid,
        'grant_view' => 1,
        'grant_update' => 1,
        'grant_delete' => 1,
      );
    }
  }
  if ($node->og_public) {
    $grants[] = array(
      'realm' => 'og_public',
      'gid' => 0,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
    );
  }
  return $grants;
}