From 9e4399aae82b43bd49c0a1558174ad494b6fbcdc Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Thu, 14 Oct 2004 15:28:24 +0000 Subject: #10677: Confirmation when deleting a block + unifying confirmation screens. --- modules/block.module | 83 +++++++++++++++++++--------------------- modules/block/block.module | 83 +++++++++++++++++++--------------------- modules/comment.module | 2 +- modules/comment/comment.module | 2 +- modules/filter.module | 14 +------ modules/filter/filter.module | 14 +------ modules/locale.module | 1 - modules/locale/locale.module | 1 - modules/taxonomy.module | 2 - modules/taxonomy/taxonomy.module | 2 - 10 files changed, 84 insertions(+), 120 deletions(-) (limited to 'modules') diff --git a/modules/block.module b/modules/block.module index 3b604f13a..6082c188b 100644 --- a/modules/block.module +++ b/modules/block.module @@ -61,10 +61,6 @@ function block_menu($may_cache) { 'access' => user_access('administer blocks'), 'callback' => 'block_box_edit', 'type' => MENU_CALLBACK); - $items[] = array('path' => 'admin/block/delete', 'title' => t('delete block'), - 'access' => user_access('administer blocks'), - 'callback' => 'block_box_delete', - 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/block/add', 'title' => t('add'), 'access' => user_access('administer blocks'), 'callback' => 'block_box_edit', @@ -175,22 +171,17 @@ function block_admin_display() { $formats[$box->bid] = $box->format; } - $header = array(t('Block'), t('Enabled'), t('Custom'), t('Throttle'), t('Weight'), t('Region'), t('Path'), array('data' => t('Operations'), 'colspan' => 2)); + $header = array(t('Block'), t('Enabled'), t('Custom'), t('Throttle'), t('Weight'), t('Region'), t('Path'), array('data' => t('Operations'))); foreach ($blocks as $block) { - if ($block['module'] == 'block') { - if (filter_access($formats[$block['delta']])) { - $edit = l(t('edit'), 'admin/block/edit/'. $block['delta']); - } - $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']); + if ($block['module'] == 'block' && filter_access($formats[$block['delta']])) { + $edit = l(t('edit block'), 'admin/block/edit/'. $block['delta']); } else { $edit = ''; - $delete = ''; } - $rows[] = array($block['info'], array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][custom', 1, $block['custom']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle'], NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled')), 'align' => 'center'), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], array(t('left'), t('right'))), form_textfield(NULL, $block['module'] .']['. $block['delta'] .'][path', $block['path'], 10, 255), - $edit, $delete); + $rows[] = array($block['info'], array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][custom', 1, $block['custom']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle'], NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled')), 'align' => 'center'), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], array(t('left'), t('right'))), form_textfield(NULL, $block['module'] .']['. $block['delta'] .'][path', $block['path'], 10, 255), $edit); } $output = theme('table', $header, $rows); @@ -212,36 +203,52 @@ function block_box_edit($bid = 0) { $edit = $_POST['edit']; $op = $_POST['op']; - if ($op == t('Save block')) { - drupal_set_message(block_box_save($edit)); - cache_clear_all(); - $output = block_admin_display(); - } - else { - if ($bid) { - $output = block_box_form(block_box_get($bid)); - } - else { - $output = block_box_form(); - } + switch ($op) { + case t('Save block'): + drupal_set_message(block_box_save($edit)); + cache_clear_all(); + drupal_goto('admin/block'); + + case t('Delete block'): + $form = '

'. t('Are you sure you want to delete the block %name?', array('%name' => ''. $edit['info'] .'')) ."

\n"; + $form .= form_submit(t('Delete')); + $output = form($form); + break; + + case t('Delete'): + db_query('DELETE FROM {boxes} WHERE bid = %d', $bid); + drupal_set_message(t('The block has been deleted.')); + cache_clear_all(); + drupal_goto('admin/block'); + + case t('Cancel'): + default: + if ($bid) { + $output = block_box_form(block_box_get($bid)); + } + else { + $output = block_box_form(); + } } print theme('page', $output); } function block_box_form($edit = array()) { - $group = form_textfield(t('Block title'), 'title', $edit['title'], 50, 64, t('The title of the block as shown to the user.')); - $group .= filter_form('format', $edit['format']); - $group .= form_textarea(t('Block body'), 'body', $edit['body'], 70, 10, t('The content of the block as shown to the user.')); - $group .= form_textfield(t('Block description'), 'info', $edit['info'], 50, 64, t('A brief description of your block. Used on the block overview page.', array('%overview' => url('admin/block')))); + $output = form_textfield(t('Block title'), 'title', $edit['title'], 50, 64, t('The title of the block as shown to the user.')); + $output .= filter_form('format', $edit['format']); + $output .= form_textarea(t('Block body'), 'body', $edit['body'], 70, 10, t('The content of the block as shown to the user.')); + $output .= form_textfield(t('Block description'), 'info', $edit['info'], 50, 64, t('A brief description of your block. Used on the block overview page.', array('%overview' => url('admin/block')))); if ($edit['bid']) { - $group .= form_hidden('bid', $edit['bid']); + $output .= form_hidden('bid', $edit['bid']); } - $group .= form_submit(t('Save block')); + $output .= form_submit(t('Save block')); + if ($edit['bid']) { + $output .= form_submit(t('Delete block')); + } - $output = form_group(t('Add a new block'), $group); return form($output); } @@ -260,18 +267,6 @@ function block_box_save($edit) { } } -/** - * Menu callback; deletes a custom box, then displays the overview page. - */ -function block_box_delete($bid = 0) { - if ($bid) { - db_query('DELETE FROM {boxes} WHERE bid = %d', $bid); - drupal_set_message(t('The block has been deleted.')); - cache_clear_all(); - } - print theme('page', block_admin_display()); -} - /** * Menu callback; displays the block overview page. */ diff --git a/modules/block/block.module b/modules/block/block.module index 3b604f13a..6082c188b 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -61,10 +61,6 @@ function block_menu($may_cache) { 'access' => user_access('administer blocks'), 'callback' => 'block_box_edit', 'type' => MENU_CALLBACK); - $items[] = array('path' => 'admin/block/delete', 'title' => t('delete block'), - 'access' => user_access('administer blocks'), - 'callback' => 'block_box_delete', - 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/block/add', 'title' => t('add'), 'access' => user_access('administer blocks'), 'callback' => 'block_box_edit', @@ -175,22 +171,17 @@ function block_admin_display() { $formats[$box->bid] = $box->format; } - $header = array(t('Block'), t('Enabled'), t('Custom'), t('Throttle'), t('Weight'), t('Region'), t('Path'), array('data' => t('Operations'), 'colspan' => 2)); + $header = array(t('Block'), t('Enabled'), t('Custom'), t('Throttle'), t('Weight'), t('Region'), t('Path'), array('data' => t('Operations'))); foreach ($blocks as $block) { - if ($block['module'] == 'block') { - if (filter_access($formats[$block['delta']])) { - $edit = l(t('edit'), 'admin/block/edit/'. $block['delta']); - } - $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']); + if ($block['module'] == 'block' && filter_access($formats[$block['delta']])) { + $edit = l(t('edit block'), 'admin/block/edit/'. $block['delta']); } else { $edit = ''; - $delete = ''; } - $rows[] = array($block['info'], array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][custom', 1, $block['custom']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle'], NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled')), 'align' => 'center'), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], array(t('left'), t('right'))), form_textfield(NULL, $block['module'] .']['. $block['delta'] .'][path', $block['path'], 10, 255), - $edit, $delete); + $rows[] = array($block['info'], array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][custom', 1, $block['custom']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle'], NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled')), 'align' => 'center'), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], array(t('left'), t('right'))), form_textfield(NULL, $block['module'] .']['. $block['delta'] .'][path', $block['path'], 10, 255), $edit); } $output = theme('table', $header, $rows); @@ -212,36 +203,52 @@ function block_box_edit($bid = 0) { $edit = $_POST['edit']; $op = $_POST['op']; - if ($op == t('Save block')) { - drupal_set_message(block_box_save($edit)); - cache_clear_all(); - $output = block_admin_display(); - } - else { - if ($bid) { - $output = block_box_form(block_box_get($bid)); - } - else { - $output = block_box_form(); - } + switch ($op) { + case t('Save block'): + drupal_set_message(block_box_save($edit)); + cache_clear_all(); + drupal_goto('admin/block'); + + case t('Delete block'): + $form = '

'. t('Are you sure you want to delete the block %name?', array('%name' => ''. $edit['info'] .'')) ."

\n"; + $form .= form_submit(t('Delete')); + $output = form($form); + break; + + case t('Delete'): + db_query('DELETE FROM {boxes} WHERE bid = %d', $bid); + drupal_set_message(t('The block has been deleted.')); + cache_clear_all(); + drupal_goto('admin/block'); + + case t('Cancel'): + default: + if ($bid) { + $output = block_box_form(block_box_get($bid)); + } + else { + $output = block_box_form(); + } } print theme('page', $output); } function block_box_form($edit = array()) { - $group = form_textfield(t('Block title'), 'title', $edit['title'], 50, 64, t('The title of the block as shown to the user.')); - $group .= filter_form('format', $edit['format']); - $group .= form_textarea(t('Block body'), 'body', $edit['body'], 70, 10, t('The content of the block as shown to the user.')); - $group .= form_textfield(t('Block description'), 'info', $edit['info'], 50, 64, t('A brief description of your block. Used on the block overview page.', array('%overview' => url('admin/block')))); + $output = form_textfield(t('Block title'), 'title', $edit['title'], 50, 64, t('The title of the block as shown to the user.')); + $output .= filter_form('format', $edit['format']); + $output .= form_textarea(t('Block body'), 'body', $edit['body'], 70, 10, t('The content of the block as shown to the user.')); + $output .= form_textfield(t('Block description'), 'info', $edit['info'], 50, 64, t('A brief description of your block. Used on the block overview page.', array('%overview' => url('admin/block')))); if ($edit['bid']) { - $group .= form_hidden('bid', $edit['bid']); + $output .= form_hidden('bid', $edit['bid']); } - $group .= form_submit(t('Save block')); + $output .= form_submit(t('Save block')); + if ($edit['bid']) { + $output .= form_submit(t('Delete block')); + } - $output = form_group(t('Add a new block'), $group); return form($output); } @@ -260,18 +267,6 @@ function block_box_save($edit) { } } -/** - * Menu callback; deletes a custom box, then displays the overview page. - */ -function block_box_delete($bid = 0) { - if ($bid) { - db_query('DELETE FROM {boxes} WHERE bid = %d', $bid); - drupal_set_message(t('The block has been deleted.')); - cache_clear_all(); - } - print theme('page', block_admin_display()); -} - /** * Menu callback; displays the block overview page. */ diff --git a/modules/comment.module b/modules/comment.module index 4eed28bc7..1fa60180e 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -992,7 +992,7 @@ function comment_delete($cid) { drupal_set_message(t('Do you want to delete this comment and all its replies?')); $comment->comment = check_output($comment->comment, $comment->format); $output = theme('comment', $comment); - $output .= form_submit(t('Delete comment')); + $output .= form_submit(t('Delete')); } else { drupal_set_message(t('The comment no longer exists.')); diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 4eed28bc7..1fa60180e 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -992,7 +992,7 @@ function comment_delete($cid) { drupal_set_message(t('Do you want to delete this comment and all its replies?')); $comment->comment = check_output($comment->comment, $comment->format); $output = theme('comment', $comment); - $output .= form_submit(t('Delete comment')); + $output .= form_submit(t('Delete')); } else { drupal_set_message(t('The comment no longer exists.')); diff --git a/modules/filter.module b/modules/filter.module index 5cdd0d46f..2fc7a85de 100644 --- a/modules/filter.module +++ b/modules/filter.module @@ -286,7 +286,7 @@ function filter_admin_add() { */ function filter_admin_delete() { $edit = $_POST['edit']; - if ($_POST['op'] == t('Confirm deletion')) { + if ($_POST['op'] == t('Delete')) { if ($edit['format'] != variable_get('filter_default_format', 1)) { db_query("DELETE FROM {filter_formats} WHERE format = %d", $edit['format']); db_query("DELETE FROM {filters} WHERE format = %d", $edit['format']); @@ -309,20 +309,10 @@ function filter_admin_delete() { $form .= form_hidden('format', $format->format); $form .= form_hidden('name', $format->name); $form .= '

'. t('Are you sure you want to delete the input format %format? If you have any content left in this input format, it will be switched to the default input format.', array('%format' => ''. $format->name .'')) ."

\n"; - $form .= form_submit(t('Confirm deletion')); + $form .= form_submit(t('Delete')); print theme('page', form($form)); } -/** - * Ask for confirmation before deleting a format. - */ -function filter_admin_confirm() { - $edit = $_POST['edit']['format']; - - - return form($form); -} - /** * Menu callback; configure the filters for a format. */ diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 5cdd0d46f..2fc7a85de 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -286,7 +286,7 @@ function filter_admin_add() { */ function filter_admin_delete() { $edit = $_POST['edit']; - if ($_POST['op'] == t('Confirm deletion')) { + if ($_POST['op'] == t('Delete')) { if ($edit['format'] != variable_get('filter_default_format', 1)) { db_query("DELETE FROM {filter_formats} WHERE format = %d", $edit['format']); db_query("DELETE FROM {filters} WHERE format = %d", $edit['format']); @@ -309,20 +309,10 @@ function filter_admin_delete() { $form .= form_hidden('format', $format->format); $form .= form_hidden('name', $format->name); $form .= '

'. t('Are you sure you want to delete the input format %format? If you have any content left in this input format, it will be switched to the default input format.', array('%format' => ''. $format->name .'')) ."

\n"; - $form .= form_submit(t('Confirm deletion')); + $form .= form_submit(t('Delete')); print theme('page', form($form)); } -/** - * Ask for confirmation before deleting a format. - */ -function filter_admin_confirm() { - $edit = $_POST['edit']['format']; - - - return form($form); -} - /** * Menu callback; configure the filters for a format. */ diff --git a/modules/locale.module b/modules/locale.module index 3f4d4794d..319de1889 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -325,7 +325,6 @@ function locale_admin_manage_delete_screen() { // For other locales, warn user that data loss is ahead $form = form_hidden('langcode', $langcode); $form .= form_submit(t('Delete')); - $form .= form_submit(t('Cancel')); $languages = locale_supported_languages(FALSE, TRUE); print theme('page', form(form_item(t("Delete language '%name'", array('%name' => t($languages['name'][$langcode]))), $form, t('Are you sure you want to delete the language and all data associated with it?')), 'POST', url('admin/locale/language/overview'))); } diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 3f4d4794d..319de1889 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -325,7 +325,6 @@ function locale_admin_manage_delete_screen() { // For other locales, warn user that data loss is ahead $form = form_hidden('langcode', $langcode); $form .= form_submit(t('Delete')); - $form .= form_submit(t('Cancel')); $languages = locale_supported_languages(FALSE, TRUE); print theme('page', form(form_item(t("Delete language '%name'", array('%name' => t($languages['name'][$langcode]))), $form, t('Are you sure you want to delete the language and all data associated with it?')), 'POST', url('admin/locale/language/overview'))); } diff --git a/modules/taxonomy.module b/modules/taxonomy.module index dc593879f..f802df531 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -190,7 +190,6 @@ function _taxonomy_confirm_del_vocabulary($vid) { $form .= form_hidden('type', 'vocabulary'); $form .= form_hidden('vid', $vid); $form .= form_submit(t('Delete')); - $form .= form_submit(t('Cancel')); return form(form_item(t('Delete vocabulary "%name"', array('%name' => $vocabulary->name)), $form, t('Are you sure you want to delete the vocabulary and all its terms?'))); } @@ -334,7 +333,6 @@ function _taxonomy_confirm_del_term($tid) { $form .= form_hidden('type', 'term'); $form .= form_hidden('tid', $tid); $form .= form_submit(t('Delete')); - $form .= form_submit(t('Cancel')); $output = form(form_item(t('Delete term "%name" and all its children', array('%name' => $term->name)), $form, t('Are you sure you want to delete the term and all its children (if any)?'))); diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index dc593879f..f802df531 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -190,7 +190,6 @@ function _taxonomy_confirm_del_vocabulary($vid) { $form .= form_hidden('type', 'vocabulary'); $form .= form_hidden('vid', $vid); $form .= form_submit(t('Delete')); - $form .= form_submit(t('Cancel')); return form(form_item(t('Delete vocabulary "%name"', array('%name' => $vocabulary->name)), $form, t('Are you sure you want to delete the vocabulary and all its terms?'))); } @@ -334,7 +333,6 @@ function _taxonomy_confirm_del_term($tid) { $form .= form_hidden('type', 'term'); $form .= form_hidden('tid', $tid); $form .= form_submit(t('Delete')); - $form .= form_submit(t('Cancel')); $output = form(form_item(t('Delete term "%name" and all its children', array('%name' => $term->name)), $form, t('Are you sure you want to delete the term and all its children (if any)?'))); -- cgit v1.2.3