Same name and namespace in other branches
  1. 5.x-1.x devel_node_access.api.php \hook_node_access_explain()
  2. 7.x-1.x devel_node_access.api.php \hook_node_access_explain()

Explain your records in the {node_access} table.

In order to help developers and administrators understand the forces that control access to any given node, the DNA module provides the Devel Node Access block, which lists all the grant records in the {node_access} table for that node.

However, every Node Access module is free in how it defines and uses the 'realm' and 'gid' fields in its records in the {node_access} table, and it's often difficult to interpret them. This hook passes each record that DNA wants to display, and the owning module is expected to return an explanation of that record.

The explanation should not be localized (not be passed through t()), so that administrators seeking help can present English explanations.

Parameters

$row: The record from the {node_access} table, as object. The member fields are: nid, gid, realm, grant_view, grant_update, grant_delete.

Return value

A string with a (short!) explanation of the given {node_access} row, to be displayed in DNA's 'Devel Node Access' block. It will be displayed as HTML; any variable parts must already be sanitized.

See also

hook_node_access_records()

devel_node_access_node_access_explain()

1 function implements hook_node_access_explain()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

devel_node_access_node_access_explain in ./devel_node_access.module
Implementation of hook_node_access_explain().

File

./devel_node_access.api.php, line 44
Hook provided by the Devel Node Access module.

Code

function hook_node_access_explain($row) {
  if ($row->realm == 'mymodule_myrealm') {
    if ($row->grant_view) {
      $name = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $row->gid));
      return 'Role ' . theme_placeholder($name) . ' may view this node.';
    }
    else {
      return 'No access.';
    }
  }
}