Created
December 28, 2009 16:48
-
-
Save derhasi/264771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; $Id$ | |
name = "redirectgoto" | |
description = "goto redirect callback" | |
core = 6.x | |
package = ZZZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $Id$ | |
/** | |
* @file | |
* Callback function to do a redirect via drupal_goto and not via simply | |
* rendering the destination content. | |
* The callback will redirect to the path appended to redirectgoto/... . | |
* E.g. redirectgoto/node/10 will go to node/10 . | |
*/ | |
/** | |
* Implementation of hook_menu(). | |
*/ | |
function redirectgoto_menu() { | |
$items = array(); | |
$items['redirectgoto'] = array( | |
'title' => 'redirectgoto', | |
'description' => 'redirectgoto', | |
'page callback' => 'redirectgoto', | |
'access callback' => TRUE, | |
'type' => MENU_CALLBACK, | |
); | |
return $items; | |
} | |
/** | |
* redirectgoto callback | |
*/ | |
function redirectgoto() { | |
$args = func_get_args(); | |
$path = implode('/', $args); | |
$query = array(); | |
// Set go back destination for anonymous users | |
GLOBAL $user; | |
if (!$user->uid) { | |
$query = drupal_get_destination(); | |
} | |
$destination = drupal_get_destination(); | |
//unset current destination variables to avoid loops | |
unset($_REQUEST['destination']); | |
unset($_REQUEST['edit']['destination']); | |
drupal_goto($path, $query, NULL, 303); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment