You are here

function module_grants_node_access_explain in Module Grants 6.3

Implementation of hook_node_access_explain().

Adds an 'explained' text to the last column of the table that appears inside the Devel Node Access block. See devel_node_access submodule in the Devel project.

@todo: I18n

File

./module_grants.module, line 543
Module to apply access grants to pre-published content just as they are to published content and to make multiple content access modules work together in the expected way.

Code

function module_grants_node_access_explain($row) {
  global $user;
  $ops_allowed = array();
  foreach (array(
    'view',
    'update',
    'delete',
  ) as $node_op) {
    $node = node_load($row->nid);
    if (module_grants_node_access($node_op, $node, $user)) {
      $ops_allowed[] = $node_op;
    }
  }
  $access = empty($ops_allowed) ? 'not view' : implode(', ', $ops_allowed);
  return theme('username', $user) . " may {$access} this node.";
}