summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc24
-rw-r--r--modules/node.module32
-rw-r--r--modules/node/node.module32
3 files changed, 56 insertions, 32 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));
}
/**
diff --git a/modules/node.module b/modules/node.module
index cc1d36a40..9871ae87e 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -673,7 +673,7 @@ function node_menu($may_cache) {
'weight' => 1,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('delete'),
- 'callback' => 'node_page',
+ 'callback' => 'node_delete_page',
'access' => node_access('delete', $node),
'weight' => 1,
'type' => MENU_CALLBACK);
@@ -1696,21 +1696,15 @@ function node_page() {
return node_preview($edit);
}
break;
- case 'delete':
+
case t('Delete'):
// Note: we redirect from node/uid/edit to node/uid/delete to make the tabs disappear.
- if ($_GET['q'] == 'node/'. arg(1) .'/edit') {
+ if ($_REQUEST['destination']) {
+ $destination = drupal_get_destination();
unset($_REQUEST['destination']);
- drupal_goto('node/'. arg(1) .'/delete');
}
- $edit['nid'] = $edit['nid'] ? $edit['nid'] : arg(1);
- $output = node_delete($edit);
- if (!$output) {
- drupal_set_message(t('The node has been deleted.'));
- drupal_goto('admin/node');
- }
- return node_delete($edit);
- break;
+ drupal_goto('node/'. arg(1) .'/delete', $destination);
+
default:
drupal_set_title('');
return node_page_default();
@@ -1718,6 +1712,20 @@ function node_page() {
}
/**
+ * Menu callback; the page for deleting a single node.
+ */
+function node_delete_page() {
+ $edit = $_POST['edit'];
+ $edit['nid'] = $edit['nid'] ? $edit['nid'] : arg(1);
+ $node = node_load($edit['nid']);
+ if (!($output = node_delete($edit))) {
+ drupal_set_message(t('%title has been deleted.', array('%title' => theme('placeholder', $node->title))));
+ drupal_goto('');
+ }
+ return $output;
+}
+
+/**
* Implementation of hook_update_index().
*/
function node_update_index() {
diff --git a/modules/node/node.module b/modules/node/node.module
index cc1d36a40..9871ae87e 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -673,7 +673,7 @@ function node_menu($may_cache) {
'weight' => 1,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('delete'),
- 'callback' => 'node_page',
+ 'callback' => 'node_delete_page',
'access' => node_access('delete', $node),
'weight' => 1,
'type' => MENU_CALLBACK);
@@ -1696,21 +1696,15 @@ function node_page() {
return node_preview($edit);
}
break;
- case 'delete':
+
case t('Delete'):
// Note: we redirect from node/uid/edit to node/uid/delete to make the tabs disappear.
- if ($_GET['q'] == 'node/'. arg(1) .'/edit') {
+ if ($_REQUEST['destination']) {
+ $destination = drupal_get_destination();
unset($_REQUEST['destination']);
- drupal_goto('node/'. arg(1) .'/delete');
}
- $edit['nid'] = $edit['nid'] ? $edit['nid'] : arg(1);
- $output = node_delete($edit);
- if (!$output) {
- drupal_set_message(t('The node has been deleted.'));
- drupal_goto('admin/node');
- }
- return node_delete($edit);
- break;
+ drupal_goto('node/'. arg(1) .'/delete', $destination);
+
default:
drupal_set_title('');
return node_page_default();
@@ -1718,6 +1712,20 @@ function node_page() {
}
/**
+ * Menu callback; the page for deleting a single node.
+ */
+function node_delete_page() {
+ $edit = $_POST['edit'];
+ $edit['nid'] = $edit['nid'] ? $edit['nid'] : arg(1);
+ $node = node_load($edit['nid']);
+ if (!($output = node_delete($edit))) {
+ drupal_set_message(t('%title has been deleted.', array('%title' => theme('placeholder', $node->title))));
+ drupal_goto('');
+ }
+ return $output;
+}
+
+/**
* Implementation of hook_update_index().
*/
function node_update_index() {