summaryrefslogtreecommitdiff
path: root/program/steps/addressbook
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-07-08 13:03:42 +0000
committeralecpl <alec@alec.pl>2011-07-08 13:03:42 +0000
commit63fda8af57a285020dc094adcf6eeb46bee1c2d5 (patch)
treeddbbd13344dddee364e58f6b8539159694f52124 /program/steps/addressbook
parent78086d349dc8085a09ceedd1ea06b3c45ea011bb (diff)
- Make Undo action optional by setting undo_timeout=0
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r--program/steps/addressbook/delete.inc9
-rw-r--r--program/steps/addressbook/func.inc5
2 files changed, 8 insertions, 6 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index f11752b70..b0b255e27 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -27,6 +27,7 @@ $cids = rcmail_get_cids();
$delcnt = 0;
// remove previous deletes
+$undo_time = $RCMAIL->config->get('undo_timeout', 0);
$RCMAIL->session->remove('contact_undo');
foreach ($cids as $source => $cid)
@@ -47,7 +48,7 @@ foreach ($cids as $source => $cid)
$plugin = $RCMAIL->plugins->exec_hook('contact_delete', array(
'id' => $cid, 'source' => $source));
- $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid) : $plugin['result'];
+ $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid, $undo_time < 1) : $plugin['result'];
if (!$deleted) {
$OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'contactdelerror', 'error');
@@ -57,8 +58,8 @@ foreach ($cids as $source => $cid)
else {
$delcnt += $deleted;
- // store deleted contacts IDs in session for undelete
- if ($CONTACTS->undelete) {
+ // store deleted contacts IDs in session for undo action
+ if ($undo_time > 0 && $CONTACTS->undelete) {
$_SESSION['contact_undo']['data'][$source] = $cid;
}
}
@@ -147,7 +148,7 @@ if (!empty($_SESSION['contact_undo'])) {
$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));
+ $OUTPUT->show_message($msg, 'confirmation', null, true, $undo_time);
}
else {
$OUTPUT->show_message('contactdeleted', 'confirmation');
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index a895b617f..62c61ecd0 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -90,8 +90,9 @@ if (!$RCMAIL->action && !$OUTPUT->ajax_call) {
// remove undo information...
if ($undo = $_SESSION['contact_undo']) {
- // ...after 30 seconds
- if ($undo['ts'] < time() - 30)
+ // ...after timeout
+ $undo_time = $RCMAIL->config->get('undo_timeout', 0);
+ if ($undo['ts'] < time() - $undo_time)
$RCMAIL->session->remove('contact_undo');
}