function domain_reassign in Domain Access 7.3
Reassign domain data to a new domain.
Parameters
$old_domain: The curent domain record, most commonly passed during a domain deletion.
$new_domain: The target domain record.
$table: The database table being affected. This value indicates the type of update being performed. Core module values are 'domain_access' (indicating that node records are being affected, and 'domain_editor' (indicating user records).
2 calls to domain_reassign()
- DomainHookTest::testDomainHooks in tests/domain.test 
- domain_delete in ./domain.module 
- Delete a domain record.
File
- ./domain.module, line 3692 
- Core module functions for the Domain Access suite.
Code
function domain_reassign($old_domain, $new_domain, $table) {
  // Re-assign content and users, if specified.
  $old_id = $old_domain['domain_id'];
  $new_id = $new_domain['domain_id'];
  if ($table == 'domain_access') {
    $nids = db_query("SELECT nid FROM {domain_access} WHERE realm = 'domain_id' AND gid = :domain_id", array(
      ':domain_id' => $new_id,
    ))
      ->fetchAllAssoc('nid');
    $query = db_update('domain_access')
      ->condition('gid', $old_id)
      ->condition('realm', 'domain_id')
      ->fields(array(
      'gid' => $new_id,
    ));
    // We cannot update using a subquery, so be sure to exclude duplicates.
    if (!empty($nids)) {
      $query
        ->condition('nid', array_keys($nids), 'NOT IN');
    }
    $query
      ->execute();
  }
  elseif ($table == 'domain_editor') {
    $uids = db_query("SELECT uid FROM {domain_editor} WHERE domain_id = :domain_id", array(
      ':domain_id' => $new_id,
    ))
      ->fetchAllAssoc('uid');
    $query = db_update('domain_editor')
      ->condition('domain_id', $old_id)
      ->fields(array(
      'domain_id' => $new_id,
    ));
    // We cannot update using a subquery, so be sure to exclude duplicates.
    if (!empty($uids)) {
      $query
        ->condition('uid', array_keys($uids), 'NOT IN');
    }
    $query
      ->execute();
  }
  // Let other modules act.
  module_invoke_all('domain_reassign', $old_domain, $new_domain, $table);
  // In all cases, we need to force a menu rebuild, which also clears the cache.
  menu_rebuild();
  // Notify that node access needs to be rebuilt.
  node_access_needs_rebuild(TRUE);
}