5 * Hook provided by the Devel Node Access module.
14 * Explain your records in the {node_access} table.
16 * In order to help developers and administrators understand the forces
17 * that control access to any given node, the DNA module provides the
18 * Devel Node Access block, which lists all the grant records in the
19 * {node_access} table for that node.
21 * However, every Node Access module is free in how it defines and uses the
22 * 'realm' and 'gid' fields in its records in the {node_access} table, and
23 * it's often difficult to interpret them. This hook passes each record
24 * that DNA wants to display, and the owning module is expected to return
25 * an explanation of that record.
27 * The explanation should not be localized (not be passed through t()), so
28 * that administrators seeking help can present English explanations.
31 * The record from the {node_access} table, as object. The member fields are:
32 * nid, gid, realm, grant_view, grant_update, grant_delete.
35 * A string with a (short!) explanation of the given {node_access} row,
36 * to be displayed in DNA's 'Devel Node Access' block. It will be displayed
37 * as HTML; any variable parts must already be sanitized.
39 * @see hook_node_access_records()
40 * @see devel_node_access_node_access_explain()
42 * @ingroup node_access
44 function hook_node_access_explain($row) {
45 if ($row->realm
== 'mymodule_myrealm') {
46 if ($row->grant_view
) {
47 $role = user_role_load($row->gid
);
48 return 'Role ' .
drupal_placeholder($role->name
) .
' may view this node.';
57 * Acknowledge ownership of 'alien' grant records.
59 * Some node access modules store grant records directly into the {node_access}
60 * table rather than returning them through hook_node_access_records(). This
61 * practice is not recommended and DNA will flag all such records as 'alien'.
63 * If this is unavoidable, a module can confess to being the owner of these
64 * grant records, so that DNA can properly attribute them.
66 * @see hook_node_access_records()
68 * @ingroup node_access
70 function hook_node_access_acknowledge($grant) {
71 if ($grant['realm'] == 'mymodule_all' && $grant['nid'] == 0) {
77 * @} End of "addtogroup hooks".