Commit f8be0de3 authored by smk-ka's avatar smk-ka

#369711 by smk-ka: Added confirmation before deleting a snapshot.

parent 8fc2a4d6
......@@ -16,6 +16,7 @@ Demo 5.x-1.x, xxxx-xx-xx
#312215 by rondp: Added foreign key support.
#294879 by smk-ka: Moved admin functions into include file.
#369642 by smk-ka: Added checkbox to define new snapshot as default.
#369711 by smk-ka: Added confirmation before deleting a snapshot.
Demo 5.x-1.4, 2008-04-29
......
......@@ -101,12 +101,29 @@ function demo_manage_submit($form_id, $values) {
break;
case t('Delete selected snapshot'):
$files = demo_get_fileconfig($values['filename']);
unlink($files['sqlfile']);
unlink($files['infofile']);
drupal_set_message(t('Snapshot %title has been deleted.', array('%title' => $values['filename'])));
break;
return 'admin/build/demo/delete/'. $values['filename'];
}
}
function _demo_delete_confirm($filename = '') {
$fileconfig = demo_get_fileconfig($filename);
if (!file_exists($fileconfig['infofile'])) {
return drupal_access_denied();
}
$form['filename'] = array(
'#type' => 'value',
'#value' => $filename,
);
return confirm_form($form, t('Are you sure you want to delete the snapshot %title?', array('%title' => $filename)), 'admin/build/demo/manage', t('This action cannot be undone.'), t('Delete'));
}
function demo_delete_confirm_submit($form_id, $values) {
$files = demo_get_fileconfig($values['filename']);
unlink($files['sqlfile']);
unlink($files['infofile']);
drupal_set_message(t('Snapshot %title has been deleted.', array('%title' => $values['filename'])));
return 'admin/build/demo/manage';
}
function _demo_dump() {
......
......@@ -61,6 +61,14 @@ function demo_menu($may_cache) {
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
$items[] = array(
'path' => 'admin/build/demo/delete',
'title' => t('Delete snapshot'),
'callback' => 'drupal_get_form',
'callback arguments' => array('demo_delete_confirm'),
'access' => $admin_access,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'demo/autocomplete',
'title' => t('Demo Site autocomplete'),
......@@ -149,6 +157,11 @@ function demo_reset_confirm() {
return _demo_reset_confirm();
}
function demo_delete_confirm($filename) {
require_once drupal_get_path('module', 'demo') .'/demo.admin.inc';
return _demo_delete_confirm($filename);
}
function demo_autocomplete($string = '') {
require_once drupal_get_path('module', 'demo') .'/demo.admin.inc';
return _demo_autocomplete($string);
......
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