function hosting_subdirs_validate_alias in Hosting 7.3
Same name and namespace in other branches
- 7.4 subdirs/hosting_subdirs.module \hosting_subdirs_validate_alias()
Ensure that an alias is valid for subdir site.
Parameters
object $site: A Hosting site node.
string $alias: An alias to have point to the site.
string $key:
1 call to hosting_subdirs_validate_alias()
- hosting_subdirs_site_form_validate in subdirs/
hosting_subdirs.module - Validation handler for site form.
File
- subdirs/
hosting_subdirs.module, line 70 - Allow sites to be installed in subdirectories.
Code
function hosting_subdirs_validate_alias($site, $alias, $key) {
$alias = hosting_site_clean_domain($alias);
// If we're adding a subdirectory alias, it can't begin with '/'.
if (@strpos($alias, '/', 1)) {
$subdir = explode('/', $alias, 2);
}
else {
// No subdirectory in use, so validate normally.
return hosting_alias_validate_alias($site, $alias, $key);
}
if (!hosting_alias_allow_domain($alias, array(
'nid' => $site->nid,
)) || $alias == $site->title) {
form_set_error("aliases][{$key}", t('The domain name @alias is already in use', array(
'@alias' => $alias,
)));
}
if (!hosting_subdirs_valid_fqdn_subdir($alias)) {
form_set_error("aliases][{$key}", t('The domain name @alias is not a valid subdir url', array(
'@alias' => $alias,
)));
}
}