From e59852d336467e7269853724a28d80bc070bcbf6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 1 Jul 2007 17:41:16 +0000 Subject: - Rollback of patch #147723: delete API. Talked to Steven and Gabor and we unanimously agreed to rollback the deletion API. We all support the features this patch added, yet not its actual design and implementation. After some talk, we decided that it would be better for Drupal -- in the long term -- not to go with a solution that isn't 100%. We also recognize that in the short term, this patch would have been useful addition. So let's figure out how we can implement this properly in D7. --- modules/block/block.module | 2 +- modules/book/book.module | 4 +- modules/comment/comment.module | 70 +++++++++++++++------------- modules/contact/contact.module | 2 +- modules/filter/filter.module | 4 +- modules/forum/forum.module | 8 ++-- modules/menu/menu.module | 7 ++- modules/node/content_types.inc | 4 +- modules/node/node.module | 62 ++++++++++++------------- modules/path/path.module | 9 ++-- modules/poll/poll.module | 6 +-- modules/profile/profile.module | 6 +-- modules/search/search.module | 7 +-- modules/statistics/statistics.module | 2 +- modules/system/system.module | 90 ++++++++++++------------------------ modules/taxonomy/taxonomy.module | 18 ++++---- modules/upload/upload.module | 31 ++++--------- modules/user/user.module | 19 ++++---- 18 files changed, 148 insertions(+), 203 deletions(-) (limited to 'modules') diff --git a/modules/block/block.module b/modules/block/block.module index 72ae78d0e..10f3bf1a5 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -566,7 +566,7 @@ function block_box_delete(&$form_state, $bid = 0) { $form['info'] = array('#type' => 'hidden', '#value' => $box['info'] ? $box['info'] : $box['title']); $form['bid'] = array('#type' => 'hidden', '#value' => $bid); - return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $box['info'])), 'admin/build/block'); + return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $box['info'])), 'admin/build/block', '', t('Delete'), t('Cancel')); } /** diff --git a/modules/book/book.module b/modules/book/book.module index 8fea8fd7c..f21e574f8 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -466,10 +466,10 @@ function book_nodeapi(&$node, $op, $teaser, $page) { } break; case 'delete revision': - drupal_delete_add_query('DELETE FROM {book} WHERE vid = %d', $node->vid); + db_query('DELETE FROM {book} WHERE vid = %d', $node->vid); break; case 'delete': - drupal_delete_add_query('DELETE FROM {book} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {book} WHERE nid = %d', $node->nid); break; } } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8266aebfa..495637b94 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -231,8 +231,7 @@ function comment_menu() { $items['comment/delete'] = array( 'title' => 'Delete comment', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('comment_delete', 2), + 'page callback' => 'comment_delete', 'access arguments' => array('administer comments'), 'type' => MENU_CALLBACK, ); @@ -474,8 +473,8 @@ function comment_nodeapi(&$node, $op, $arg = 0) { break; case 'delete': - drupal_delete_add_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); - drupal_delete_add_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); break; case 'update index': @@ -1093,43 +1092,50 @@ function comment_render($node, $cid = 0) { /** * Menu callback; delete a comment. */ -function comment_delete(&$form_state, $cid = NULL) { +function comment_delete($cid = NULL) { $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid)); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - if (is_object($comment) && is_numeric($comment->cid)) { - drupal_delete_initiate('comment', $comment->cid); - drupal_delete_add_callback( - array( - 'comment_delete_post' => array($comment), - // Clear the cache so an anonymous poster can see the node being deleted. - 'cache_clear_all' => array(), - ) - ); - - // Delete comment and its replies. - _comment_delete_thread($comment); + $output = ''; - return drupal_delete_confirm( - array( - 'question' => t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)), - 'destination' => 'node/'. $comment->nid, - 'description' => t('Any replies to this comment will be lost. This action cannot be undone.'), - ) - ); + if (is_object($comment) && is_numeric($comment->cid)) { + $output = drupal_get_form('comment_confirm_delete', $comment); } else { - drupal_set_message(t('The comment no longer exists.'), 'error'); - drupal_goto(''); + drupal_set_message(t('The comment no longer exists.')); } + + return $output; +} + +function comment_confirm_delete(&$form_state, $comment) { + $form = array(); + $form['#comment'] = $comment; + return confirm_form( + $form, + t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)), + 'node/'. $comment->nid, + t('Any replies to this comment will be lost. This action cannot be undone.'), + t('Delete'), + t('Cancel'), + 'comment_confirm_delete'); } -function comment_delete_post($comment) { +function comment_confirm_delete_submit($form, &$form_state) { + drupal_set_message(t('The comment and all its replies have been deleted.')); - drupal_set_message(t('The comment %subject and all its replies have been deleted.', array('%subject' => $comment->subject))); - watchdog('content', 'Comment: deleted %subject and all its replies.', array('%subject' => $comment->subject)); + $comment = $form['#comment']; + + // Delete comment and its replies. + _comment_delete_thread($comment); _comment_update_node_statistics($comment->nid); + + // Clear the cache so an anonymous user sees that his comment was deleted. + cache_clear_all(); + + $form_state['redirect'] = "node/$comment->nid"; + return; } /** @@ -1342,8 +1348,9 @@ function comment_multiple_delete_confirm(&$form_state) { array( 'form' => $form, 'question' => t('Are you sure you want to delete these comments and all their children?'), - 'destination' => 'admin/content/comment', + 'path' => 'admin/content/comment', 'yes' => t('Delete all'), + 'destination' => 'admin/content/comment', ) ); } @@ -1917,7 +1924,8 @@ function _comment_delete_thread($comment) { } // Delete the comment: - drupal_delete_add_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); + db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); + watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject)); comment_invoke_comment($comment, 'delete'); diff --git a/modules/contact/contact.module b/modules/contact/contact.module index 7b53d6be6..cb628bbac 100644 --- a/modules/contact/contact.module +++ b/modules/contact/contact.module @@ -265,7 +265,7 @@ function contact_admin_delete(&$form_state, $cid = NULL) { '#value' => $info->category, ); - return confirm_form($form, t('Are you sure you want to delete %category?', array('%category' => $info->category)), 'admin/build/contact'); + return confirm_form($form, t('Are you sure you want to delete %category?', array('%category' => $info->category)), 'admin/build/contact', t('This action cannot be undone.'), t('Delete'), t('Cancel')); } else { drupal_set_message(t('Category not found.'), 'error'); diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 7e0cc011f..f3c2e38ea 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -336,9 +336,7 @@ function filter_admin_delete() { $form['format'] = array('#type' => 'hidden', '#value' => $format->format); $form['name'] = array('#type' => 'hidden', '#value' => $format->name); - $options = array('description' => t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.')); - - return confirm_form($form, t('Are you sure you want to delete the input format %format?', array('%format' => $format->name)), 'admin/settings/filters', $options); + return confirm_form($form, t('Are you sure you want to delete the input format %format?', array('%format' => $format->name)), 'admin/settings/filters', t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.'), t('Delete'), t('Cancel')); } else { drupal_set_message(t('The default format cannot be deleted.')); diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 1352911b8..09519e390 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -169,7 +169,7 @@ function forum_perm() { function forum_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'delete revision': - drupal_delete_add_query('DELETE FROM {forum} WHERE vid = %d', $node->vid); + db_query('DELETE FROM {forum} WHERE vid = %d', $node->vid); break; } } @@ -453,7 +453,7 @@ function forum_insert($node) { * Implementation of hook_delete(). */ function forum_delete(&$node) { - drupal_delete_add_query('DELETE FROM {forum} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid); } /** @@ -610,9 +610,7 @@ function forum_confirm_delete(&$form_state, $tid) { $form['tid'] = array('#type' => 'value', '#value' => $tid); $form['name'] = array('#type' => 'value', '#value' => $term->name); - $options = array('description' => t('Deleting a forum or container will delete all sub-forums and associated posts as well. This action cannot be undone.')); - - return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%name' => $term->name)), 'admin/content/forum', $options); + return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%name' => $term->name)), 'admin/content/forum', t('Deleting a forum or container will delete all sub-forums and associated posts as well. This action cannot be undone.'), t('Delete'), t('Cancel')); } /** diff --git a/modules/menu/menu.module b/modules/menu/menu.module index bc29cd928..6376cb111 100644 --- a/modules/menu/menu.module +++ b/modules/menu/menu.module @@ -464,7 +464,7 @@ function menu_item_delete_form(&$form_state, $mlid) { } $form['#item'] = $item; - return confirm_form($form, t('Are you sure you want to delete the custom menu item %item?', array('%item' => $item['link_title'])), 'admin/build/menu/'. $item['menu_name']); + return confirm_form($form, t('Are you sure you want to delete the custom menu item %item?', array('%item' => $item['link_title'])), 'admin/build/menu/'. $item['menu_name'], t('This action cannot be undone.'), t('Delete')); } /** @@ -488,11 +488,10 @@ function menu_reset_item(&$form_state, $mlid) { $options = array( 'description' => t('Any customizations will be lost. This action cannot be undone.'), - 'yes' => t('Reset'), - 'cancel' => 'admin/build/menu', + 'yes' => t('Reset') ); - return confirm_form($form, t('Are you sure you want to reset the item %item to its default values?', array('%item' => $item['link_title'])), 'admin/build/menu/navigation', $options); + return confirm_form($form, t('Are you sure you want to reset the item %item to its default values?', array('%item' => $item['link_title'])), 'admin/build/menu', $options); } else { drupal_not_found(); diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index 8340544c5..d4999d637 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -392,9 +392,7 @@ function node_type_delete_confirm(&$form_state, $type) { $caption .= '

'. t('This action cannot be undone.') .'

'; - $options = array('description' => $caption); - - return confirm_form($form, $message, 'admin/content/types', $options); + return confirm_form($form, $message, 'admin/content/types', $caption, t('Delete')); } /** diff --git a/modules/node/node.module b/modules/node/node.module index e2ef093e3..2d7d19021 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1089,13 +1089,8 @@ function node_configure_validate($form, &$form_state) { * Menu callback: confirm rebuilding of permissions. */ function node_configure_rebuild_confirm() { - $options = array( - 'description' => t('This will wipe all current node permissions and rebuild them based on current settings. Rebuilding the permissions may take a while so please be patient. This action cannot be undone.'), - 'yes' => t('Rebuild permissions') - ); - return confirm_form(array(), t('Are you sure you want to rebuild node permissions on the site?'), - 'admin/content/node-settings', $options); + 'admin/content/node-settings', t('This will wipe all current node permissions and rebuild them based on current settings. Rebuilding the permissions may take a while so please be patient. This action cannot be undone.'), t('Rebuild permissions'), t('Cancel')); } /** @@ -1751,8 +1746,9 @@ function node_multiple_delete_confirm(&$form_state) { array( 'form' => $form, 'question' => t('Are you sure you want to delete these items?'), - 'destination' => 'admin/content/node', + 'path' => 'admin/content/node', 'yes' => t('Delete all'), + 'destination' => 'admin/content/node', ) ); } @@ -2435,25 +2431,25 @@ function node_form_submit($form, &$form_state) { * Menu callback -- ask for confirmation of node deletion */ function node_delete_confirm(&$form_state, $node) { + $form['nid'] = array('#type' => 'value', '#value' => $node->nid); - drupal_delete_initiate('node', $node->nid); - drupal_delete_add_callback( - array( - 'node_delete_post' => array($node->nid, $node->title, $node->type), - // Clear the cache so an anonymous poster can see the node being deleted. - 'cache_clear_all' => array(), - ) - ); + return confirm_form($form, + t('Are you sure you want to delete %title?', array('%title' => $node->title)), + isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid, + t('This action cannot be undone.'), + t('Delete'), t('Cancel')); +} - node_delete($node->nid, FALSE); +/** + * Execute node deletion + */ +function node_delete_confirm_submit($form, &$form_state) { + if ($form_state['values']['confirm']) { + node_delete($form_state['values']['nid']); + } - return drupal_delete_confirm( - array( - 'question' => t('Are you sure you want to delete %title?', array('%title' => $node->title)), - 'cancel' => isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid, - 'destination' => isset($_GET['destination']) ? $_GET['destination'] : '', - ) - ); + $form_state['redirect'] = ''; + return; } /** @@ -2464,23 +2460,23 @@ function node_delete($nid) { $node = node_load($nid); if (node_access('delete', $node)) { - drupal_delete_add_query('DELETE FROM {node} WHERE nid = %d', $node->nid); - drupal_delete_add_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); // Call the node-specific callback (if any): node_invoke($node, 'delete'); node_invoke_nodeapi($node, 'delete'); - } -} -function node_delete_post($nid, $title, $type) { + // Clear the cache so an anonymous poster can see the node being deleted. + cache_clear_all(); - // Remove this node from the search index if needed. - if (function_exists('search_wipe')) { - search_wipe($nid, 'node'); + // 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' => $node->title))); + watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title)); } - drupal_set_message(t('%title has been deleted.', array('%title' => $title))); - watchdog('content', '@type: deleted %title.', array('@type' => t($type), '%title' => $title)); } /** diff --git a/modules/path/path.module b/modules/path/path.module index e709df0e8..cd0643402 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -89,14 +89,13 @@ function path_admin_edit($pid = 0) { /** * Menu callback; confirms deleting an URL alias **/ -function path_admin_delete_confirm(&$form_state, $pid) { +function path_admin_delete_confirm($pid) { $path = path_load($pid); if (user_access('administer url aliases')) { $form['pid'] = array('#type' => 'value', '#value' => $pid); - $options = array('cancel' => isset($_GET['destination']) ? $_GET['destination'] : 'admin/build/path'); $output = confirm_form($form, t('Are you sure you want to delete path alias %title?', array('%title' => $path['dst'])), - 'admin/build/path', $options); + isset($_GET['destination']) ? $_GET['destination'] : 'admin/build/path'); } return $output; } @@ -126,12 +125,12 @@ function path_admin_delete($pid = 0) { function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '') { if ($path && !$alias) { // Delete based on path - drupal_delete_add_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language); + db_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language); drupal_clear_path_cache(); } else if (!$path && $alias) { // Delete based on alias - drupal_delete_add_query("DELETE FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language); + db_query("DELETE FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language); drupal_clear_path_cache(); } else if ($path && $alias) { diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 4a4141c51..15585d90a 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -91,9 +91,9 @@ function poll_cron() { * Implementation of hook_delete(). */ function poll_delete($node) { - drupal_delete_add_query('DELETE FROM {poll} WHERE nid = %d', $node->nid); - drupal_delete_add_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid); - drupal_delete_add_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid); + db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid); + db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid); + db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid); } /** diff --git a/modules/profile/profile.module b/modules/profile/profile.module index 74a27513d..66ab22967 100644 --- a/modules/profile/profile.module +++ b/modules/profile/profile.module @@ -398,10 +398,10 @@ function profile_field_delete(&$form_state, $fid) { $form['fid'] = array('#type' => 'value', '#value' => $fid); $form['title'] = array('#type' => 'value', '#value' => $field->title); - $options = array('description' => t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to edit this field and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/'. $fid)))); - return confirm_form($form, - t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/user/profile', $options); + t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/user/profile', + t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to edit this field and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/'. $fid))), + t('Delete'), t('Cancel')); } /** diff --git a/modules/search/search.module b/modules/search/search.module index 1ae52e456..d19b6cd4b 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -262,13 +262,8 @@ function search_admin_settings() { * Menu callback: confirm wiping of the index. */ function search_wipe_confirm() { - $options = array( - 'description' => t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), - 'yes' => t('Re-index site') - ); - return confirm_form(array(), t('Are you sure you want to re-index the site?'), - 'admin/settings/search', $options); + 'admin/settings/search', t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel')); } /** diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 8973736e9..ce12dd15a 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -553,7 +553,7 @@ function statistics_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case 'delete': // clean up statistics table when node is deleted - drupal_delete_add_query('DELETE FROM {node_counter} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {node_counter} WHERE nid = %d', $node->nid); } } diff --git a/modules/system/system.module b/modules/system/system.module index 73f83cb13..cb14f61f0 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1690,18 +1690,14 @@ function system_modules_confirm_form($modules, $storage) { $form['text'] = array('#value' => theme('item_list', $items)); if ($form) { - $options = array( - 'description' => t('Would you like to continue with enabling the above?'), - 'yes' => t('Continue'), - ); - // Set some default form values $form = confirm_form( $form, t('Some required modules must be enabled'), 'admin/build/modules', - $options); - + t('Would you like to continue with enabling the above?'), + t('Continue'), + t('Cancel')); return $form; } } @@ -1991,17 +1987,13 @@ function system_modules_uninstall_confirm_form($storage) { $form['#confirmed'] = TRUE; $form['uninstall']['#tree'] = TRUE; $form['modules'] = array('#value' => '

'. t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') .'

'. theme('item_list', $uninstall)); - - $options = array( - 'description' => t('Would you like to continue with uninstalling the above?'), - 'yes' => t('Uninstall') - ); - $form = confirm_form( $form, t('Confirm uninstall'), 'admin/build/modules/uninstall', - $options); + t('Would you like to continue with uninstalling the above?'), + t('Uninstall'), + t('Cancel')); return $form; } } @@ -2484,71 +2476,49 @@ function system_node_type($op, $info) { * @param $question * The question to ask the user (e.g. "Are you sure you want to delete the * block foo?"). - * @param $destination - * The page to go to if the confirm form is submitted, or the action is cancelled. - * The value can be either a Drupal path, or an array with the keys 'path', 'query', 'fragment'. - * - * Note: If a custom submit handler is being used, return the destination from the handler. - * @param $options - * An associative array of options, with the following key/value pairs: - * 'description' => Additional text to display. - * Default is "This action cannot be undone". - * 'yes' => A caption for the button which confirms the action (e.g. "Confirm", - * "Replace", ...). Default is "Delete". - * 'no' => A caption for the link which denies the action (e.g. "Cancel"). - * Default is "Cancel". - * 'name' => The internal name used to refer to the confirmation item. - * Default is "confirm". - * 'cancel' => Set a custom path for cancelling the form, -- can be either a Drupal path, - * or an array with the keys 'path', 'query', 'fragment'. - * + * @param $path + * The page to go to if the user denies the action. + * Can be either a drupal path, or an array with the keys 'path', 'query', 'fragment'. + * @param $description + * Additional text to display (defaults to "This action cannot be undone."). + * @param $yes + * A caption for the button which confirms the action (e.g. "Delete", + * "Replace", ...). + * @param $no + * A caption for the link which denies the action (e.g. "Cancel"). + * @param $name + * The internal name used to refer to the confirmation item. * @return * The form. */ -function confirm_form($form, $question, $destination, $options = array()) { - $description = isset($options['description']) ? $options['description'] : t('This action cannot be undone.'); - $name = isset($options['name']) ? $options['name'] : 'confirm'; - $cancel = isset($options['cancel']) ? $options['cancel'] : $destination; +function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') { + $description = isset($description) ? $description : t('This action cannot be undone.'); // Prepare cancel link $query = $fragment = NULL; - if (is_array($cancel)) { - $query = isset($cancel['query']) ? $cancel['query'] : NULL; - $fragment = isset($cancel['fragment']) ? $cancel['fragment'] : NULL; - $path = isset($cancel['path']) ? $cancel['path'] : NULL; + if (is_array($path)) { + $query = isset($path['query']) ? $path['query'] : NULL; + $fragment = isset($path['fragment']) ? $path['fragment'] : NULL; + $path = isset($path['path']) ? $path['path'] : NULL; } - else { - $path = $cancel; - } - $cancel_link = l(isset($options['no']) ? $options['no'] : t('Cancel'), $path, array('query' => $query, 'fragment' => $fragment)); + $cancel = l($no ? $no : t('Cancel'), $path, array('query' => $query, 'fragment' => $fragment)); drupal_set_title($question); + // Confirm form fails duplication check, as the form values rarely change -- so skip it. + $form['#skip_duplicate_check'] = TRUE; + $form['#attributes'] = array('class' => 'confirmation'); $form['description'] = array('#value' => $description); $form[$name] = array('#type' => 'hidden', '#value' => 1); - $form['destination'] = array('#type' => 'value', '#value' => $destination); $form['actions'] = array('#prefix' => '
', '#suffix' => '
'); - $form['actions']['submit'] = array('#type' => 'submit', '#value' => isset($options['yes']) ? $options['yes'] : t('Delete')); - $form['actions']['cancel'] = array('#value' => $cancel_link); - + $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm')); + $form['actions']['cancel'] = array('#value' => $cancel); $form['#theme'] = 'confirm_form'; return $form; } -/** - * Executes confirmation pages for the Deletion API. - */ -function delete_confirm_submit($form, &$form_state) { - if ($form_state['values']['delete']) { - drupal_delete_execute(); - } - if (isset($form_state['values']['destination'])) { - $form_state['redirect'] = $form_state['values']['destination']; - } -} - /** * Determine if a user is in compact mode. */ diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 71fc80bef..03c164b47 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -384,14 +384,13 @@ function taxonomy_vocabulary_confirm_delete(&$form_state, $vid) { $form['type'] = array('#type' => 'value', '#value' => 'vocabulary'); $form['vid'] = array('#type' => 'value', '#value' => $vid); $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name); - - $options = array('description' => t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.')); - return confirm_form($form, t('Are you sure you want to delete the vocabulary %title?', array('%title' => $vocabulary->name)), 'admin/content/taxonomy', - $options); + t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), + t('Delete'), + t('Cancel')); } function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) { @@ -621,14 +620,13 @@ function taxonomy_term_confirm_delete(&$form_state, $tid) { $form['type'] = array('#type' => 'value', '#value' => 'term'); $form['name'] = array('#type' => 'value', '#value' => $term->name); $form['tid'] = array('#type' => 'value', '#value' => $tid); - - $options = array('description' => t('Deleting a term will delete all its children if there are any. This action cannot be undone.')); - return confirm_form($form, t('Are you sure you want to delete the term %title?', array('%title' => $term->name)), 'admin/content/taxonomy', - $options); + t('Deleting a term will delete all its children if there are any. This action cannot be undone.'), + t('Delete'), + t('Cancel')); } function taxonomy_term_confirm_delete_submit($form, &$form_state) { @@ -878,14 +876,14 @@ function taxonomy_node_save($node, $terms) { * Remove associations of a node to its terms. */ function taxonomy_node_delete($node) { - drupal_delete_add_query('DELETE FROM {term_node} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {term_node} WHERE nid = %d', $node->nid); } /** * Remove associations of a node to its terms. */ function taxonomy_node_delete_revision($node) { - drupal_delete_add_query('DELETE FROM {term_node} WHERE vid = %d', $node->vid); + db_query('DELETE FROM {term_node} WHERE vid = %d', $node->vid); } /** diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 43ae3f2f3..f8ddc5f86 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -575,44 +575,31 @@ function upload_delete($node) { } foreach ($files as $fid => $file) { - // Delete all file revision information associated with the node - drupal_delete_add_query('DELETE FROM {files} WHERE fid = %d', $fid); + // Delete all files associated with the node + db_query('DELETE FROM {files} WHERE fid = %d', $fid); + file_delete($file->filepath); } - // Delete all files associated with the node - drupal_delete_add_query('DELETE FROM {upload} WHERE nid = %d', $node->nid); - - // Register a callback to delete the files. - drupal_delete_add_callback(array('upload_delete_post' => array($files))); + // Delete all file revision information associated with the node + db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid); } function upload_delete_revision($node) { if (is_array($node->files)) { - $files = array(); foreach ($node->files as $file) { // Check if the file will be used after this revision is deleted $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $file->fid)); // if the file won't be used, delete it if ($count < 2) { - drupal_delete_add_query('DELETE FROM {files} WHERE fid = %d', $file->fid); - $files[$file->fid] = $file; + db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); + file_delete($file->filepath); } } } - // Delete the revision. - drupal_delete_add_query('DELETE FROM {upload} WHERE vid = %d', $node->vid); - - // Register a callback to delete the files. - drupal_delete_add_callback(array('upload_delete_post' => array($files))); -} - -function upload_delete_post($files) { - foreach ($files as $file) { - // Delete all files associated with the node or revision. - file_delete($file->filepath); - } + // delete the revision + db_query('DELETE FROM {upload} WHERE vid = %d', $node->vid); } function _upload_form($node) { diff --git a/modules/user/user.module b/modules/user/user.module index 188884290..baab4e935 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1621,15 +1621,12 @@ function user_edit($form_state, $category = 'account') { return $form; } -function user_confirm_delete(&$form_state, $name, $uid) { - $options = array( - 'description' => t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'), - 'cancel' => 'user/'. $uid, - ); +function user_confirm_delete($name, $uid) { + $options = array('description' => t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.')); return confirm_form(array(), t('Are you sure you want to delete the account %name?', array('%name' => $name)), - 'admin/user/user', + 'user/'. $uid, $options); } @@ -1863,7 +1860,10 @@ function user_admin_access_delete_confirm($aid = 0) { $form['aid'] = array('#type' => 'hidden', '#value' => $aid); $output = confirm_form($form, t('Are you sure you want to delete the @type rule for %rule?', array('@type' => $access_types[$edit->type], '%rule' => $edit->mask)), - 'admin/user/rules'); + 'admin/user/rules', + t('This action cannot be undone.'), + t('Delete'), + t('Cancel')); return $output; } @@ -2464,11 +2464,10 @@ function user_multiple_delete_confirm(&$form_state) { } $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); - $options = array('yes' => t('Delete all')); - return confirm_form($form, t('Are you sure you want to delete these users?'), - 'admin/user/user', $options); + 'admin/user/user', t('This action cannot be undone.'), + t('Delete all'), t('Cancel')); } function user_multiple_delete_confirm_submit($form, &$form_state) { -- cgit v1.2.3