You are here

function domain_rules_actions_change_subdomain in Domain Rules 7

Custom hook Do on action 'change subdomain'

Parameters

string $subdomain:

string $new_subdomain:

File

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

Code

function domain_rules_actions_change_subdomain($subdomain, $new_subdomain) {
  $domain = domain_lookup(NULL, $subdomain, TRUE);
  if ($domain['domain_id']) {
    $domain['subdomain'] = $new_subdomain;
    $domain = domain_save($domain, FALSE);
    if ($domain['domain_id']) {
      drupal_set_message(t('The domain %domain updated successfully.', array(
        '%domain' => $subdomain,
      )));
    }
    else {
      drupal_set_message(t('Failed to update the domain %domain.', array(
        '%domain' => $subdomain,
      )), 'error');
    }
  }
  else {
    drupal_set_message(t('The domain %domain does not exist.', array(
      '%domain' => $subdomain,
    )), 'error');
  }
}