You are here

module_grants_test_access_hook.module in Module Grants 7

This module will implement hook_node_access() to change node access.

File

tests/module_grants_test_access_hook.module
View source
<?php

/**
 * @file
 * This module will implement hook_node_access() to change node access.
 */

/**
 * Used for implement hook_permission().
 */
function module_grants_test_access_hook_permission() {
  $permissions = array();
  foreach (array(
    'view',
    'update',
    'delete',
    'create',
  ) as $op) {
    $permissions["module_grants_test_access_hook {$op} all"] = array(
      'title' => "Module grants permission for {$op} all access",
    );
  }
  return $permissions;
}

/**
 * Used for implement hook_node_access().
 */
function module_grants_test_access_hook_node_access($node, $op, $account) {
  if (user_access("module_grants_test_access_hook {$op} all", $account)) {
    return NODE_ACCESS_ALLOW;
  }
  else {
    return NODE_ACCESS_IGNORE;
  }
}