summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc24
1 files changed, 16 insertions, 8 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 6f4353e29..7c5971087 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -133,20 +133,28 @@ function drupal_get_headers() {
/**
* Prepare a destination query string for use in combination with
- * drupal_goto(). Used to direct the user back to the referring page
- * after completing a form.
+ * drupal_goto(). Used to direct the user back to the referring page
+ * after completing a form. By default the current URL is returned.
+ * If a destination exists in the previous request, that destination
+ * is returned. As such, a destination can persist across multiple
+ * pages.
*
* @see drupal_goto()
*/
function drupal_get_destination() {
- $destination[] = $_GET['q'];
- $params = array('page', 'sort', 'order');
- foreach ($params as $param) {
- if (isset($_GET[$param])) {
- $destination[] = "$param=". $_GET[$param];
+ if ($_REQUEST['destination']) {
+ return 'destination='. urlencode($_REQUEST['destination']);
+ }
+ else {
+ $destination[] = $_GET['q'];
+ $params = array('page', 'sort', 'order');
+ foreach ($params as $param) {
+ if (isset($_GET[$param])) {
+ $destination[] = "$param=". $_GET[$param];
+ }
}
+ return 'destination='. urlencode(implode('&', $destination));
}
- return 'destination='. urlencode(implode('&', $destination));
}
/**