function login_destination_calculate_redirection_path_and_query in Login Destination 6.2
1 call to login_destination_calculate_redirection_path_and_query()
- login_destination_user in ./
login_destination.module - Implementation of hook_user().
File
- ./
login_destination.module, line 231 - Control where users are directed to, once they login
Code
function login_destination_calculate_redirection_path_and_query($form) {
//$message = print_r($edit, true);
//watchdog("php", $message, array(), WATCHDOG_NOTICE, NULL);
// this is a string with the contents of the settings textarea
$destination_str = variable_get('ld_url_destination', 'user');
$url_type = variable_get('ld_url_type', LOGIN_DEST_STATIC);
// override all if "preserve" checkbox set and there is a destination in the URL
if (variable_get('ld_destination', TRUE) && $_GET['destination']) {
$url_type = LOGIN_DEST_STATIC;
$destination_str = $_GET['destination'];
}
// if snippet
if ($url_type == LOGIN_DEST_SNIPPET) {
$url = eval($destination_str);
// if an array came from the snippet (an array with "path" and "query" keys)
if (is_array($url) && !empty($url['path'])) {
// "/" or "/drupal/" or similar
$base = base_path();
global $language;
if (!empty($language->prefix)) {
// now becomes probably "/en/" or "/drupal/en/"
$base .= $language->prefix . '/';
}
$path = $url['path'];
$query = $url['query'];
// strip base from url (isn't this too paranoic?) (won't hurt)
$path = preg_replace("!^{$base}!", '', $path);
}
else {
$path = $url;
$query = NULL;
}
}
else {
// take only 1st line
if (preg_match("!^(.*?)\$!", $destination_str, $matches) === 1) {
$path = $matches[1];
$query = NULL;
}
}
// support for <front>
if ($path == "<front>") {
$path = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
}
return array(
$path,
$query,
);
}