/[drupal]/contributions/modules/path_redirect/path_redirect.module
ViewVC logotype

Diff of /contributions/modules/path_redirect/path_redirect.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3.2.7.2.57, Wed Nov 4 05:49:46 2009 UTC revision 1.3.2.7.2.58, Wed Nov 4 06:00:11 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: path_redirect.module,v 1.3.2.7.2.56 2009/11/04 05:10:21 davereid Exp $  // $Id: path_redirect.module,v 1.3.2.7.2.57 2009/11/04 05:49:46 davereid Exp $
3    
4  if (!defined('REQUEST_TIME')) {  if (!defined('REQUEST_TIME')) {
5    define('REQUEST_TIME', time());    define('REQUEST_TIME', time());
# Line 130  function path_redirect_menu() { Line 130  function path_redirect_menu() {
130  function path_redirect_init() {  function path_redirect_init() {
131    if ($redirect = _path_redirect_load_current_page_redirect()) {    if ($redirect = _path_redirect_load_current_page_redirect()) {
132      // Create the absolute redirection URL.      // Create the absolute redirection URL.
133      $redirect->url_options = array(      $redirect['url_options'] = array(
134        'query' => $redirect->query,        'query' => $redirect['query'],
135        'fragment' => $redirect->fragment,        'fragment' => $redirect['fragment'],
136        'absolute' => TRUE,        'absolute' => TRUE,
137      );      );
138      $redirect->location = url($redirect->redirect, $redirect->url_options);      $redirect['location'] = url($redirect['redirect'], $redirect['url_options']);
139    
140      // Update the last used timestamp so that unused redirects can be purged.      // Update the last used timestamp so that unused redirects can be purged.
141      db_query("UPDATE {path_redirect} SET last_used = %d WHERE rid = %d", REQUEST_TIME, $redirect->rid);      db_query("UPDATE {path_redirect} SET last_used = %d WHERE rid = %d", REQUEST_TIME, $redirect['rid']);
142    
143      if (url($redirect->redirect) == url($_GET['q'])) {      if (url($redirect['redirect']) == url($_GET['q'])) {
144        // Prevent infinite loop redirection.        // Prevent infinite loop redirection.
145        watchdog('path_redirect', 'Redirect to <code>%redirect</code> is causing an infinite loop; redirect cancelled.', array('%redirect' => $redirect->location), WATCHDOG_WARNING, l(t('Edit'), 'admin/build/path-redirect/edit/'. $redirect->rid));        watchdog('path_redirect', 'Redirect to <code>%redirect</code> is causing an infinite loop; redirect cancelled.', array('%redirect' => $redirect['location']), WATCHDOG_WARNING, l(t('Edit'), 'admin/build/path-redirect/edit/'. $redirect['rid']));
146      }      }
147      elseif (path_redirect_var('allow_bypass') && isset($_GET['redirect']) && $_GET['redirect'] === 'no') {      elseif (path_redirect_var('allow_bypass') && isset($_GET['redirect']) && $_GET['redirect'] === 'no') {
148        // If the user has requested not to be redirected, show a message.        // If the user has requested not to be redirected, show a message.
149        drupal_set_message(t('This page has been moved to <a href="@redirect">@redirect</a>.', array('@redirect' => $redirect->location)));        drupal_set_message(t('This page has been moved to <a href="@redirect">@redirect</a>.', array('@redirect' => $redirect['location'])));
150      }      }
151      elseif (path_redirect_var('redirect_warning')) {      elseif (path_redirect_var('redirect_warning')) {
152        // Show a message and automatically redirect after 10 seconds.        // Show a message and automatically redirect after 10 seconds.
153        drupal_set_message(t('This page has been moved to <a href="@redirect">@redirect</a>. You will be automatically redirected in 10 seconds.', array('@redirect' => $redirect->location)), 'error');        drupal_set_message(t('This page has been moved to <a href="@redirect">@redirect</a>. You will be automatically redirected in 10 seconds.', array('@redirect' => $redirect['location'])), 'error');
154        drupal_set_html_head('<meta http-equiv="refresh" content="10;url="' . $redirect->location . '" />');        drupal_set_html_head('<meta http-equiv="refresh" content="10;url="' . $redirect['location'] . '" />');
155      }      }
156      else {      else {
157        // Perform the redirect.        // Perform the redirect.
158        unset($_REQUEST['destination']);        unset($_REQUEST['destination']);
159        drupal_goto($redirect->redirect, $redirect->query, $redirect->fragment, $redirect->type);        drupal_goto($redirect['redirect'], $redirect['query'], $redirect['fragment'], $redirect['type']);
160      }      }
161    }    }
162  }  }
# Line 274  function _path_redirect_load_current_pag Line 274  function _path_redirect_load_current_pag
274      // Remove ($language->language .'/') via preg_replace?      // Remove ($language->language .'/') via preg_replace?
275      $path = _path_redirect_split_path($path);      $path = _path_redirect_split_path($path);
276      $sql = "SELECT * FROM {path_redirect} WHERE (path = '%s' OR path = '%s') AND language IN ('%s', '') ORDER BY path DESC, language DESC";      $sql = "SELECT * FROM {path_redirect} WHERE (path = '%s' OR path = '%s') AND language IN ('%s', '') ORDER BY path DESC, language DESC";
277      return db_fetch_object(db_query_range($sql, $_GET['q'], $_GET['q'] . '?' . $path['query'], $language->language, 0, 1));      return db_fetch_array(db_query_range($sql, $_GET['q'], $_GET['q'] . '?' . $path['query'], $language->language, 0, 1));
278    }    }
279    else {    else {
280      return path_redirect_load_by_path($_GET['q'], $language->language);      return path_redirect_load_by_path($_GET['q'], $language->language);

Legend:
Removed from v.1.3.2.7.2.57  
changed lines
  Added in v.1.3.2.7.2.58

  ViewVC Help
Powered by ViewVC 1.1.2