You are here

function domain_rules_actions_create_domain in Domain Rules 7

Custom hook Do on action 'create domain'

Parameters

string $sitename:

string $subdomain:

int $domainscheme:

int $valid:

File

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

Code

function domain_rules_actions_create_domain($sitename, $subdomain, $scheme, $valid) {
  $domain = domain_lookup(NULL, $subdomain, TRUE);
  if ($domain['domain_id']) {
    drupal_set_message(t('The domain %domain already exists.', array(
      '%domain' => $subdomain,
    )), 'error');
  }
  else {
    $schemes = __domain_rules_schemes();
    $scheme = isset($schemes[$scheme]) ? $schemes[$scheme] : '';
    unset($schemes);
    $domain_settings = array(
      'subdomain' => $subdomain,
      'sitename' => $sitename,
      'scheme' => $scheme,
      'valid' => $valid,
    );
    $domain = domain_save($domain_settings, FALSE);
    unset($domain_settings);
    if ($domain['domain_id']) {
      drupal_set_message(t('The domain %domain created successfully.', array(
        '%domain' => $subdomain,
      )));
    }
    else {
      drupal_set_message(t('Failed to create the domain %domain.', array(
        '%domain' => $subdomain,
      )), 'error');
    }
  }
}