You are here

function views_spaces_dashboard_block_access_alter in Spaces 7

Same name and namespace in other branches
  1. 6.3 spaces_dashboard/spaces_dashboard.module \views_spaces_dashboard_block_access_alter()
  2. 7.3 spaces_dashboard/spaces_dashboard.module \views_spaces_dashboard_block_access_alter()

Implementation of hook_spaces_dashboard_block_access_alter() on behalf of Views.

File

spaces_dashboard/spaces_dashboard.module, line 432

Code

function views_spaces_dashboard_block_access_alter(&$access) {
  static $views;
  foreach ($access as $bid => $allowed) {
    list($module, $delta) = explode('-', $bid, 2);
    if ($module === 'views') {

      // if this is 32, this should be an md5 hash.
      if (strlen($delta) == 32) {
        $hashes = variable_get('views_block_hashes', array());
        if (!empty($hashes[$delta])) {
          $delta = $hashes[$delta];
        }
      }

      // Ensure that this Views delta is well-formed.
      if (strpos($delta, '-') !== FALSE) {

        // Special Views blocks
        if (substr($delta, 0, 1) == '-') {
          list($nothing, $type, $name, $display_id) = explode('-', $delta);
        }
        else {
          list($name, $display_id) = explode('-', $delta);
        }

        // Load the view
        if (!isset($views[$name])) {
          $views[$name] = views_get_view($name);
        }
        if ($view = $views[$name]) {
          $access[$bid] = $allowed && $view
            ->access($display_id);
          $view
            ->destroy();
        }
      }
    }
  }
}