? ld_variables.patch Index: login_destination.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/login_destination/login_destination.module,v retrieving revision 1.8 diff -u -p -r1.8 login_destination.module --- login_destination.module 1 Dec 2008 13:37:22 -0000 1.8 +++ login_destination.module 20 Oct 2009 14:03:02 -0000 @@ -19,8 +19,8 @@ define('LOGIN_COND_SNIPPET', 'snippet'); define('LOGIN_DEST_PERM_ADMIN', 'administer login destination'); /** -* Implementation of hook_perm(). -*/ + * Implementation of hook_perm(). + */ function login_destination_perm() { return array(LOGIN_DEST_PERM_ADMIN); } @@ -70,7 +70,8 @@ function login_destination_admin_setting '#title' => t('URL'), '#rows' => 4, '#description' => - t('Static URL mode: Enter a static path. Example paths are %ex1 or %ex2.', array('%ex1' => 'node/add', '%ex2' => 'workspace')). '
'. + t('Static URL mode: Enter a static path. Example paths are %ex1 or %ex2.', + array('%ex1' => 'node/add', '%ex2' => 'workspace')) .'
'. t("PHP snippet mode: Enter PHP code to evaluate path (NO %php tags!). It should return either a string value or an array('path' => path/alias to redirect, 'query' => parameters, ... [other parameters are equal to the url() function specification]).", array('%php' => '')) ); @@ -95,9 +96,9 @@ function login_destination_admin_setting '#title' => t('Redirect condition'), '#rows' => 4, '#description' => - t('Always: Redirection happens always. Redirect condition field is ignored.'). '
' . + t('Always: Redirection happens always. Redirect condition field is ignored.') .'
' . t('List of paths mode: Enter a list of paths, one path per one line. Redirection will happen only when logging from specified pages. Example paths are %ex1 or %ex2.', - array('%ex1' => 'contact', '%ex2' => 'user/login')). '
'. + array('%ex1' => 'contact', '%ex2' => 'user/login')) .'
'. t('PHP snippet mode: Enter PHP code to find should redirection happen or not (NO %php tags!). It should return boolean value.', array('%php' => '')) ); @@ -106,37 +107,39 @@ function login_destination_admin_setting } /** - * Implementation of hook_user. + * Implementation of hook_user(). */ function login_destination_user($op, &$edit, &$account, $category = NULL) { + $url = NULL; switch ($op) { - case 'login': - global $language; - $destination = variable_get('ld_url_destination', 'user'); - - if (variable_get('ld_url_type', LOGIN_DEST_STATIC) == LOGIN_DEST_SNIPPET) { - ob_start(); - $url = eval($destination); - ob_end_clean(); - } - else { - $url = $destination; - } + case 'login': + global $language; + $destination = variable_get('ld_url_destination', 'user'); - if (is_array($url) && !empty($url['path'])) { - $path = $url['path']; - unset($url['path']); - $base = base_path(); - if (!empty($language->prefix)) { - $base .= $language->prefix. '/'; + if (variable_get('ld_url_type', LOGIN_DEST_STATIC) == LOGIN_DEST_SNIPPET) { + ob_start(); + $url = eval($destination); + ob_end_clean(); + } + else { + $url = $destination; + } + + if (is_array($url) && !empty($url['path'])) { + $path = $url['path']; + unset($url['path']); + $base = base_path(); + if (!empty($language->prefix)) { + $base .= $language->prefix .'/'; + } + $url = str_replace($base, '', url($path, $url)); } - $url = str_replace($base, '', url($path, $url)); - } } + if (login_destination_apply_redirect()) { $_REQUEST['destination'] = $url; } -} +} /** * A helper function to determine whether redirection should happen. @@ -144,7 +147,8 @@ function login_destination_user($op, &$e * @return bool TRUE - apply redirect, FALSE - not to apply redirect. */ function login_destination_apply_redirect() { - if ($_GET['destination'] != $_GET['q'] && variable_get('ld_destination', TRUE)) { + if (array_key_exists('destination', $_GET) && $_GET['destination'] != $_GET['q'] + && variable_get('ld_destination', TRUE)) { return FALSE; } @@ -159,8 +163,7 @@ function login_destination_apply_redirec return in_array($_GET['q'], $paths); } elseif (LOGIN_COND_SNIPPET == $mode) { - $destination = variable_get('ld_url_destination', 'user'); - return drupal_eval(''); + return drupal_eval(''); } } }