You are here

function hook_domainupdate in Domain Access 6.2

Same name and namespace in other branches
  1. 5 API.php \hook_domainupdate()
  2. 7.2 domain.api.php \hook_domainupdate()

Notify other modules that we have created a new domain or updated a domain record.

For 'update' and 'delete' operations, the $domain array holds the original values of the domain record. The $edit array will hold the new, replacement values. This is useful when making changes to records, such as in domain_user_domainupdate().

Parameters

$op: The operation being performed: 'create', 'update', 'delete'

$domain: The domain record taken from {domain}, as an array.

$form_state: The form values processed by the form. Note that these are not editable since module_invoke_all() cannot pass by reference. We set $form_state to an array by default in case this hook gets called by a non-form function.

Related topics

8 functions implement hook_domainupdate()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

domain_alias_domainupdate in domain_alias/domain_alias.module
Implement hook_domainupdate().
domain_conf_domainupdate in domain_conf/domain_conf.module
Implement hook_domainupdate().
domain_domainupdate in ./domain.module
Implement hook_domainupdate()
domain_nav_domainupdate in domain_nav/domain_nav.module
Implement hook_domainupdate()
domain_prefix_domainupdate in domain_prefix/domain_prefix.module
Implement hook_domainupdate().

... See full list

5 invocations of hook_domainupdate()
domain_configure_form_submit in ./domain.admin.inc
Save any changes to the primary domain record.
domain_delete_form_submit in ./domain.admin.inc
Implement domain_delete_form submit hook.
domain_save in ./domain.module
Domain save function.
domain_set_primary_domain in ./domain.module
Set the primary domain properly, if necessary.
domain_user_user in domain_user/domain_user.module
Implement hook_user()

File

./API.php, line 125
API documentation file.

Code

function hook_domainupdate($op, $domain, $form_state = array()) {
  switch ($op) {
    case 'create':
      db_query("INSERT INTO {mytable} (subdomain, sitename) VALUES ('%s', '%s')", $domain['subdomain'], $domain['sitename']);
      break;
    case 'update':
      db_query("UPDATE {mytable} SET subdomain = '%s', sitename = '%s' WHERE domain_id = %d", $domain['subdomain'], $domain['sitename'], $domain['domain_id']);
      break;
    case 'delete':
      db_query("DELETE FROM {mytable} WHERE subdomain = '%s'", $domain['subdomain']);
      break;
  }
}