commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/show.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
0ea884
|
8 |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Display a mail message similar as a usual mail application does | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
197601
|
22 |
$PRINT_MODE = $RCMAIL->action=='print' ? TRUE : FALSE; |
4e17e6
|
23 |
|
T |
24 |
// similar code as in program/steps/mail/get.inc |
8fa58e
|
25 |
if ($_GET['_uid']) { |
T |
26 |
$MESSAGE = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET)); |
b19097
|
27 |
|
17b5fb
|
28 |
// set message charset as default |
8fa58e
|
29 |
if (!empty($MESSAGE->headers->charset)) |
T |
30 |
$IMAP->set_charset($MESSAGE->headers->charset); |
3f5cef
|
31 |
|
4e17e6
|
32 |
// go back to list if message not found (wrong UID) |
8fa58e
|
33 |
if (empty($MESSAGE->headers)) { |
f11541
|
34 |
$OUTPUT->show_message('messageopenerror', 'error'); |
e58df3
|
35 |
if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview')) |
47124c
|
36 |
$OUTPUT->send('messagepreview'); |
8fa58e
|
37 |
else { |
b469a1
|
38 |
rcmail_overwrite_action(''); |
b19097
|
39 |
return; |
4e17e6
|
40 |
} |
8fa58e
|
41 |
} |
6726f0
|
42 |
|
6d2714
|
43 |
$mbox_name = $IMAP->get_mailbox_name(); |
A |
44 |
|
712b30
|
45 |
// check known senders to display images |
A |
46 |
if (!$MESSAGE->is_safe |
62e43d
|
47 |
&& !empty($MESSAGE->sender['mailto']) |
T |
48 |
&& $RCMAIL->config->get('addrbook_show_images') |
|
49 |
&& $MESSAGE->has_html_part()) { |
|
50 |
$CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']); |
|
51 |
|
|
52 |
if ($CONTACTS->search('email', $MESSAGE->sender['mailto'], true, false)->count) { |
|
53 |
$MESSAGE->set_safe(true); |
712b30
|
54 |
} |
62e43d
|
55 |
} |
712b30
|
56 |
|
ed42ff
|
57 |
// calculate Etag for this request |
T |
58 |
$etag = md5($MESSAGE->uid.$mbox_name.session_id().intval($MESSAGE->headers->mdn_sent).intval($MESSAGE->is_safe).intval($PRINT_MODE)); |
|
59 |
|
ff52be
|
60 |
// allow caching, unless remote images are present |
8fa58e
|
61 |
if ((bool)$MESSAGE->is_safe) |
ff52be
|
62 |
send_nocacheing_headers(); |
719a25
|
63 |
else if (empty($CONFIG['devel_mode'])) |
8fa58e
|
64 |
send_modified_header($_SESSION['login_time'], $etag, !$MESSAGE->headers->seen); |
ff52be
|
65 |
|
8fa58e
|
66 |
$OUTPUT->set_pagetitle($MESSAGE->subject); |
8d4bcd
|
67 |
|
4e17e6
|
68 |
// mark message as read |
8fa58e
|
69 |
if (!$MESSAGE->headers->seen) |
47124c
|
70 |
{ |
8fa58e
|
71 |
$marked = $IMAP->set_flag($MESSAGE->uid, 'SEEN'); |
197601
|
72 |
if($RCMAIL->action == 'preview' && $marked != -1) |
6d2714
|
73 |
{ |
47124c
|
74 |
$OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); |
8fa58e
|
75 |
$OUTPUT->command('mark_as_read_from_preview', $MESSAGE->uid); |
6d2714
|
76 |
} |
47124c
|
77 |
} |
4e17e6
|
78 |
|
T |
79 |
// give message uid to the client |
8fa58e
|
80 |
$OUTPUT->set_env('uid', $MESSAGE->uid); |
T |
81 |
$OUTPUT->set_env('safemode', $MESSAGE->is_safe); |
62e43d
|
82 |
$OUTPUT->set_env('sender', $MESSAGE->sender['string']); |
203ee4
|
83 |
$OUTPUT->set_env('permaurl', rcmail_url('show', array('_uid' => $MESSAGE->uid, '_mbox' => $mbox_name))); |
ed5407
|
84 |
|
T |
85 |
// check for unset disposition notification |
5b3dd4
|
86 |
if ($MESSAGE->headers->mdn_to && |
T |
87 |
!$MESSAGE->headers->mdn_sent && |
|
88 |
$IMAP->check_permflag('MDNSENT') && |
|
89 |
$mbox_name != $CONFIG['drafts_mbox'] && |
|
90 |
$mbox_name != $CONFIG['sent_mbox']) |
fba1f5
|
91 |
{ |
0ea884
|
92 |
if (intval($CONFIG['mdn_requests']) === 1) |
T |
93 |
{ |
8fa58e
|
94 |
if (rcmail_send_mdn($MESSAGE->uid)) |
0ea884
|
95 |
$OUTPUT->show_message('receiptsent', 'confirmation'); |
86d43e
|
96 |
else |
T |
97 |
$OUTPUT->show_message('errorsendingreceipt', 'error'); |
0ea884
|
98 |
} |
T |
99 |
else if (empty($CONFIG['mdn_requests'])) |
|
100 |
{ |
|
101 |
rcube_add_label('mdnrequest'); |
|
102 |
$OUTPUT->set_env('mdn_request', true); |
|
103 |
} |
fba1f5
|
104 |
} |
4e17e6
|
105 |
|
1f020b
|
106 |
|
S |
107 |
$next = $prev = $first = $last = -1; |
d17008
|
108 |
// get previous, first, next and last message UID |
1f020b
|
109 |
if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && |
df0da2
|
110 |
$IMAP->get_capability('sort')) || !empty($_REQUEST['_search'])) |
8d4bcd
|
111 |
{ |
T |
112 |
// Only if we use custom sorting |
|
113 |
$a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); |
e6f360
|
114 |
|
8fa58e
|
115 |
$MESSAGE->index = array_search((string)$MESSAGE->uid, $a_msg_index, TRUE); |
T |
116 |
$prev = isset($a_msg_index[$MESSAGE->index-1]) ? $a_msg_index[$MESSAGE->index-1] : -1 ; |
d17008
|
117 |
$first = count($a_msg_index)>0 ? $a_msg_index[0] : -1; |
8fa58e
|
118 |
$next = isset($a_msg_index[$MESSAGE->index+1]) ? $a_msg_index[$MESSAGE->index+1] : -1 ; |
d17008
|
119 |
$last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1; |
8d4bcd
|
120 |
} |
T |
121 |
else |
|
122 |
{ |
|
123 |
// this assumes that we are sorted by date_DESC |
8fa58e
|
124 |
$seq = $IMAP->get_id($MESSAGE->uid); |
8d4bcd
|
125 |
$prev = $IMAP->get_uid($seq + 1); |
d17008
|
126 |
$first = $IMAP->get_uid($IMAP->messagecount()); |
8d4bcd
|
127 |
$next = $IMAP->get_uid($seq - 1); |
d17008
|
128 |
$last = $IMAP->get_uid(1); |
8fa58e
|
129 |
$MESSAGE->index = $IMAP->messagecount() - $seq; |
8d4bcd
|
130 |
} |
4e17e6
|
131 |
|
e6f360
|
132 |
if ($prev > 0) |
f11541
|
133 |
$OUTPUT->set_env('prev_uid', $prev); |
d17008
|
134 |
if ($first >0) |
f11541
|
135 |
$OUTPUT->set_env('first_uid', $first); |
e6f360
|
136 |
if ($next > 0) |
f11541
|
137 |
$OUTPUT->set_env('next_uid', $next); |
d17008
|
138 |
if ($last >0) |
f11541
|
139 |
$OUTPUT->set_env('last_uid', $last); |
4e17e6
|
140 |
} |
T |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
function rcmail_message_attachments($attrib) |
8fa58e
|
145 |
{ |
T |
146 |
global $PRINT_MODE, $MESSAGE; |
|
147 |
|
|
148 |
$out = $ol = ''; |
4e17e6
|
149 |
|
8fa58e
|
150 |
if (sizeof($MESSAGE->attachments)) { |
T |
151 |
foreach ($MESSAGE->attachments as $attach_prop) { |
|
152 |
if ($PRINT_MODE) { |
|
153 |
$ol .= html::tag('li', null, sprintf("%s (%s)", Q($attach_prop->filename), Q(show_bytes($attach_prop->size)))); |
4e17e6
|
154 |
} |
8fa58e
|
155 |
else { |
203ee4
|
156 |
if (rc_strlen($attach_prop->filename) > 50) { |
T |
157 |
$filename = abbreviate_string($attach_prop->filename, 50); |
|
158 |
$title = $attach_prop->filename; |
|
159 |
} |
|
160 |
else { |
|
161 |
$filename = $attach_prop->filename; |
|
162 |
$title = ''; |
|
163 |
} |
|
164 |
|
8fa58e
|
165 |
$ol .= html::tag('li', null, |
T |
166 |
html::a(array( |
|
167 |
'href' => $MESSAGE->get_part_url($attach_prop->mime_id), |
|
168 |
'onclick' => sprintf( |
|
169 |
'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)', |
|
170 |
JS_OBJECT_NAME, |
|
171 |
$attach_prop->mime_id, |
|
172 |
$attach_prop->mimetype), |
203ee4
|
173 |
'title' => Q($title), |
8fa58e
|
174 |
), |
30694e
|
175 |
Q($filename))); |
8fa58e
|
176 |
} |
T |
177 |
} |
4e17e6
|
178 |
|
8fa58e
|
179 |
$out = html::tag('ul', $attrib, $ol, html::$common_attrib); |
T |
180 |
} |
|
181 |
|
|
182 |
return $out; |
|
183 |
} |
4e17e6
|
184 |
|
T |
185 |
|
|
186 |
|
|
187 |
function rcmail_remote_objects_msg($attrib) |
62e43d
|
188 |
{ |
T |
189 |
global $MESSAGE, $RCMAIL; |
4e17e6
|
190 |
|
T |
191 |
if (!$attrib['id']) |
|
192 |
$attrib['id'] = 'rcmremoteobjmsg'; |
|
193 |
|
62e43d
|
194 |
$msg = Q(rcube_label('blockedimages')) . ' '; |
T |
195 |
$msg .= html::a(array('href' => "#loadimages", 'onclick' => JS_OBJECT_NAME.".command('load-images')"), Q(rcube_label('showimages'))); |
4e17e6
|
196 |
|
62e43d
|
197 |
// add link to save sender in addressbook and reload message |
T |
198 |
if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('addrbook_show_images')) { |
|
199 |
$msg .= ' ' . html::a(array('href' => "#alwaysload", 'onclick' => JS_OBJECT_NAME.".command('always-load')", 'style' => "white-space:nowrap"), |
|
200 |
Q(rcube_label(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto']))))); |
4e17e6
|
201 |
} |
62e43d
|
202 |
|
T |
203 |
$RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']); |
|
204 |
return html::div($attrib, $msg); |
|
205 |
} |
4e17e6
|
206 |
|
T |
207 |
|
f11541
|
208 |
$OUTPUT->add_handlers(array( |
T |
209 |
'messageattachments' => 'rcmail_message_attachments', |
ac5d15
|
210 |
'mailboxname' => 'rcmail_mailbox_name_display', |
f11541
|
211 |
'blockedobjects' => 'rcmail_remote_objects_msg')); |
T |
212 |
|
|
213 |
|
e58df3
|
214 |
if ($RCMAIL->action=='print' && $OUTPUT->template_exists('printmessage')) |
47124c
|
215 |
$OUTPUT->send('printmessage'); |
e58df3
|
216 |
else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview')) |
47124c
|
217 |
$OUTPUT->send('messagepreview'); |
4e17e6
|
218 |
else |
47124c
|
219 |
$OUTPUT->send('message'); |
1f020b
|
220 |
?> |