commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/show.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
A |
8 |
| Copyright (C) 2005-2009, 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 |
64e3e8
|
25 |
if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) { |
A |
26 |
$MESSAGE = new rcube_message($uid); |
c9ca6a
|
27 |
|
65e8df
|
28 |
// if message not found (wrong UID)... |
8fa58e
|
29 |
if (empty($MESSAGE->headers)) { |
64e3e8
|
30 |
rcmail_message_error($uid); |
8fa58e
|
31 |
} |
eab71f
|
32 |
|
ae9d58
|
33 |
send_nocacheing_headers(); |
A |
34 |
|
6d2714
|
35 |
$mbox_name = $IMAP->get_mailbox_name(); |
64e3e8
|
36 |
|
2a4135
|
37 |
// show images? |
ec603f
|
38 |
rcmail_check_safe($MESSAGE); |
353657
|
39 |
|
A |
40 |
// set message charset as default |
|
41 |
if (!empty($MESSAGE->headers->charset)) |
|
42 |
$IMAP->set_charset($MESSAGE->headers->charset); |
ff52be
|
43 |
|
8fa58e
|
44 |
$OUTPUT->set_pagetitle($MESSAGE->subject); |
64e3e8
|
45 |
|
4e17e6
|
46 |
// give message uid to the client |
8fa58e
|
47 |
$OUTPUT->set_env('uid', $MESSAGE->uid); |
112c91
|
48 |
// set environement |
8fa58e
|
49 |
$OUTPUT->set_env('safemode', $MESSAGE->is_safe); |
62e43d
|
50 |
$OUTPUT->set_env('sender', $MESSAGE->sender['string']); |
a25d39
|
51 |
$OUTPUT->set_env('permaurl', rcmail_url('show', array('_uid' => $MESSAGE->uid, '_mbox' => $mbox_name))); |
2cc1ca
|
52 |
$OUTPUT->set_env('mailbox', $mbox_name); |
11ea2a
|
53 |
|
112c91
|
54 |
if ($CONFIG['trash_mbox']) |
A |
55 |
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']); |
11ea2a
|
56 |
if ($CONFIG['flag_for_deletion']) |
A |
57 |
$OUTPUT->set_env('flag_for_deletion', true); |
|
58 |
if ($CONFIG['read_when_deleted']) |
|
59 |
$OUTPUT->set_env('read_when_deleted', true); |
|
60 |
if ($CONFIG['skip_deleted']) |
|
61 |
$OUTPUT->set_env('skip_deleted', true); |
|
62 |
if ($CONFIG['display_next']) |
|
63 |
$OUTPUT->set_env('display_next', true); |
|
64 |
|
112c91
|
65 |
if (!$OUTPUT->ajax_call) |
A |
66 |
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash', 'movingmessage'); |
172e33
|
67 |
|
ed5407
|
68 |
// check for unset disposition notification |
5b3dd4
|
69 |
if ($MESSAGE->headers->mdn_to && |
072fde
|
70 |
!$MESSAGE->headers->mdn_sent && !$MESSAGE->headers->seen && |
5c771c
|
71 |
($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*')) && |
5b3dd4
|
72 |
$mbox_name != $CONFIG['drafts_mbox'] && |
T |
73 |
$mbox_name != $CONFIG['sent_mbox']) |
fba1f5
|
74 |
{ |
0ea884
|
75 |
if (intval($CONFIG['mdn_requests']) === 1) |
T |
76 |
{ |
ca90a9
|
77 |
if (rcmail_send_mdn($MESSAGE->uid, $smtp_error)) |
0ea884
|
78 |
$OUTPUT->show_message('receiptsent', 'confirmation'); |
ca90a9
|
79 |
else if ($smtp_error) |
A |
80 |
$OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']); |
|
81 |
else |
86d43e
|
82 |
$OUTPUT->show_message('errorsendingreceipt', 'error'); |
0ea884
|
83 |
} |
T |
84 |
else if (empty($CONFIG['mdn_requests'])) |
|
85 |
{ |
112c91
|
86 |
$OUTPUT->add_label('mdnrequest'); |
0ea884
|
87 |
$OUTPUT->set_env('mdn_request', true); |
T |
88 |
} |
fba1f5
|
89 |
} |
4e17e6
|
90 |
|
d17008
|
91 |
// get previous, first, next and last message UID |
14d953
|
92 |
if ($RCMAIL->action != 'preview' && $RCMAIL->action != 'print') |
A |
93 |
{ |
|
94 |
$next = $prev = $first = $last = -1; |
|
95 |
|
2dd7ee
|
96 |
if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] != 'DESC' |
f52c93
|
97 |
&& empty($_REQUEST['_search']) && !$CONFIG['skip_deleted'] && !$IMAP->threading) |
14d953
|
98 |
{ |
A |
99 |
// this assumes that we are sorted by date_DESC |
|
100 |
$cnt = $IMAP->messagecount(); |
|
101 |
$seq = $IMAP->get_id($MESSAGE->uid); |
|
102 |
$MESSAGE->index = $cnt - $seq; |
|
103 |
|
|
104 |
$prev = $IMAP->get_uid($seq + 1); |
|
105 |
$first = $IMAP->get_uid($cnt); |
|
106 |
$next = $IMAP->get_uid($seq - 1); |
|
107 |
$last = $IMAP->get_uid(1); |
|
108 |
} |
2dd7ee
|
109 |
else |
A |
110 |
{ |
|
111 |
// Only if we use custom sorting |
|
112 |
$a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); |
|
113 |
|
|
114 |
$MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index); |
|
115 |
|
e7dde1
|
116 |
$count = count($a_msg_index); |
A |
117 |
$prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1; |
|
118 |
$first = $count > 1 ? $IMAP->get_uid($a_msg_index[0]) : -1; |
|
119 |
$next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1; |
|
120 |
$last = $count > 1 ? $IMAP->get_uid($a_msg_index[$count-1]) : -1; |
2dd7ee
|
121 |
} |
14d953
|
122 |
|
A |
123 |
if ($prev > 0) |
|
124 |
$OUTPUT->set_env('prev_uid', $prev); |
|
125 |
if ($first > 0) |
|
126 |
$OUTPUT->set_env('first_uid', $first); |
|
127 |
if ($next > 0) |
|
128 |
$OUTPUT->set_env('next_uid', $next); |
|
129 |
if ($last > 0) |
|
130 |
$OUTPUT->set_env('last_uid', $last); |
172e33
|
131 |
|
A |
132 |
// Don't need a real messages count value |
|
133 |
$OUTPUT->set_env('messagecount', 1); |
8d4bcd
|
134 |
} |
e54bb7
|
135 |
|
bc4960
|
136 |
if (!$MESSAGE->headers->seen && ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))) |
353657
|
137 |
$RCMAIL->plugins->exec_hook('message_read', array('uid' => $MESSAGE->uid, |
f52c93
|
138 |
'mailbox' => $mbox_name, 'message' => $MESSAGE)); |
cc97ea
|
139 |
} |
4e17e6
|
140 |
|
T |
141 |
|
|
142 |
|
|
143 |
function rcmail_message_attachments($attrib) |
8fa58e
|
144 |
{ |
T |
145 |
global $PRINT_MODE, $MESSAGE; |
|
146 |
|
|
147 |
$out = $ol = ''; |
4e17e6
|
148 |
|
8fa58e
|
149 |
if (sizeof($MESSAGE->attachments)) { |
T |
150 |
foreach ($MESSAGE->attachments as $attach_prop) { |
|
151 |
if ($PRINT_MODE) { |
|
152 |
$ol .= html::tag('li', null, sprintf("%s (%s)", Q($attach_prop->filename), Q(show_bytes($attach_prop->size)))); |
4e17e6
|
153 |
} |
8fa58e
|
154 |
else { |
ee258c
|
155 |
if (mb_strlen($attach_prop->filename) > 50) { |
203ee4
|
156 |
$filename = abbreviate_string($attach_prop->filename, 50); |
T |
157 |
$title = $attach_prop->filename; |
|
158 |
} |
|
159 |
else { |
|
160 |
$filename = $attach_prop->filename; |
|
161 |
$title = ''; |
|
162 |
} |
|
163 |
|
8fa58e
|
164 |
$ol .= html::tag('li', null, |
T |
165 |
html::a(array( |
|
166 |
'href' => $MESSAGE->get_part_url($attach_prop->mime_id), |
|
167 |
'onclick' => sprintf( |
|
168 |
'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)', |
|
169 |
JS_OBJECT_NAME, |
|
170 |
$attach_prop->mime_id, |
|
171 |
$attach_prop->mimetype), |
203ee4
|
172 |
'title' => Q($title), |
8fa58e
|
173 |
), |
30694e
|
174 |
Q($filename))); |
8fa58e
|
175 |
} |
T |
176 |
} |
4e17e6
|
177 |
|
8fa58e
|
178 |
$out = html::tag('ul', $attrib, $ol, html::$common_attrib); |
T |
179 |
} |
|
180 |
|
|
181 |
return $out; |
|
182 |
} |
4e17e6
|
183 |
|
T |
184 |
|
|
185 |
|
|
186 |
function rcmail_remote_objects_msg($attrib) |
62e43d
|
187 |
{ |
T |
188 |
global $MESSAGE, $RCMAIL; |
4e17e6
|
189 |
|
T |
190 |
if (!$attrib['id']) |
|
191 |
$attrib['id'] = 'rcmremoteobjmsg'; |
|
192 |
|
62e43d
|
193 |
$msg = Q(rcube_label('blockedimages')) . ' '; |
T |
194 |
$msg .= html::a(array('href' => "#loadimages", 'onclick' => JS_OBJECT_NAME.".command('load-images')"), Q(rcube_label('showimages'))); |
4e17e6
|
195 |
|
62e43d
|
196 |
// add link to save sender in addressbook and reload message |
2a4135
|
197 |
if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('show_images') == 1) { |
62e43d
|
198 |
$msg .= ' ' . html::a(array('href' => "#alwaysload", 'onclick' => JS_OBJECT_NAME.".command('always-load')", 'style' => "white-space:nowrap"), |
T |
199 |
Q(rcube_label(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto']))))); |
4e17e6
|
200 |
} |
62e43d
|
201 |
|
T |
202 |
$RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']); |
|
203 |
return html::div($attrib, $msg); |
|
204 |
} |
4e17e6
|
205 |
|
T |
206 |
|
f11541
|
207 |
$OUTPUT->add_handlers(array( |
T |
208 |
'messageattachments' => 'rcmail_message_attachments', |
ac5d15
|
209 |
'mailboxname' => 'rcmail_mailbox_name_display', |
f11541
|
210 |
'blockedobjects' => 'rcmail_remote_objects_msg')); |
T |
211 |
|
|
212 |
|
e58df3
|
213 |
if ($RCMAIL->action=='print' && $OUTPUT->template_exists('printmessage')) |
353657
|
214 |
$OUTPUT->send('printmessage', false); |
e58df3
|
215 |
else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview')) |
353657
|
216 |
$OUTPUT->send('messagepreview', false); |
4e17e6
|
217 |
else |
353657
|
218 |
$OUTPUT->send('message', false); |
A |
219 |
|
|
220 |
|
|
221 |
// mark message as read |
c64277
|
222 |
if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen && |
A |
223 |
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))) |
|
224 |
{ |
|
225 |
if ($IMAP->set_flag($MESSAGE->uid, 'SEEN') && $_SESSION['unseen_count'][$mbox_name]) |
|
226 |
$_SESSION['unseen_count'][$mbox_name] -= 1; |
|
227 |
} |
353657
|
228 |
|
A |
229 |
exit; |
|
230 |
|
b25dfd
|
231 |
|