You are here

public function AdvbanIpManager::unbanIpAll in Advanced ban 8

Unbans all IP addresses.

Parameters

array $params: Simple or/and range IP.

Return value

int Deleted count.

Overrides AdvbanIpManagerInterface::unbanIpAll

File

src/AdvbanIpManager.php, line 209

Class

AdvbanIpManager
Ban IP manager.

Namespace

Drupal\advban

Code

public function unbanIpAll(array $params = []) {
  $query = $this->connection
    ->delete('advban_ip');
  if (!empty($params)) {

    // Range parameters.
    if (!empty($params['range']) && $params['range'] != 'all') {
      switch ($params['range']) {
        case 'simple':
          $query
            ->condition('ip_end', '');
          break;
        case 'range':
          $query
            ->condition('ip_end', '', '<>');
          break;
      }
    }

    // Expire parameters.
    if (!empty($params['expire']) && $params['expire'] != 'all') {
      switch ($params['expire']) {
        case 'expired':
          $query
            ->condition('expiry_date', 0, '<>');
          break;
        case 'not_expired':
          $query
            ->condition('expiry_date', 0);
          break;
      }
    }
  }
  return $query
    ->execute();
}