domain_invalid_domain_requested()Redirect a request to an invalid domain.
We were sent here from domain_init() because the user cannot view the requested domain.
Take the user to the best valid match, which is usually the primary domain. In the case of nodes, try to find another match.
No return. This function issues a drupal_goto();
contrib-6/domain/domain.module, line 2131
<?php
function domain_invalid_domain_requested() {
global $_domain, $user;
// Some users are allowed to view inactive domains.
if (user_access('access inactive domains')) {
return;
}
// Check to see if this is a node page. These are redirected to a visible page, if possible.
$item = menu_get_item();
$nid = NULL;
if ($item['path'] == 'node/%') {
$node = node_load(arg(1));
}
if (empty($node->nid)) {
$path = $item['href'];
if (drupal_is_front_page($item['href'])) {
$path = '';
}
$default = domain_default();
// Log the access attempt.
watchdog('domain', 'Invalid domain requested by %user on %domain; redirected to %default.', array('%user' => $user->name, '%domain' => $_domain['sitename'], '%default' => $default['sitename']), WATCHDOG_WARNING);
drupal_goto($default['path'] . drupal_get_path_alias($path));
}
// Try to find the proper redirect for a node.
$path = "node/$node->nid";
$domain = domain_get_node_match($node->nid);
if ($domain['valid']) {
$redirect = $domain;
}
else if (!empty($node->domains)) {
foreach ($node->domains as $domain_id) {
if ($domain_id == -1) {
$domain_id = 0;
}
$domain = domain_lookup($domain_id);
if ($domain['valid']) {
$redirect = $domain;
break;
}
}
}
// If we found no node matches, just go to the home page.
$extra = ' '. t('node page.');
if (empty($redirect)) {
$redirect = domain_default();
$path = '';
$extra = '.';
}
// Log the access attempt.
watchdog('domain', 'Invalid domain requested by %user on %domain, redirected to %redirect', array('%user' => $user->name, '%domain' => $_domain['sitename'], '%redirect' => $redirect['sitename'] . $extra), WATCHDOG_WARNING);
drupal_goto($redirect['path'] . drupal_get_path_alias($path));
}
?>