function domain_update_6200 in Domain Access 6.2
Updates to 6.x.2.
Deprecates the domain_editor grant. Adds the {domain_editor} table. Installs the new Domain Boostrap routine. Moves records from {user} (data) to {domain_editor}.
File
- ./
domain.install, line 106 - Install file.
Code
function domain_update_6200() {
$ret = array();
// Remove the old editors information.
variable_del('domain_editors');
// Promopt the user to rebuild node access.
node_access_needs_rebuild(TRUE);
// Update the new bootstrap information.
domain_bootstrap_register();
// Try to register the default domain.
$root = variable_get('domain_root', rtrim($_SERVER['HTTP_HOST']));
db_query("INSERT INTO {domain} (subdomain, sitename, scheme, valid) VALUES ('%s', '%s', '%s', %d)", $root, variable_get('domain_sitename', variable_get('site_name', 'Drupal')), variable_get('domain_scheme', 'http://'), 1);
// MySQL won't let us insert row 0 into an autoincrement table.
db_query("UPDATE {domain} SET domain_id = 0 WHERE subdomain = '%s'", $root);
// Install the {domain_editor} table.
$schema = domain_schema();
db_create_table($ret, 'domain_editor', $schema['domain_editor']);
// Move records from $user->data to {domain_editor}.
if (!db_table_exists('domain_editor')) {
return;
}
$result = db_query("SELECT uid, data FROM {users}");
while ($account = db_fetch_object($result)) {
$data = unserialize($account->data);
if (!empty($data['domain_user'])) {
foreach ($data['domain_user'] as $domain_id => $status) {
// A zero flag indicated not selected.
if ($status != 0) {
// Convert the -1 checkbox to a zero.
if ($domain_id == -1) {
$domain_id = 0;
}
db_query("INSERT INTO {domain_editor} (uid, domain_id) VALUES (%d, %d)", $account->uid, $domain_id);
}
}
}
}
return $ret;
}