You are here

function content_access_condition_check_permissions in Content Access 6

Same name and namespace in other branches
  1. 5 content_access.workflow_ng.inc \content_access_condition_check_permissions()

Condition implementation: Check if node has permissions.

@note This will only check for the existence of permissions, not the absence of. I.e. a rule that checks just for authenticated write will return TRUE for a node that allows authenticated and anonymous write.

File

./content_access.rules.inc, line 243
Rules specific functions that expose content_access' API.

Code

function content_access_condition_check_permissions($node, $settings) {
  if (_content_access_rules_check_setting($node)) {

    // Compare our settings with node's settings.
    foreach (_content_access_get_operations() as $op) {
      $settings += array(
        $op => array(),
      );
      $expect_roles = $settings[$op];
      $current_roles = content_access_per_node_setting($op, $node);
      if (count(array_diff($expect_roles, $current_roles)) != 0) {
        return FALSE;
      }
    }
    return TRUE;
  }
  return FALSE;
}