function domain_user_rules in Domain Access 6.2
Same name and namespace in other branches
- 5 domain_user/domain_user.module \domain_user_rules()
Checks for existing domains to create rules
Parameters
$generate: A boolean flag indicating whether to generate {access} table entries based on the current domain set. Default to TRUE.
Return value
An array of reserved name strings or an empty array.
4 calls to domain_user_rules()
- domain_user_configure_form in domain_user/
domain_user.admin.inc - FormsAPI for module settings
- domain_user_disable in domain_user/
domain_user.module - Implement hook_disable()
- domain_user_domainupdate in domain_user/
domain_user.module - Implement hook_domainupdate()
- domain_user_enable in domain_user/
domain_user.module - Implement hook_enable()
File
- domain_user/
domain_user.module, line 61 - Creates unique subdomains for registered users.
Code
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 && empty($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;
}