Commit 24caaddc authored by merlinofchaos's avatar merlinofchaos

View deletion works

parent d8e483d4
......@@ -8,7 +8,11 @@
/**
* Page callback to list views in the system.
*/
function views_ui_list_views() {
function views_ui_list_views($arg = NULL) {
if ($arg != NULL) {
return drupal_not_found();
}
$items = array();
$sorts = array();
......@@ -29,7 +33,7 @@ function views_ui_list_views() {
}
if ($view->type != t('Default')) {
$text = $view->type == t('Overridden') ? t('Revert') : t('Delete');
$ops[] = l($text, "admin/build/views/$view->name/delete");
$ops[] = l($text, "admin/build/views/delete/$view->name");
}
else {
if (empty($view->disabled)) {
......@@ -158,6 +162,35 @@ function views_ui_add_form_submit($form, &$form_state) {
$form_state['redirect'] ='admin/build/views/edit/' . $view->name;
}
/**
* Page to delete a view.
*/
function views_ui_delete_confirm(&$form_state, $view) {
$form_state['view'] = $view;
$form = array();
$cancel = 'admin/build/views';
if (!empty($_REQUEST['cancel'])) {
$cancel = $_REQUEST['cancel'];
}
return confirm_form($form,
t('Are you sure you want to delete the view %name?',
array('%name' => $view->name)),
$cancel,
t('Deleting a term will delete all its children if there are any. This action cannot be undone.'),
t('Delete'),
t('Cancel'));
}
/**
* Submit handler to delete a view.
*/
function views_ui_delete_confirm_submit(&$form, &$form_state) {
$form_state['view']->delete();
views_object_cache_clear('view', $form_state['view']->name);
drupal_set_message(t('The view has been deleted'));
$form_state['redirect'] = 'admin/build/views';
}
/**
* The main view edit page
*/
......@@ -230,6 +263,11 @@ function views_ui_edit_view_form_cancel($form, &$form_state) {
views_object_cache_clear('view', $form_state['view']->name);
}
function views_ui_edit_view_form_delete($form, &$form_state) {
// Remove this view from cache so edits will be lost.
$form_state['redirect'] = array('admin/build/views/delete/' . $form_state['view']->name, 'cancel=admin/build/views/edit/' . $form_state['view']->name);
}
/**
* Preprocess the view edit page.
*/
......
......@@ -52,10 +52,10 @@ function views_ui_menu() {
'callback arguments' => array('views_ui_admin_tools'),
'type' => MENU_LOCAL_TASK
);
$items['admin/build/views/delete'] = $callback + array(
'title' => t('Edit view'),
$items['admin/build/views/delete/%views_ui_cache'] = $callback + array(
'title' => t('Delete view'),
'page callback' => 'drupal_get_form',
'callback arguments' => array('views_ui_admin_delete_confirm'),
'page arguments' => array('views_ui_delete_confirm', 4),
);
$items['admin/build/views/enable'] = $callback + array(
'page callback' => 'views_ui_admin_enable_page',
......
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