summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-11-04 19:40:28 +0000
committerDries Buytaert <dries@buytaert.net>2005-11-04 19:40:28 +0000
commitb4644f8e668effe5e26309794efab59608c8fd56 (patch)
tree867bc883d9e54481fd767430b79b7865faea5c6b /modules/node/node.module
parent2ad97f0277c4eff591c4a7b826ad182e629a7f94 (diff)
downloadbrdo-b4644f8e668effe5e26309794efab59608c8fd56.tar.gz
brdo-b4644f8e668effe5e26309794efab59608c8fd56.tar.bz2
- Patch #36250 by hunmonk: admin batch delete broken, node_delete needs reworked.
This commit changes the node_delete() API. A list of affected modules is available at http://drupal.org/node/36250#comment-52963.
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module77
1 files changed, 37 insertions, 40 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index a7665d5c1..bc9881bd5 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -900,7 +900,7 @@ function node_menu($may_cache) {
'weight' => 1,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('delete'),
- 'callback' => 'node_delete_page',
+ 'callback' => 'node_delete_confirm',
'access' => node_access('delete', $node),
'weight' => 1,
'type' => MENU_CALLBACK);
@@ -1103,8 +1103,8 @@ function node_admin_nodes_execute($form_id, $edit) {
}
}
drupal_set_message(t('The update has been performed.'));
+ drupal_goto('admin/node');
}
- drupal_goto('admin/node');
}
function node_admin_nodes_validate($form_id, $edit) {
@@ -1192,11 +1192,11 @@ function theme_node_admin_nodes($form) {
function node_multiple_delete_form() {
global $form_values;
- $form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>');
+ $form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
foreach ($form_values['nodes'] as $nid => $value) {
if ($value) {
$title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
- $form['nodes'][$nid] = array('#type' => 'hidden', '#value' => $nid, '#tree' => TRUE, '#prefix' => '<li>', '#suffix' => check_plain($title) .'</li>');
+ $form['nodes'][$nid] = array('#type' => 'hidden', '#value' => $nid, '#prefix' => '<li>', '#suffix' => check_plain($title) .'</li>');
}
}
$form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
@@ -1211,7 +1211,7 @@ function node_multiple_delete_form() {
function node_multiple_delete_form_execute($form_id, $edit) {
if ($edit['confirm']) {
foreach ($edit['nodes'] as $nid => $value) {
- node_delete(array('nid' => $nid, 'confirm' => 1));
+ node_delete($nid);
}
drupal_set_message(t('The items have been deleted.'));
}
@@ -1833,13 +1833,15 @@ function node_form_execute($form_id, $edit) {
}
/**
- * Ask for confirmation, and delete the node.
+ * Menu callback -- ask for confirmation of node deletion
*/
-function node_delete($edit) {
+function node_delete_confirm() {
+ $edit = $_POST['edit'];
+ $edit['nid'] = $edit['nid'] ? $edit['nid'] : arg(1);
$node = node_load($edit['nid']);
if (node_access('delete', $node)) {
- $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
+ $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
$output = confirm_form('node_delete_confirm', $form,
t('Are you sure you want to delete %title?', array('%title' => theme('placeholder', $node->title))),
$_GET['destination'] ? $_GET['destination'] : 'node/'. $node->nid, t('This action cannot be undone.'),
@@ -1849,32 +1851,41 @@ function node_delete($edit) {
return $output;
}
-function node_delete_confirm_execute() {
- global $form_values;
- $node = node_load($form_values['nid']);
+/**
+ * Execute node deletion
+ */
+function node_delete_confirm_execute($form_id, $form_values) {
+ if ($form_values['confirm']) {
+ node_delete($form_values['nid']);
+ drupal_goto('node');
+ }
+}
- if (node_access('delete', $node)) {
+/**
+ * Delete a node.
+ */
+function node_delete($nid) {
- if ($form_values['confirm']) {
- db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
- db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
+ $node = node_load($nid);
- // Call the node-specific callback (if any):
- node_invoke($node, 'delete');
- node_invoke_nodeapi($node, 'delete');
+ if (node_access('delete', $node)) {
+ db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
+ db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
- // Clear the cache so an anonymous poster can see the node being deleted.
- cache_clear_all();
+ // Call the node-specific callback (if any):
+ node_invoke($node, 'delete');
+ node_invoke_nodeapi($node, 'delete');
- // Remove this node from the search index if needed.
- if (function_exists('search_wipe')) {
- search_wipe($node->nid, 'node');
- }
+ // Clear the cache so an anonymous poster can see the node being deleted.
+ cache_clear_all();
- watchdog('content', t('%type: deleted %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))));
+ // Remove this node from the search index if needed.
+ if (function_exists('search_wipe')) {
+ search_wipe($node->nid, 'node');
}
+ drupal_set_message(t('%title has been deleted.', array('%title' => theme('placeholder', $node->title))));
+ watchdog('content', t('%type: deleted %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))));
}
- drupal_goto('node');
}
/**
@@ -1996,20 +2007,6 @@ 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() {