You are here

function domain_delete in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain_admin.inc \domain_delete()
  2. 7.2 domain.module \domain_delete()

Delete a domain record.

Parameters

$domain: The domain record being deleted.

$values: An array of values passed by a form submit, if any. When reassigning content from a domain, look for the 'domain_access' and 'domain_editor' keys, which are the domains ids for re-assignment.

6 calls to domain_delete()
DomainCreateTest::testDomainCreate in tests/domain.test
DomainHookTest::testDomainHooks in tests/domain.test
domain_delete_form_submit in ./domain.admin.inc
Implement domain_delete_form submit hook.
domain_features_rebuild in ./domain.features.inc
Implements hook_features_rebuild().
drush_domain_delete in ./domain.drush.inc
Delete a domain record.

... See full list

4 string references to 'domain_delete'
domain_batch_form_submit in ./domain.admin.inc
FormsAPI for saving batch form actions.
domain_conf_domain_batch in domain_conf/domain_conf.domain.inc
Implements hook_domain_batch().
domain_theme_domain_batch in domain_theme/domain_theme.domain.inc
Implements hook_domain_batch().
MigrateDestinationDomain::rollback in ./domain.migrate.inc
Delete a single domain.

File

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

Code

function domain_delete($domain, $values = array()) {

  // Let other modules act to reassign data.
  foreach (array(
    'domain_access',
    'domain_editor',
  ) as $table) {
    if (isset($values[$table]) && $values[$table] != 'none') {
      $new_domain = domain_lookup($values[$table]);
      if ($new_domain != -1) {
        domain_reassign($domain, $new_domain, $table);
      }
    }
  }

  // Inform other modules of the deletion.
  module_invoke_all('domain_delete', $domain, $values);

  // Remove domain-specific entries from tables and clear the cache.
  db_delete('domain_access')
    ->condition('gid', $domain['domain_id'])
    ->condition('realm', 'domain_id')
    ->execute();
  db_delete('domain_editor')
    ->condition('domain_id', $domain['domain_id'])
    ->execute();

  // Delete the domain.
  db_delete('domain')
    ->condition('domain_id', $domain['domain_id'])
    ->execute();
  db_delete('domain_export')
    ->condition('domain_id', $domain['domain_id'])
    ->execute();

  // In all cases, we need to force a menu rebuild, which also clears the cache.
  variable_set('menu_rebuild_needed', TRUE);

  // Notify that node access needs to be rebuilt.
  node_access_needs_rebuild(TRUE);
}