You are here

function domain_save in Domain Access 7.2

Same name and namespace in other branches
  1. 6.2 domain.module \domain_save()
  2. 7.3 domain.module \domain_save()

Domain save function.

Parameters

$values: Form value information.

$edit: Form state information.

Return value

$domain array on success or -1 on failure.

1 call to domain_save()
domain_form_submit in ./domain.admin.inc
Implement domain_form submit hook.

File

./domain.module, line 766
Core module functions for the Domain Access suite.

Code

function domain_save($values, $edit) {

  // Update or insert a record?
  $update = isset($values['domain_id']) && is_numeric($values['domain_id']) ? array(
    'domain_id',
  ) : array();
  if (!empty($update)) {
    $action = 'update';
  }
  else {
    $action = 'create';
  }
  drupal_write_record('domain', $values, $update);

  // Let other modules act on a proper copy of the domain.
  $domain = domain_lookup(NULL, $values['subdomain'], TRUE);
  module_invoke_all('domainupdate', $action, $domain, $edit);

  // Lookup the modified record and return it.
  $domain = domain_lookup(NULL, $values['subdomain'], TRUE);
  return $domain;
}