From fb7ec576ab3a353b6eb99614e9636a9096462807 Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 25 Mar 2010 16:29:02 +0000 Subject: - Added possibility to select all messages in a folder (#1484756) --- CHANGELOG | 1 + program/include/rcube_imap.php | 32 +++++++++++--- program/js/app.js | 81 ++++++++++++++++++---------------- program/lib/imap.inc | 15 +++---- program/localization/en_US/labels.inc | 1 + program/localization/pl_PL/labels.inc | 1 + program/steps/mail/mark.inc | 18 ++++---- program/steps/mail/move_del.inc | 12 ++--- skins/default/images/mail_footer.png | Bin 1186 -> 2416 bytes skins/default/mail.css | 8 ++++ skins/default/templates/mail.html | 1 + 11 files changed, 103 insertions(+), 67 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bbd0a881e..f7905dd84 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Added possibility to select all messages in a folder (#1484756) - Added 'imap_force_caps' option for after-login CAPABILITY checking (#1485750) - Password: Support dovecotpw encryption - TinyMCE 3.3.1 diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 64b300c65..24080d618 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2115,7 +2115,7 @@ class rcube_imap $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; $flag = strtoupper($flag); - list($uids, $all_mode) = $this->_parse_uids($uids); + list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox); if (strpos($flag, 'UN') === 0) $result = iil_C_UnFlag($this->conn, $mailbox, $uids, substr($flag, 2)); @@ -2209,7 +2209,7 @@ class rcube_imap $to_mbox = $this->mod_mailbox($to_mbox); $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox; - list($uids, $all_mode) = $this->_parse_uids($uids); + list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox); // exit if no message uids are specified if (empty($uids)) @@ -2291,7 +2291,7 @@ class rcube_imap $to_mbox = $this->mod_mailbox($to_mbox); $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox; - list($uids, $all_mode) = $this->_parse_uids($uids); + list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox); // exit if no message uids are specified if (empty($uids)) @@ -2329,7 +2329,7 @@ class rcube_imap { $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; - list($uids, $all_mode) = $this->_parse_uids($uids); + list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox); // exit if no message uids are specified if (empty($uids)) @@ -2450,14 +2450,32 @@ class rcube_imap * Parse message UIDs input * * @param mixed UIDs array or comma-separated list or '*' or '1:*' + * @param string Mailbox name * @return array Two elements array with UIDs converted to list and ALL flag * @access private */ - private function _parse_uids($uids) + private function _parse_uids($uids, $mailbox) { if ($uids === '*' || $uids === '1:*') { - $uids = '1:*'; - $all = true; + if (empty($this->search_set)) { + $uids = '1:*'; + $all = true; + } + // get UIDs from current search set + // @TODO: skip iil_C_FetchUIDs() and work with IDs instead of UIDs (?) + else { + if ($this->search_threads) + $uids = iil_C_FetchUIDs($this->conn, $mailbox, array_keys($this->search_set['depth'])); + else + $uids = iil_C_FetchUIDs($this->conn, $mailbox, $this->search_set); + + // save ID-to-UID mapping in local cache + if (is_array($uids)) + foreach ($uids as $id => $uid) + $this->uid_id_map[$mailbox][$uid] = $id; + + $uids = join(',', $uids); + } } else { if (is_array($uids)) diff --git a/program/js/app.js b/program/js/app.js index 1f7290913..0fc5e7675 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -489,8 +489,8 @@ function rcube_webmail() case 'menu-open': case 'menu-save': - this.triggerEvent(command, {props:props}); - return false; + this.triggerEvent(command, {props:props}); + return false; break; case 'open': @@ -753,10 +753,11 @@ function rcube_webmail() break; case 'select-all': + this.select_all_mode = props ? false : true; if (props == 'invert') this.message_list.invert_selection(); else - this.message_list.select_all(props); + this.message_list.select_all(props == 'page' ? '' : props); break; case 'select-none': @@ -1833,9 +1834,10 @@ function rcube_webmail() // unselect selected messages this.last_selected = 0; - if (this.message_list) + if (this.message_list) { this.message_list.clear_selection(); - + this.select_all_mode = false; + } this.select_folder(mbox, this.env.mailbox); this.env.mailbox = mbox; @@ -2254,8 +2256,8 @@ function rcube_webmail() // @private this._with_selected_messages = function(action, lock, add_url) { - var a_uids = new Array(); - var count = 0; + var a_uids = new Array(), + count = 0; if (this.env.uid) a_uids[0] = this.env.uid; @@ -2287,8 +2289,10 @@ function rcube_webmail() // remove threads from the end of the list this.delete_excessive_thread_rows(); + add_url += '&_uid='+this.uids_to_list(a_uids); + // send request to server - this.http_post(action, '_uid='+a_uids.join(',')+'&_mbox='+urlencode(this.env.mailbox)+add_url, lock); + this.http_post(action, '_mbox='+urlencode(this.env.mailbox)+add_url, lock); }; // set a specific flag to one or more messages @@ -2355,7 +2359,7 @@ function rcube_webmail() for (var i=0; i 0) // remove threads from the end of the list this.delete_excessive_thread_rows(); - } + } add_url = '&_from='+(this.env.action ? this.env.action : ''); + // ?? if (r_uids.length) - add_url += '&_ruid='+r_uids.join(','); + add_url += '&_ruid='+this.uids_to_list(r_uids); if (this.env.skip_deleted) { // also send search request to get the right messages @@ -2464,7 +2467,7 @@ function rcube_webmail() add_url += '&_next_uid='+this.env.next_uid; } - this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url); + this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag=delete'+add_url); return true; }; @@ -2472,21 +2475,25 @@ function rcube_webmail() // argument should be a coma-separated list of uids this.flag_deleted_as_read = function(uids) { - var icn_src; - var rows = this.message_list ? this.message_list.rows : new Array(); - var str = String(uids); - var a_uids = new Array(); + var icn_src, uid, + rows = this.message_list ? this.message_list.rows : new Array(), + str = String(uids), + a_uids = str.split(','); - a_uids = str.split(','); - - for (var uid, i=0; i1?':' . $num:''); - - return iil_C_FetchHeaderIndex($conn, $mailbox, $message_set, 'UID'); + return iil_C_FetchHeaderIndex($conn, $mailbox, $message_set, 'UID', false); } function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false, $bodystr=false, $add='') diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index 1a1291ccb..b8c36ec87 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -146,6 +146,7 @@ $labels['messageactions'] = 'More actions...'; $labels['select'] = 'Select'; $labels['all'] = 'All'; $labels['none'] = 'None'; +$labels['currpage'] = 'Current page'; $labels['unread'] = 'Unread'; $labels['flagged'] = 'Flagged'; $labels['unanswered'] = 'Unanswered'; diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc index d6af5ac1b..18dfffbf8 100644 --- a/program/localization/pl_PL/labels.inc +++ b/program/localization/pl_PL/labels.inc @@ -132,6 +132,7 @@ $labels['markunflagged'] = 'Jako nieoflagowane'; $labels['messageactions'] = 'Więcej akcji...'; $labels['select'] = 'Zaznacz'; $labels['all'] = 'Wszystkie'; +$labels['currpage'] = 'Bieżąca strona'; $labels['none'] = 'Brak'; $labels['unread'] = 'Nieprzeczytane'; $labels['flagged'] = 'Oznaczone'; diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc index c37a6e47c..1a2838cd8 100644 --- a/program/steps/mail/mark.inc +++ b/program/steps/mail/mark.inc @@ -52,14 +52,14 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va exit; } - 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 ($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) { + $ruids = get_input_value('_ruid', RCUBE_INPUT_POST); + $read = $IMAP->set_flag($ruids, 'SEEN'); if ($read != -1 && !$CONFIG['skip_deleted']) - $OUTPUT->command('flag_deleted_as_read', $uids); + $OUTPUT->command('flag_deleted_as_read', $ruids); } - + if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) { rcmail_send_unread_count($IMAP->get_mailbox_name()); } @@ -99,20 +99,20 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va if ($old_unseen != $unseen_count) { $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX')); - $_SESSION['unseen_count'][$mbox] = $unseen_count; + $_SESSION['unseen_count'][$mbox] = $unseen_count; } $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); if ($IMAP->threading) - $count = get_input_value('_count', RCUBE_INPUT_POST); + $count = get_input_value('_count', RCUBE_INPUT_POST); // add new rows from next page (if any) - if ($count && ($jump_back || $nextpage_count > 0)) { + if ($count && $uids != '*' && ($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, - $jump_back ? NULL : $count); + $jump_back ? NULL : $count); rcmail_js_message_list($a_headers, false, false); } diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc index f884a781e..f6d8d98ae 100644 --- a/program/steps/mail/move_del.inc +++ b/program/steps/mail/move_del.inc @@ -34,11 +34,11 @@ if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_targe $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); $moved = $IMAP->move_message($uids, $target, $mbox); - + if (!$moved) { // send error message - if ($_POST['_from'] != 'show') - $OUTPUT->command('list_mailbox'); + if ($_POST['_from'] != 'show') + $OUTPUT->command('list_mailbox'); $OUTPUT->show_message('errormoving', 'error'); $OUTPUT->send(); exit; @@ -55,8 +55,8 @@ else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) { if (!$del) { // send error message - if ($_POST['_from'] != 'show') - $OUTPUT->command('list_mailbox'); + if ($_POST['_from'] != 'show') + $OUTPUT->command('list_mailbox'); $OUTPUT->show_message('errordeleting', 'error'); $OUTPUT->send(); exit; @@ -121,7 +121,7 @@ else $count = get_input_value('_count', RCUBE_INPUT_POST); // add new rows from next page (if any) - if ($addrows && $count && ($jump_back || $nextpage_count > 0)) { + if ($addrows && $count && $uids != '*' && ($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']; diff --git a/skins/default/images/mail_footer.png b/skins/default/images/mail_footer.png index ab56b835f..7e0867748 100644 Binary files a/skins/default/images/mail_footer.png and b/skins/default/images/mail_footer.png differ diff --git a/skins/default/mail.css b/skins/default/mail.css index 0e35046c0..7b233f861 100644 --- a/skins/default/mail.css +++ b/skins/default/mail.css @@ -579,6 +579,14 @@ td.formlinks a:visited background-position: -30px -15px; } +#listcontrols a.page { + background-position: -135px 0; +} + +#listcontrols a.pagesel { + background-position: -135px -15px; +} + #listcontrols a.unread { background-position: -45px 0; } diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html index f82aca43a..a1084b096 100644 --- a/skins/default/templates/mail.html +++ b/skins/default/templates/mail.html @@ -81,6 +81,7 @@
+ -- cgit v1.2.3