domain_user_rules($generate = TRUE)
domain_user/domain_user.module, line 128
Checks for existing domains to create rules
$generate A boolean flag indicating whether to generate {access} table entries based on the current domain set. Default to TRUE.
An array of reserved name strings or an empty array.
function domain_user_rules($generate = TRUE) {
// Find domains that are not user domains. These are blacklisted in user rules.
// We set the $reset flag to TRUE, to be sure we catch all changes.
$domains = domain_domains(TRUE);
$reserved = array();
// Get the root user domain.
$root = variable_get('domain_user_root', variable_get('domain_root', ''));
foreach ($domains as $domain) {
if ($domain['domain_id'] > 0 && !$domain['uid'] && !empty($root)) {
// Chop the name of domains to find the username equivalent.
$string = str_replace('.'. $root, '', $domain['subdomain']);
// In this case, we do strip port protocols, since they make no sense as usernames.
$str = explode(':', $string);
$name_string = $str[0];
$reserved[] = $name_string;
if ($generate && !empty($name_string)) {
$check = db_result(db_query("SELECT aid FROM {access} WHERE mask = '%s'", $name_string));
if (!$check) {
db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $name_string, 'user', 0);
}
}
}
}
return $reserved;
}