Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.507 diff -u -F^f -r1.507 node.module --- modules/node.module 18 Jul 2005 08:46:30 -0000 1.507 +++ modules/node.module 18 Jul 2005 21:58:34 -0000 @@ -673,7 +678,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 +1716,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 +1732,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() { Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.457 diff -u -F^f -r1.457 common.inc --- includes/common.inc 6 Jul 2005 14:20:11 -0000 1.457 +++ includes/common.inc 18 Jul 2005 21:58:35 -0000 @@ -133,20 +133,26 @@ 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. * * @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)); } /**