function _devel_node_access_nar_alter

cis7 devel_node_access.module _devel_node_access_nar_alter(&$grants, $node)
cle7 devel_node_access.module _devel_node_access_nar_alter(&$grants, $node)
elmsmedia7 devel_node_access.module _devel_node_access_nar_alter(&$grants, $node)
icor7 devel_node_access.module _devel_node_access_nar_alter(&$grants, $node)
meedjum_blog7 devel_node_access.module _devel_node_access_nar_alter(&$grants, $node)
mooc7 devel_node_access.module _devel_node_access_nar_alter(&$grants, $node)

Helper function to mimic hook_node_access_records_alter() and trace what each module does with it.

Parameters

object $grants: An indexed array of grant records, augmented by the '#module' key, as created by _devel_node_access_module_invoke_all('node_access_records'). This array is updated by the hook_node_access_records_alter() implementations.

$node: The node that the grant records belong to.

Return value

A tree representation of the grant records in $grants including their history: $data[$realm][$gid] ['original'] - grant record before processing ['current'] - grant record after processing (if still present) ['changes'][]['op'] - change message (add/change/delete by $module) ['grant'] - grant record after change (unless deleted)

1 call to _devel_node_access_nar_alter()
devel_node_access_block_view in sites/all/modules/ulmus/devel/devel_node_access.module
Implements hook_block_view().

File

sites/all/modules/ulmus/devel/devel_node_access.module, line 341
This module gives developers feedback as to what their node_access table contains, and which nodes are protected or visible to the public.

Code

function _devel_node_access_nar_alter(&$grants, $node) {
  //dpm($grants, '_devel_node_access_nar_alter(): grants IN');
  $dummy = array();
  static drupal_alter('node_access_records', $dummy, $node);
  static $drupal_static = array();
  isset($drupal_static['drupal_alter']) || ($drupal_static['drupal_alter'] = &drupal_static('drupal_alter'));
  $functions = $drupal_static['drupal_alter'];

  // build the initial tree (and check for duplicates)
  $data = _devel_node_access_build_nar_data($grants, $node, 'hook_node_access_records()');

  // simulate drupal_alter('node_access_records', $grants, $node);
  foreach ($functions['node_access_records'] as $function) {
    // call hook_node_access_records_alter() for one module at a time and analyze
    $function($grants, $node); // <==
    $module = substr($function, 0, strlen($function) - 26);

    foreach ($grants as $i => $grant) {
      if (empty($data[$grant['realm']][$grant['gid']]['current'])) {
        // it's an added grant
        $data[$grant['realm']][$grant['gid']]['current'] = $grant;
        $data[$grant['realm']][$grant['gid']]['current']['#module'] = $module;
        $data[$grant['realm']][$grant['gid']]['changes'][] = array(
          'op' => 'added by ' . $module,
          'grant' => $grant,
        );
        $grants[$i]['#module'] = $module;
      }
      else {
        // it's an existing grant, check for changes
        foreach (array('view', 'update', 'delete') as $op) {
          $$op = $grant["grant_$op"] - $data[$grant['realm']][$grant['gid']]['current']["grant_$op"];
        }
        $priority = $grant['priority'] - $data[$grant['realm']][$grant['gid']]['current']['priority'];
        if ($view || $update || $delete || $priority) {
          // it was changed
          $data[$grant['realm']][$grant['gid']]['current'] = $grant;
          $data[$grant['realm']][$grant['gid']]['current']['#module'] = $module;
          $data[$grant['realm']][$grant['gid']]['changes'][] = array(
            'op' => 'altered by ' . $module,
            'grant' => $grant,
          );
          $grants[$i]['#module'] = $module;
        }
      }
      $data[$grant['realm']][$grant['gid']]['found'] = TRUE;
    }

    // check for newly introduced duplicates
    _devel_node_access_build_nar_data($grants, $node, 'hook_node_access_records_alter()');

    // look for grant records that have disappeared
    foreach ($data as $realm => $data2) {
      foreach ($data2 as $gid => $data3) {
        if (empty($data[$realm][$gid]['found']) && isset($data[$realm][$gid]['current'])) {
          unset($data[$realm][$gid]['current']);
          $data[$realm][$gid]['changes'][] = array('op' => 'removed by ' . $module);
        }
        else {
          unset($data[$realm][$gid]['found']);
        }
      }
    }
  }
  //dpm($data, '_devel_node_access_nar_alter() returns');
  //dpm($grants, '_devel_node_access_nar_alter(): grants OUT');
  return $data;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.