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. --- includes/common.inc | 162 +++------------------------------------------------- includes/form.inc | 12 +++- includes/locale.inc | 4 +- 3 files changed, 19 insertions(+), 159 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index e4db9acc7..b20da7e74 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -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' => '
  • ', - * '#suffix' => "
  • \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'] : ''; - 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(''); } } } @@ -3521,4 +3373,4 @@ function drupal_implode_tags($tags) { $encoded_tags[] = $tag; } return implode(', ', $encoded_tags); -} \ No newline at end of file +} diff --git a/includes/form.inc b/includes/form.inc index b9648e236..f29d95e7d 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -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']); + } } /** diff --git a/includes/locale.inc b/includes/locale.inc index 8c364e958..5dd97f730 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -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')); } } -- cgit v1.2.3