function domain_set_primary_domain in Domain Access 6.2
Same name and namespace in other branches
- 7.3 domain.module \domain_set_primary_domain()
- 7.2 domain.module \domain_set_primary_domain()
Set the primary domain properly, if necessary.
2 calls to domain_set_primary_domain()
- domain_configure_form in ./
domain.admin.inc - FormsAPI for configuring the domain module.
- domain_configure_form_submit in ./
domain.admin.inc - Save any changes to the primary domain record.
File
- ./
domain.module, line 901 - Core module functions for the Domain Access suite.
Code
function domain_set_primary_domain() {
$root = strtolower(rtrim($_SERVER['SERVER_NAME']));
$site = variable_get('site_name', 'Drupal');
$scheme = 'http';
if (!empty($_SERVER['HTTPS'])) {
$scheme = 'https';
}
db_query("UPDATE {domain} SET subdomain = '%s', sitename = '%s', scheme = '%s', valid = 1 WHERE domain_id = 0", $root, $site, $scheme);
if (!db_affected_rows()) {
db_query("INSERT INTO {domain} (subdomain, sitename, scheme, valid) VALUES ('%s', '%s', '%s', %d)", $root, $site, $scheme, 1);
// MySQL won't let us insert row 0 into an autoincrement table.
// Similar to the {users} table, this leaves us with no row 1.
db_query("UPDATE {domain} SET domain_id = domain_id - 1");
}
// Set the default domain variables.
variable_set('domain_root', $root);
variable_set('domain_scheme', $scheme);
variable_set('domain_sitename', $site);
// Allow other modules to respond to changes.
module_invoke_all('domainupdate', 'update', domain_default(TRUE));
}