summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2007-06-22 05:44:21 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2007-06-22 05:44:21 +0000
commit38a1300df2005f9f054f19d8d2bd41518a8e7ad8 (patch)
tree0dc73c018fc63f74500593f7c533c902bbd5f54d /modules/system
parentc5443d739e8caa07a55080acc06d806c0d0758fa (diff)
downloadbrdo-38a1300df2005f9f054f19d8d2bd41518a8e7ad8.tar.gz
brdo-38a1300df2005f9f054f19d8d2bd41518a8e7ad8.tar.bz2
#147723: Deletion API (by hunmonk). Woop woop.
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.module52
1 files changed, 35 insertions, 17 deletions
diff --git a/modules/system/system.module b/modules/system/system.module
index a2c3c6df5..3b221f204 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2420,21 +2420,26 @@ function system_node_type($op, $info) {
* block <em>foo</em>?").
* @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.
+ * Can be either a Drupal path, or an array with the keys 'path', 'query', 'fragment'.
+ * @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".
+ * 'destination' => A destination page to go to after form submission -- the value can
+ * be of any form of the $goto argument accepted by drupal_redirect().
+ *
* @return
* The form.
*/
-function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
- $description = isset($description) ? $description : t('This action cannot be undone.');
+function confirm_form($form, $question, $path, $options = array()) {
+ $description = isset($options['description']) ? $options['description'] : t('This action cannot be undone.');
+ $name = isset($options['name']) ? $options['name'] : 'confirm';
// Prepare cancel link
$query = $fragment = NULL;
@@ -2443,25 +2448,38 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL,
$fragment = isset($path['fragment']) ? $path['fragment'] : NULL;
$path = isset($path['path']) ? $path['path'] : NULL;
}
- $cancel = l($no ? $no : t('Cancel'), $path, array('query' => $query, 'fragment' => $fragment));
+ $cancel = l(isset($options['no']) ? $options['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);
+ if (isset($options['destination'])) {
+ $form['destination'] = array('#type' => 'value', '#value' => $options['destination']);
+ }
$form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
+ $form['actions']['submit'] = array('#type' => 'submit', '#value' => isset($options['yes']) ? $options['yes'] : t('Delete'));
$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.
*/
function system_admin_compact_mode() {