You are here

function content_access_get_rids_per_node_op in Content Access 6

Same name and namespace in other branches
  1. 8 content_access.module \content_access_get_rids_per_node_op()
  2. 7 content_access.module \content_access_get_rids_per_node_op()

Returns optimized role ids for the given operation and node to grant access for.

If to a role access is granted by permissions, it's not necessary to write a grant for it. So it won't be returned.

Parameters

$op: One of the supported operations.

$node: The node object.

1 call to content_access_get_rids_per_node_op()
content_access_node_access_records in ./content_access.module
Implementation of hook_node_access_records()

File

./content_access.module, line 343
Content access module file.

Code

function content_access_get_rids_per_node_op($op, $node) {
  $rids = content_access_per_node_setting($op, $node);
  if ($permission = content_access_get_permission_by_op($op, $node->type)) {
    $perm_roles = content_access_get_permission_access($permission);
    $rids = array_diff($rids, $perm_roles);
    if (in_array(DRUPAL_AUTHENTICATED_RID, $perm_roles)) {
      return in_array(DRUPAL_ANONYMOUS_RID, $rids) ? array(
        DRUPAL_ANONYMOUS_RID,
        DRUPAL_AUTHENTICATED_RID,
      ) : array(
        DRUPAL_AUTHENTICATED_RID,
      );
    }
  }
  return $rids;
}