Commit e59852d3 authored by Dries's avatar Dries

- 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.
parent c11cb4ec
......@@ -2804,154 +2804,6 @@ function drupal_common_themes() {
);
}
/**
* @ingroup deletionapi
* @{
*/
/**
* Used to begin a new deletion package. A package is set of deletion
* queries associated with a particular kind of deletion -- for example,
* all the queries associated with a node deletion. Most often it will
* not be necessary to start a new package, as most non-core deletions will
* already be part of a package initiated by core. Once a package has
* been started, all metadata, callbacks, and queries are added to the package.
* A package is complete when either a new package is started, or when a
* confirm or execute command is given.
*
* @param $type
* The deletion type for the package, ex. 'node', 'user', 'comment'.
* @param $id
* A unique identifier for the package. By convention this is the primary
* key of the 'root' deletion, ex. the nid for node type deletions, the uid
* for user type deletions, etc.
*/
function drupal_delete_initiate($type, $id) {
_drupal_delete('new package', array('type' => $type, 'id' => $id));
}
/**
* Pass a deletion query into a deletion package.
*
* @param $query
* The query to be passed, followed by any additional arguments for escaped values.
* ex. drupal_delete_add_query('DELETE FROM {comments} WHERE nid = %d', $node->nid);
* The additional arguments can be passed in any fashion that db_query() accepts.
*/
function drupal_delete_add_query($query) {
$all_args = func_get_args();
array_unshift($all_args, 'query', '');
call_user_func_array('_drupal_delete', $all_args);
}
/**
* Initiates the confirmation cycle. This command fully builds all packages
* for deletion, and returns a confirm form array containing any injected messages
* which can be used to print a confirmation screen.
*
* @code
* drupal_delete_confirm(
* array(
* 'form' => $form,
* 'question' => t('Are you sure you want to delete these items?'),
* 'destination' => 'admin/content/node',
* 'yes' => t('Delete all'),
* )
* );
* @endcode
*
* @param $confirm
* An associative array with the following key/value pairs:
* 'form' => Optional. An array representing the form elements to pass to the confirm form.
* 'question' => Optional. The question for the confirm form.
* 'destination' => Optional. The destination path for form submissions and form cancellations.
*
* Also, any valid options from the $options argument of confirm_form() may
* be passed, and they will be passed through to the confirm form.
*/
function drupal_delete_confirm($confirm) {
return _drupal_delete('confirm', '', $confirm);
}
/**
* Initiates the deletion of all constructed packages. Confirmation messages
* are bypassed, but abort messages are respected.
*
* @param $destination
* Optional. A destination to go to after all packages are executed.
* Can be either a Drupal path, or an array with the keys 'path', 'query', 'fragment'.
*/
function drupal_delete_execute($destination = FALSE) {
_drupal_delete('execute', '', array('destination' => $destination));
}
/**
* Register post-deletion callback functions for a package. The functions are called after the package
* has been deleted. Useful for miscellaneous cleanup, user messages, etc.
*
* @code
* drupal_delete_add_callback(
* array(
* 'node_delete_post' => array($node->nid, $node->title, $node->type),
* )
* );
* @endcode
*
* @param $callbacks
* An associative array of callback functions, key = name of function,
* value = an array of arguments to pass to the function.
*/
function drupal_delete_add_callback($callbacks) {
_drupal_delete('callback', '', $callbacks);
}
/**
* Pass metadata related to the deletion or package to the API. This is made
* available to all hooks called during the deletion cycle.
*
* @code
* drupal_delete_add_metadata(
* array(
* 'comment_messages' => $messages,
* )
* );
* @endcode
*
* @param $metadata
* An associative array of metadata.
*/
function drupal_delete_add_metadata($metadata) {
_drupal_delete('metadata', '', $metadata);
}
/**
* Pass in a package-specific set of form elements, to be displayed in the
* confirm form. Use this in multiple deletion scenarios where the confirm
* information shouldn't be displayed if the package is aborted.
*
* @code
* drupal_delete_add_form_elements(
* array(
* "node_$node->nid" => array(
* '#value' => check_plain($node->title),
* '#prefix' => '<li>',
* '#suffix' => "</li>\n",
* ),
* )
* );
* @endcode
*
* @param $elements
* An array representing the package-specific form elements to pass to the confirm form.
*/
function drupal_delete_add_form_elements($elements) {
_drupal_delete('form', '', $elements);
}
/**
* @} End of "ingroup deletionapi".
*/
/**
* Create/build/execute deletion packages.
*
......@@ -3096,8 +2948,8 @@ function _drupal_delete($op, $id = '') {
// Generate the confirm form if any packages remain.
if ($count) {
$question = isset($args['question']) ? $args['question'] : t('Delete the item?');
$path = isset($args['destination']) ? $args['destination'] : '<front>';
unset($args['question'], $args['destination']);
$path = isset($args['path']) ? $args['path'] : 'node';
unset($args['question'], $args['path']);
$args['name'] = 'delete';
// Submit handler - triggers execute operation for the API.
$form['#submit'] = array('delete_confirm_submit');
......@@ -3108,12 +2960,12 @@ function _drupal_delete($op, $id = '') {
drupal_goto($abort_destination);
}
// Fallback to cancel path.
elseif (isset($args['cancel'])) {
drupal_goto($args['cancel']);
elseif (isset($args['path'])) {
drupal_goto($args['path']);
}
// Last fallback, submit destination.
// Last fallback, front page.
else {
drupal_goto($path);
drupal_goto('<front>');
}
}
}
......@@ -3521,4 +3373,4 @@ function drupal_implode_tags($tags) {
$encoded_tags[] = $tag;
}
return implode(', ', $encoded_tags);
}
\ No newline at end of file
}
......@@ -485,7 +485,17 @@ function drupal_redirect_form($form, $redirect = NULL) {
if ($goto !== FALSE && isset($form['#redirect'])) {
$goto = $form['#redirect'];
}
drupal_redirect(isset($goto) ? $goto : NULL);
if (!isset($goto) || ($goto !== FALSE)) {
if (isset($goto)) {
if (is_array($goto)) {
call_user_func_array('drupal_goto', $goto);
}
else {
drupal_goto($goto);
}
}
drupal_goto($_GET['q']);
}
}
/**
......
......@@ -393,9 +393,7 @@ function locale_languages_delete_form(&$form_state, $langcode) {
}
else {
$form['langcode'] = array('#type' => 'value', '#value' => $langcode);
$options = array('description' => t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'));
return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$langcode]->name))), 'admin/settings/language', $options);
return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$langcode]->name))), 'admin/settings/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel'));
}
}
......
......@@ -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'));
}
/**
......
......@@ -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;
}
}
......
......@@ -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('<front>');
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');
......
......@@ -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');
......
......@@ -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.'));
......
......@@ -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'));
}
/**
......
......@@ -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();
......
......@@ -392,9 +392,7 @@ function node_type_delete_confirm(&$form_state, $type) {
$caption .= '<p>'. t('This action cannot be undone.') .'</p>';
$options = array('description' => $caption);
return confirm_form($form, $message, 'admin/content/types', $options);
return confirm_form($form, $message, 'admin/content/types', $caption, t('Delete'));
}
/**
......
......@@ -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'] : '<front>',
)
);
$form_state['redirect'] = '<front>';
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));
}
/**
......
......@@ -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) {
......
......@@ -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);
}
/**
......
......@@ -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 <a href="@edit-field">edit this field</a> 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 <a href="@edit-field">edit this field</a> 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'));
}
/**
......
......@@ -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'));
}
/**
......
......@@ -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);
}
}
......
......@@ -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' => '<p>'. t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') .'</p>'. 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 <em>foo</em>?").
* @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", ...).