Commit 9e4399aa authored by Steven Wittens's avatar Steven Wittens

#10677: Confirmation when deleting a block + unifying confirmation screens.

parent 63061bd7
......@@ -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 = '<p>'. t('Are you sure you want to delete the block %name?', array('%name' => '<em>'. $edit['info'] .'</em>')) ."</p>\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 <a href="%overview">block overview page</a>.', 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 <a href="%overview">block overview page</a>.', 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.
*/
......
......@@ -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 = '<p>'. t('Are you sure you want to delete the block %name?', array('%name' => '<em>'. $edit['info'] .'</em>')) ."</p>\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 <a href="%overview">block overview page</a>.', 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 <a href="%overview">block overview page</a>.', 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.
*/
......
......@@ -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.'));
......
......@@ -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.'));
......
......@@ -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 .= '<p>'. 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' => '<em>'. $format->name .'</em>')) ."</p>\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.
*/
......
......@@ -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 .= '<p>'. 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' => '<em>'. $format->name .'</em>')) ."</p>\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.
*/
......
......@@ -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')));
}
......
......@@ -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')));
}
......
......@@ -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)?')));
......
......@@ -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)?')));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment