summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-06-05 16:13:24 +0000
committeralecpl <alec@alec.pl>2009-06-05 16:13:24 +0000
commit0b2ce91f25aed4c174c437e679155d30bd0387bf (patch)
tree4160c737d4eb52901381292ab05a1a8cb436eea3
parentcf7f222870eac0e3cb84c43ea2c7ee8b9ce206ca (diff)
- Reviewed/fixed skip_deleted/read_when_deleted/flag_for_deletion options handling in UI
-rw-r--r--CHANGELOG1
-rw-r--r--program/include/rcmail.php4
-rw-r--r--program/include/rcube_imap.php10
-rw-r--r--program/js/app.js63
-rw-r--r--program/steps/mail/func.inc7
-rw-r--r--program/steps/mail/mark.inc77
-rw-r--r--program/steps/mail/move_del.inc3
7 files changed, 110 insertions, 55 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 03f792410..fa7e9dbd7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
+- Reviewed/fixed skip_deleted/read_when_deleted/flag_for_deletion options handling in UI
- Fix displaying of big maximum upload filesize (#1485889)
- Added possibility to invert messages selection
- After move/delete from 'show' action display next message instead of messages list (#1485887)
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index afcc33af8..22ec20b90 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -301,10 +301,6 @@ class rcmail
if (!($this->output instanceof rcube_template))
$this->output = new rcube_template($this->task, $framed);
- foreach (array('flag_for_deletion','read_when_deleted') as $js_config_var) {
- $this->output->set_env($js_config_var, $this->config->get($js_config_var));
- }
-
// set keep-alive/check-recent interval
if ($keep_alive = $this->config->get('keep_alive')) {
// be sure that it's less than session lifetime
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index fe2f770f2..7b24d2307 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1627,13 +1627,9 @@ class rcube_imap
// send expunge command in order to have the moved message
// really deleted from the source mailbox
if ($moved) {
- // but only when flag_for_deletion is set to false
- if (!rcmail::get_instance()->config->get('flag_for_deletion', false))
- {
- $this->_expunge($from_mbox, FALSE, $a_uids);
- $this->_clear_messagecount($from_mbox);
- $this->_clear_messagecount($to_mbox);
- }
+ $this->_expunge($from_mbox, FALSE, $a_uids);
+ $this->_clear_messagecount($from_mbox);
+ $this->_clear_messagecount($to_mbox);
}
// moving failed
else if (rcmail::get_instance()->config->get('delete_always', false)) {
diff --git a/program/js/app.js b/program/js/app.js
index ba71518b2..590998f28 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1797,13 +1797,13 @@ function rcube_webmail()
lock = true;
this.set_busy(true, 'movingmessage');
}
- else if (!this.env.flag_for_deletion)
+ else
this.show_contentframe(false);
// Hide message command buttons until a message is selected
this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'viewsource', 'download', false);
- this._with_selected_messages('moveto', lock, add_url, (this.env.flag_for_deletion ? false : true));
+ this._with_selected_messages('moveto', lock, add_url);
};
// delete selected messages from the current mailbox
@@ -1815,9 +1815,14 @@ function rcube_webmail()
if (!this.env.uid && !selection.length)
return;
- // if there is a trash mailbox defined and we're not currently in it:
- if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() != String(this.env.trash_mailbox).toLowerCase())
- {
+ // if config is set to flag for deletion
+ if (this.env.flag_for_deletion)
+ this.mark_message('delete');
+ // if there isn't a defined trash mailbox or we are in it
+ else if (!this.env.trash_mailbox || String(this.env.mailbox).toLowerCase() == String(this.env.trash_mailbox).toLowerCase())
+ this.permanently_remove_messages();
+ // if there is a trash mailbox defined and we're not currently in it
+ else {
// if shift was pressed delete it immediately
if (this.message_list && this.message_list.shiftkey)
{
@@ -1827,21 +1832,6 @@ function rcube_webmail()
else
this.move_messages(this.env.trash_mailbox);
}
- // if there is a trash mailbox defined but we *are* in it:
- else if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() == String(this.env.trash_mailbox).toLowerCase())
- this.permanently_remove_messages();
- // if there isn't a defined trash mailbox and the config is set to flag for deletion
- else if (!this.env.trash_mailbox && this.env.flag_for_deletion)
- {
- this.mark_message('delete');
- if (this.env.action == 'show')
- this.command('nextmessage', '', this);
- else if (selection.length == 1)
- this.message_list.select_next();
- }
- // if there isn't a defined trash mailbox and the config is set NOT to flag for deletion
- else if (!this.env.trash_mailbox)
- this.permanently_remove_messages();
};
// delete the selected messages permanently
@@ -1852,7 +1842,7 @@ function rcube_webmail()
return;
this.show_contentframe(false);
- this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''), true);
+ this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''));
};
// Send a specifc request with UIDs of all selected messages
@@ -1872,16 +1862,7 @@ function rcube_webmail()
{
id = selection[n];
a_uids[a_uids.length] = id;
-
- if (remove)
- this.message_list.remove_row(id, (n == selection.length-1));
- else
- {
- this.set_message_status(id, 'deleted', true);
- if (this.env.read_when_deleted)
- this.set_message_status(id, 'unread', false);
- this.set_message(id);
- }
+ this.message_list.remove_row(id, (n == selection.length-1));
}
}
@@ -2029,15 +2010,29 @@ function rcube_webmail()
uid = a_uids[i];
if (rows[uid])
{
- this.set_message(uid, 'deleted', true);
if (rows[uid].unread)
r_uids[r_uids.length] = uid;
+
+ if (this.env.skip_deleted)
+ this.message_list.remove_row(uid, (i == this.message_list.selection.length-1));
+ else
+ this.set_message(uid, 'deleted', true);
}
}
+ add_url = '&_from='+(this.env.action ? this.env.action : '');
+
if (r_uids.length)
- add_url = '&_ruid='+r_uids.join(',');
-
+ add_url += '&_ruid='+r_uids.join(',');
+
+ if (this.env.skip_deleted) {
+ // also send search request to get the right messages
+ if (this.env.search_request)
+ add_url += '&_search='+this.env.search_request;
+ if (this.env.next_uid)
+ add_url += '&_next_uid='+this.env.next_uid;
+ }
+
this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url);
return true;
};
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 9b8398ecd..154fd7e1e 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -89,6 +89,13 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list')
$OUTPUT->set_env('quota', $IMAP->get_capability('quota'));
$OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter());
+ if ($CONFIG['flag_for_deletion'])
+ $OUTPUT->set_env('flag_for_deletion', true);
+ if ($CONFIG['read_when_deleted'])
+ $OUTPUT->set_env('read_when_deleted', true);
+ if ($CONFIG['skip_deleted'])
+ $OUTPUT->set_env('skip_deleted', true);
+
if ($CONFIG['trash_mbox'])
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);
if ($CONFIG['drafts_mbox'])
diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc
index c45131d26..2ae1cdb2c 100644
--- a/program/steps/mail/mark.inc
+++ b/program/steps/mail/mark.inc
@@ -30,24 +30,85 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va
{
$flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
$marked = $IMAP->set_flag($uids, $flag);
+
+ if ($marked == -1) {
+ // send error message
+ if ($_POST['_from'] != 'show')
+ $OUTPUT->command('list_mailbox');
+ $OUTPUT->show_message('errormarking', 'error');
+ $OUTPUT->send();
+ exit;
+ }
- if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid']))
- {
+ if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
$uids = get_input_value('_ruid', RCUBE_INPUT_POST);
$read = $IMAP->set_flag($uids, 'SEEN');
- if ($read != -1)
+ if ($read != -1 && !$CONFIG['skip_deleted'])
$OUTPUT->command('flag_deleted_as_read', $uids);
- }
-
- if ($marked != -1 && ($flag == 'SEEN' || $flag == 'UNSEEN'))
- {
+ }
+
+ if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
$mbox_name = $IMAP->get_mailbox_name();
$OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX'));
}
+ else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) {
+ if ($_POST['_from'] == 'show') {
+ if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC))
+ $OUTPUT->command('show_message', $next);
+ else
+ $OUTPUT->command('command', 'list');
+ } else {
+ // count messages before changing anything
+ $old_count = $IMAP->messagecount();
+ $old_pages = ceil($old_count / $IMAP->page_size);
+
+ // refresh saved search set after moving some messages
+ if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
+ $_SESSION['search'][$search_request] = $IMAP->refresh_search();
+ }
+
+ $msg_count = $IMAP->messagecount();
+ $pages = ceil($msg_count / $IMAP->page_size);
+ $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
+ $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
+ // jump back one page (user removed the whole last page)
+ if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) {
+ $IMAP->set_page($IMAP->list_page-1);
+ $_SESSION['page'] = $IMAP->list_page;
+ $jump_back = true;
+ }
+
+ // update message count display
+ $OUTPUT->set_env('messagecount', $msg_count);
+ $OUTPUT->set_env('current_page', $IMAP->list_page);
+ $OUTPUT->set_env('pagecount', $pages);
+
+ // update mailboxlist
+ $mbox = $IMAP->get_mailbox_name();
+ $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX'));
+
+// $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
+ $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
+
+ // add new rows from next page (if any)
+ if (($jump_back || $nextpage_count > 0)) {
+ $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
+ $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
+
+ $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
+ if (!$jump_back) {
+ $a_headers = array_slice($a_headers, -$count, $count);
+ }
+
+ rcmail_js_message_list($a_headers, false, false);
+ }
+ }
+ }
+
$OUTPUT->send();
}
exit;
-?> \ No newline at end of file
+?>
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index c4294b01f..9d7d77957 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -44,8 +44,7 @@ if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_targe
exit;
}
- if (!$CONFIG['flag_for_deletion'])
- $addrows = true;
+ $addrows = true;
}
// delete messages
else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {