You are here

function oa_core_og_perm_ctools_access_check in Open Atrium Core 7.2

Check for access.

1 string reference to 'oa_core_og_perm_ctools_access_check'
oa_core_og_perm.inc in plugins/access/oa_core_og_perm.inc
Plugin to provide access control based on user permission strings in a group. Taken from Organic Groups but modified to work on nodes that are Group Content

File

plugins/access/oa_core_og_perm.inc, line 54
Plugin to provide access control based on user permission strings in a group. Taken from Organic Groups but modified to work on nodes that are Group Content

Code

function oa_core_og_perm_ctools_access_check($conf, $context) {

  // As far as I know there should always be a context at this point, but this
  // is safe.
  list($user_context, $node_context) = $context;
  if (empty($user_context) || empty($user_context->data)) {
    return;
  }
  if (empty($node_context) || empty($node_context->data)) {
    return;
  }
  $account = clone $user_context->data;
  $node = $node_context->data;
  if (!og_is_group('node', $node) && !empty($node->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][0]['target_id'])) {
    $node = node_load($node->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][0]['target_id']);
  }
  return og_user_access('node', $node->nid, $conf['perm'], $account);
}