You are here

function boxes_spaces_dashboard_block_access_alter in Boxes 6

Same name and namespace in other branches
  1. 7 boxes.module \boxes_spaces_dashboard_block_access_alter()

Implementation of hook_spaces_dashboard_block_access_alter().

Provides access to blocks specific to each space.

File

./boxes.module, line 466

Code

function boxes_spaces_dashboard_block_access_alter(&$access) {
  foreach (array_keys($access) as $bid) {
    list($module, $delta) = explode('-', $bid, 2);
    if ($module === 'boxes') {

      // This is the add block, give access to admins.
      if (strpos($delta, 'boxes_add__') === 0) {
        $access[$bid] = boxes_access_admin();
      }
      else {
        if (module_exists('spaces') && ($space = spaces_get_space())) {
          $in_space = $space->controllers->boxes
            ->get($delta, 'space');
          $access[$bid] = $access[$bid] || !empty($in_space);
        }
        else {
          $access[$bid] = boxes_access_admin();
        }
      }
    }
  }
}