You are here

function domain_rules_condition_domain_compare in Domain Rules 7

Custom hook Test domain for matching

Parameters

string $operator:

string $subdomain:

Return value

bool

File

./domain_rules.module, line 684
domain_rules.module @description Port of 'Domain rules' by shushu for Drupal7

Code

function domain_rules_condition_domain_compare($operator, $subdomain) {
  $current_domain = domain_get_domain();
  $current_domain = $current_domain['subdomain'];
  $subdomain = trim($subdomain);
  switch ($operator) {
    case '!=':
      return $subdomain != $current_domain;
    case '~':
      return fnmatch($subdomain, $current_domain);
    case 'regexp':
      return preg_match('#' . $subdomain . '#Ui', $current_domain);
    case '=':
    default:
      return $subdomain == $current_domain;
  }
}