You are here

function ip_ban_block_list_alter in IP Ban 7

Implements hook_block_list_alter().

File

./ip_ban.module, line 68

Code

function ip_ban_block_list_alter(&$blocks) {

  // Take no action if the user has the "Bypass ban" permission.
  if (user_access('ignore ip_ban')) {
    return;
  }
  $banvalue = _ip_ban_set_ban_value();
  $disabled_blocks = variable_get('ip_ban_disabled_blocks');
  $disabled_block_list = array();
  if (!empty($disabled_blocks)) {
    $disabled_block_array = explode(PHP_EOL, $disabled_blocks);
    foreach ($disabled_block_array as $disabled_block) {
      $disabled_block_list[] = preg_replace('/\\s+/', '', $disabled_block);
    }
  }
  if (!empty($disabled_block_list)) {
    foreach ($blocks as $key => $block) {
      if ($block->status == 1) {
        $block_module_delta = $block->module . ',' . $block->delta;
        if (in_array($block_module_delta, $disabled_block_list)) {
          unset($blocks[$key]);
        }
      }
    }
  }
  _ip_ban_determine_action($banvalue);
}