summaryrefslogtreecommitdiff
path: root/program/steps/addressbook/delete.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/addressbook/delete.inc')
-rw-r--r--program/steps/addressbook/delete.inc22
1 files changed, 20 insertions, 2 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index af9bdb10a..f11752b70 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -26,6 +26,9 @@ if (!$OUTPUT->ajax_call)
$cids = rcmail_get_cids();
$delcnt = 0;
+// remove previous deletes
+$RCMAIL->session->remove('contact_undo');
+
foreach ($cids as $source => $cid)
{
$CONTACTS = rcmail_contact_source($source);
@@ -36,6 +39,7 @@ foreach ($cids as $source => $cid)
if (count($cids) == 1) {
$OUTPUT->show_message('contactdelerror', 'error');
$OUTPUT->command('list_contacts');
+ $OUTPUT->send();
}
continue;
}
@@ -52,11 +56,14 @@ foreach ($cids as $source => $cid)
}
else {
$delcnt += $deleted;
+
+ // store deleted contacts IDs in session for undelete
+ if ($CONTACTS->undelete) {
+ $_SESSION['contact_undo']['data'][$source] = $cid;
+ }
}
}
-$OUTPUT->show_message('contactdeleted', 'confirmation');
-
$page = isset($_SESSION['page']) ? $_SESSION['page'] : 1;
// update saved search after data changed
@@ -135,6 +142,17 @@ else {
$OUTPUT->set_env('pagecount', ceil($result->count / $CONFIG['pagesize']));
$OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result));
+if (!empty($_SESSION['contact_undo'])) {
+ $_SESSION['contact_undo']['ts'] = time();
+ $msg = html::span(null, rcube_label(array('name' => 'itemsdeleted', 'vars' => array('num' => $deleted))))
+ . ' ' . html::a(array('onclick' => JS_OBJECT_NAME.".command('undo', '', this)"), rcube_label('undo'));
+
+ $OUTPUT->show_message($msg, 'confirmation', null, true, $RCMAIL->config->get('undo_timeout', 15));
+}
+else {
+ $OUTPUT->show_message('contactdeleted', 'confirmation');
+}
+
// add new rows from next page (if any)
if (!empty($records)) {
rcmail_js_contacts_list($records);