#1484972: optimization: mark as read in one action with preview, deleted redundant quota reads
1 files deleted
6 files modified
| | |
| | | if ($_action=='rss') |
| | | include('program/steps/mail/rss.inc'); |
| | | |
| | | if ($_action=='quotadisplay') |
| | | include('program/steps/mail/quotadisplay.inc'); |
| | | |
| | | |
| | | // make sure the message count is refreshed |
| | | $IMAP->messagecount($_SESSION['mbox'], 'ALL', TRUE); |
| | | } |
| | |
| | | { |
| | | this.enable_command('compose', 'add-contact', false); |
| | | parent.rcmail.show_contentframe(true); |
| | | parent.rcmail.mark_message('read', this.env.uid); |
| | | } |
| | | |
| | | if ((this.env.action=='show' || this.env.action=='preview') && this.env.blockedobjects) |
| | |
| | | |
| | | this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag); |
| | | }; |
| | | |
| | | // set class to read/unread |
| | | this.mark_as_read_from_preview = function(uid) |
| | | { |
| | | var icn_src; |
| | | var rows = parent.rcmail.message_list.rows; |
| | | if(rows[uid].unread) |
| | | { |
| | | rows[uid].unread = false; |
| | | rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); |
| | | parent.rcmail.set_classname(rows[uid].obj, 'unread', false); |
| | | |
| | | if (rows[uid].replied && parent.rcmail.env.repliedicon) |
| | | icn_src = parent.rcmail.env.repliedicon; |
| | | else if (parent.rcmail.env.messageicon) |
| | | icn_src = parent.rcmail.env.messageicon; |
| | | |
| | | if (rows[uid].icon && icn_src) |
| | | rows[uid].icon.src = icn_src; |
| | | } |
| | | } |
| | | |
| | | |
| | | // mark all message rows as deleted/undeleted |
| | | this.toggle_delete_status = function(a_uids) |
| | |
| | | this.set_page_buttons(); |
| | | }; |
| | | |
| | | |
| | | // replace content of quota display |
| | | this.set_quota = function() |
| | | this.set_quota = function(content) |
| | | { |
| | | if (this.gui_objects.quotadisplay && |
| | | this.gui_objects.quotadisplay.attributes.getNamedItem('display') && |
| | | this.gui_objects.quotadisplay.attributes.getNamedItem('id')) |
| | | this.http_request('quotadisplay', '_display='+ |
| | | this.gui_objects.quotadisplay.attributes.getNamedItem('display').nodeValue+ |
| | | '&_id='+this.gui_objects.quotadisplay.attributes.getNamedItem('id').nodeValue, false); |
| | | if (this.gui_objects.quotadisplay && content) |
| | | this.gui_objects.quotadisplay.innerHTML = content; |
| | | }; |
| | | |
| | | |
| | |
| | | } |
| | | }; |
| | | |
| | | // update parent's mailboxlist (from preview) |
| | | this.set_unread_count_from_preview = function(mbox, count, set_title) |
| | | { |
| | | parent.rcmail.set_unread_count(mbox, count, set_title); |
| | | } |
| | | |
| | | // add row to contacts list |
| | | this.add_contact_row = function(cid, cols, select) |
| | |
| | | $OUTPUT->set_env('messagecount', $IMAP->messagecount()); |
| | | $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX')); |
| | | $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); |
| | | $OUTPUT->command('set_quota', $IMAP->get_quota()); |
| | | $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); |
| | | |
| | | // add new message headers to list |
| | | $a_headers = array(); |
| | |
| | | if (!$attrib['id']) |
| | | $attrib['id'] = 'rcmquotadisplay'; |
| | | |
| | | if(isset($attrib['display'])) |
| | | $_SESSION['quota_display'] = $attrib['display']; |
| | | |
| | | $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); |
| | | |
| | | // allow the following attributes to be added to the <span> tag |
| | | $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display')); |
| | | |
| | | $out = '<span' . $attrib_str . '>'; |
| | | $out .= rcmail_quota_content($attrib['display']); |
| | | $out .= rcmail_quota_content(); |
| | | $out .= '</span>'; |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | function rcmail_quota_content($display) |
| | | function rcmail_quota_content($quota=NULL) |
| | | { |
| | | global $IMAP, $COMM_PATH; |
| | | |
| | | if (!$IMAP->get_capability('QUOTA')) |
| | | $quota_text = rcube_label('unknown'); |
| | | else if ($quota = $IMAP->get_quota()) |
| | | $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; |
| | | |
| | | if (is_array($quota) && !empty($quota['used']) && !empty($quota['total'])) |
| | | { |
| | | $quota_text = sprintf("%s / %s (%.0f%%)", |
| | | show_bytes($quota["used"] * 1024), |
| | | show_bytes($quota["total"] * 1024), |
| | | $quota["percent"]); |
| | | if (!isset($quota['percent'])) |
| | | $quota['percent'] = $quota['used'] / $quota['total']; |
| | | } |
| | | elseif (!$IMAP->get_capability('QUOTA')) |
| | | return rcube_label('unknown'); |
| | | else |
| | | $quota = $IMAP->get_quota(); |
| | | |
| | | if ($quota) |
| | | { |
| | | $quota_text = sprintf('%s / %s (%.0f%%)', |
| | | show_bytes($quota['used'] * 1024), |
| | | show_bytes($quota['total'] * 1024), |
| | | $quota['percent']); |
| | | |
| | | // show quota as image (by Brett Patterson) |
| | | if ($display == 'image' && function_exists('imagegif')) |
| | |
| | | if ($_action=='moveto' && $target) |
| | | $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); |
| | | |
| | | $OUTPUT->command('set_quota', $IMAP->get_quota()); |
| | | $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); |
| | | |
| | | // add new rows from next page (if any) |
| | | if ($_POST['_from']!='show' && ($jump_back || $nextpage_count > 0)) |
| | |
| | | else if ($_SESSION['safe_messages'][$MESSAGE['UID']]) |
| | | $MESSAGE['is_safe'] = 1; |
| | | |
| | | $mbox_name = $IMAP->get_mailbox_name(); |
| | | |
| | | // calculate Etag for this request |
| | | $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE)); |
| | | $etag = md5($MESSAGE['UID'].$mbox_name.session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE)); |
| | | |
| | | // allow caching, unless remote images are present |
| | | if ((bool)$MESSAGE['is_safe']) |
| | |
| | | else |
| | | $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); |
| | | |
| | | |
| | | // mark message as read |
| | | if (!$MESSAGE['headers']->seen && $_action != 'preview') |
| | | $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); |
| | | if (!$MESSAGE['headers']->seen) |
| | | { |
| | | $marked = $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); |
| | | if($_action == 'preview' && $marked != -1) |
| | | { |
| | | $OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); |
| | | $OUTPUT->command('mark_as_read_from_preview', $MESSAGE['UID']); |
| | | } |
| | | } |
| | | |
| | | // give message uid to the client |
| | | $OUTPUT->set_env('uid', $MESSAGE['UID']); |
| | | $OUTPUT->set_env('safemode', $MESSAGE['is_safe']); |
| | | |
| | | // check for unset disposition notification |
| | | if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $IMAP->get_mailbox_name() != $CONFIG['drafts_mbox']) |
| | | if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $mbox_name != $CONFIG['drafts_mbox']) |
| | | { |
| | | if (intval($CONFIG['mdn_requests']) === 1) |
| | | { |