From 4c135457a502e4329d84b115cd3e4cde8b2c0b19 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Mon, 19 Dec 2005 14:51:38 +0000 Subject: [PATCH] - Patch #41474 by spiderman: no confirmation when deleting a path alias. --- modules/path.module | 33 ++++++++++++++++++++++++++++++--- modules/path/path.module | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/modules/path.module b/modules/path.module index 3bcd9dadf92f..816fd1c1e3af 100644 --- a/modules/path.module +++ b/modules/path.module @@ -58,7 +58,7 @@ function path_menu($may_cache) { 'access' => user_access('administer url aliases'), 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/path/delete', 'title' => t('delete alias'), - 'callback' => 'path_admin_delete', + 'callback' => 'path_admin_delete_confirm', 'access' => user_access('administer url aliases'), 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/path/list', 'title' => t('list'), @@ -96,14 +96,41 @@ function path_admin_edit($pid = 0) { } /** - * Menu callback; handles deletion of an URL alias. + * Menu callback; confirms deleting an URL alias + **/ +function path_admin_delete_confirm($pid) { + $path = path_load($pid); + if (user_access('administer path aliases')) { + $form['pid'] = array('#type' => 'value', '#value' => $pid); + $output = confirm_form('path_admin_delete_confirm', $form, + t('Are you sure you want to delete path alias %title?', array('%title' => theme('placeholder', $path['dst']))), + $_GET['destination'] ? $_GET['destination'] : 'admin/path', t('This action cannot be undone.'), + t('Delete'), t('Cancel') ); + } + + return $output; +} + +/** + * Execute URL alias deletion + **/ +function path_admin_delete_confirm_submit($form_id, $form_values) { + if ($form_values['confirm']) { + path_admin_delete($form_values['pid']); + drupal_goto('admin/path'); + } +} + +/** + * Post-confirmation; delete an URL alias. */ function path_admin_delete($pid = 0) { db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); drupal_set_message(t('The alias has been deleted.')); - drupal_goto('admin/path'); } + + /** * Set an aliased path for a given Drupal path, preventing duplicates. */ diff --git a/modules/path/path.module b/modules/path/path.module index 3bcd9dadf92f..816fd1c1e3af 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -58,7 +58,7 @@ function path_menu($may_cache) { 'access' => user_access('administer url aliases'), 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/path/delete', 'title' => t('delete alias'), - 'callback' => 'path_admin_delete', + 'callback' => 'path_admin_delete_confirm', 'access' => user_access('administer url aliases'), 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/path/list', 'title' => t('list'), @@ -96,14 +96,41 @@ function path_admin_edit($pid = 0) { } /** - * Menu callback; handles deletion of an URL alias. + * Menu callback; confirms deleting an URL alias + **/ +function path_admin_delete_confirm($pid) { + $path = path_load($pid); + if (user_access('administer path aliases')) { + $form['pid'] = array('#type' => 'value', '#value' => $pid); + $output = confirm_form('path_admin_delete_confirm', $form, + t('Are you sure you want to delete path alias %title?', array('%title' => theme('placeholder', $path['dst']))), + $_GET['destination'] ? $_GET['destination'] : 'admin/path', t('This action cannot be undone.'), + t('Delete'), t('Cancel') ); + } + + return $output; +} + +/** + * Execute URL alias deletion + **/ +function path_admin_delete_confirm_submit($form_id, $form_values) { + if ($form_values['confirm']) { + path_admin_delete($form_values['pid']); + drupal_goto('admin/path'); + } +} + +/** + * Post-confirmation; delete an URL alias. */ function path_admin_delete($pid = 0) { db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); drupal_set_message(t('The alias has been deleted.')); - drupal_goto('admin/path'); } + + /** * Set an aliased path for a given Drupal path, preventing duplicates. */ -- GitLab