function _devel_node_access_ng_alter

cis7 devel_node_access.module _devel_node_access_ng_alter(&$grants, $account, $op)
cle7 devel_node_access.module _devel_node_access_ng_alter(&$grants, $account, $op)
elmsmedia7 devel_node_access.module _devel_node_access_ng_alter(&$grants, $account, $op)
icor7 devel_node_access.module _devel_node_access_ng_alter(&$grants, $account, $op)
meedjum_blog7 devel_node_access.module _devel_node_access_ng_alter(&$grants, $account, $op)
mooc7 devel_node_access.module _devel_node_access_ng_alter(&$grants, $account, $op)

Helper function to mimic hook_node_grants_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_grants'). This array is updated by the hook_node_grants_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] ['cur'] - TRUE or FALSE whether the gid is present or not ['ori'][] - array of module names that contributed this grant (if any) ['chg'][] - array of changes, such as

  • 'added' if module name is a prefix if the $realm,
  • 'added by module' otherwise, or
  • 'removed by module'
1 call to _devel_node_access_ng_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 434
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_ng_alter(&$grants, $account, $op) {
  //dpm($grants, '_devel_node_access_ng_alter(): grants IN');
  $dummy = array();
  static drupal_alter('node_grants', $dummy, $account, $op);
  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 structure
  $data = array();
  foreach ($grants as $realm => $gids) {
    foreach ($gids as $i => $gid) {
      if ($i !== '#module') {
        $data[$realm][$gid]['cur'] = TRUE;
        $data[$realm][$gid]['ori'][] = $gids['#module'];
      }
    }
    unset($grants[$realm]['#module']);
  }

  // simulate drupal_alter('node_grants', $grants, $account, $op);
  foreach ($functions['node_grants'] as $function) {
    // call hook_node_grants_alter() for one module at a time and analyze
    $function($grants, $account, $op); // <==
    $module = substr($function, 0, strlen($function) - 18);

    // check for new gids
    foreach ($grants as $realm => $gids) {
      foreach ($gids as $i => $gid) {
        if (empty($data[$realm][$gid]['cur'])) {
          $data[$realm][$gid]['cur'] = TRUE;
          $data[$realm][$gid]['chg'][] = 'added by ' . $module;
        }
      }
    }

    // check for removed gids
    foreach ($data as $realm => $gids) {
      foreach ($gids as $gid => $history) {
        if ($history['cur'] && array_search($gid, $grants[$realm]) === FALSE) {
          $data[$realm][$gid]['cur'] = FALSE;
          $data[$realm][$gid]['chg'][] = 'removed by ' . $module;
        }
      }
    }
  }

  //dpm($data, '_devel_node_access_ng_alter() returns');
  //dpm($grants, '_devel_node_access_ng_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.