You are here

function _devel_node_access_get_grant_list in Devel 7

Same name and namespace in other branches
  1. 6 devel_node_access.module \_devel_node_access_get_grant_list()

Creates a list of the grants returned by hook_node_grants().

Parameters

integer $nid:

array $ng_alter_data:

Return value

A themed item list of grants.

1 call to _devel_node_access_get_grant_list()
devel_node_access_block_view in ./devel_node_access.module
Implements hook_block_view().

File

./devel_node_access.module, line 1312
Functions for debugging node access permissions.

Code

function _devel_node_access_get_grant_list($nid, $ng_alter_data) {

  //dpm($ng_alter_data, "_devel_node_access_get_grant_list($nid,");
  $ng_alter_data = array_merge(array(
    'all' => array(
      0 => array(
        'cur' => TRUE,
        'ori' => array(
          'all',
        ),
      ),
    ),
  ), $ng_alter_data);
  $items = array();
  if (count($ng_alter_data)) {
    foreach ($ng_alter_data as $realm => $gids) {
      ksort($gids);
      $gs = array();
      foreach ($gids as $gid => $history) {
        if ($history['cur']) {
          if (isset($history['ori'])) {
            $g = $gid;

            // original grant, still active
          }
          else {
            $g = '<u>' . $gid . '</u>';

            // new grant, still active
          }
        }
        else {
          $g = '<del>' . $gid . '</del>';

          // deleted grant
        }
        $ghs = array();
        if (isset($history['ori']) && strpos($realm, $history['ori'][0]) !== 0) {
          $ghs[] = 'by ' . $history['ori'][0];
        }
        if (isset($history['chg'])) {
          foreach ($history['chg'] as $h) {
            $ghs[] = $h;
          }
        }
        if (!empty($ghs)) {
          $g .= ' (' . implode(', ', $ghs) . ')';
        }
        $gs[] = $g;
      }
      $items[] = $realm . ': ' . implode(', ', $gs);
    }
    if (!empty($items)) {
      return theme('item_list', array(
        'items' => $items,
        'type' => 'ul',
      ));
    }
  }
}