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'); |
197601
|
35 |
if ($RCMAIL->action=='preview' && template_exists('messagepreview')) |
47124c
|
36 |
$OUTPUT->send('messagepreview'); |
8fa58e
|
37 |
else { |
197601
|
38 |
$RCMAIL->action = 'list'; |
b19097
|
39 |
return; |
4e17e6
|
40 |
} |
8fa58e
|
41 |
} |
6726f0
|
42 |
|
6d2714
|
43 |
$mbox_name = $IMAP->get_mailbox_name(); |
A |
44 |
|
ff52be
|
45 |
// calculate Etag for this request |
8fa58e
|
46 |
$etag = md5($MESSAGE->uid.$mbox_name.session_id().intval($MESSAGE->headers->mdn_sent).intval($MESSAGE->is_safe).intval($PRINT_MODE)); |
ff52be
|
47 |
|
T |
48 |
// allow caching, unless remote images are present |
8fa58e
|
49 |
if ((bool)$MESSAGE->is_safe) |
ff52be
|
50 |
send_nocacheing_headers(); |
719a25
|
51 |
else if (empty($CONFIG['devel_mode'])) |
8fa58e
|
52 |
send_modified_header($_SESSION['login_time'], $etag, !$MESSAGE->headers->seen); |
ff52be
|
53 |
|
8fa58e
|
54 |
$OUTPUT->set_pagetitle($MESSAGE->subject); |
8d4bcd
|
55 |
|
4e17e6
|
56 |
// mark message as read |
8fa58e
|
57 |
if (!$MESSAGE->headers->seen) |
47124c
|
58 |
{ |
8fa58e
|
59 |
$marked = $IMAP->set_flag($MESSAGE->uid, 'SEEN'); |
197601
|
60 |
if($RCMAIL->action == 'preview' && $marked != -1) |
6d2714
|
61 |
{ |
47124c
|
62 |
$OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); |
8fa58e
|
63 |
$OUTPUT->command('mark_as_read_from_preview', $MESSAGE->uid); |
6d2714
|
64 |
} |
47124c
|
65 |
} |
4e17e6
|
66 |
|
T |
67 |
// give message uid to the client |
8fa58e
|
68 |
$OUTPUT->set_env('uid', $MESSAGE->uid); |
T |
69 |
$OUTPUT->set_env('safemode', $MESSAGE->is_safe); |
ed5407
|
70 |
|
T |
71 |
// check for unset disposition notification |
8fa58e
|
72 |
if ($MESSAGE->headers->mdn_to && !$MESSAGE->headers->mdn_sent && |
T |
73 |
$mbox_name != $CONFIG['drafts_mbox'] && $mbox_name != $CONFIG['sent_mbox']) |
fba1f5
|
74 |
{ |
0ea884
|
75 |
if (intval($CONFIG['mdn_requests']) === 1) |
T |
76 |
{ |
8fa58e
|
77 |
if (rcmail_send_mdn($MESSAGE->uid)) |
0ea884
|
78 |
$OUTPUT->show_message('receiptsent', 'confirmation'); |
T |
79 |
} |
|
80 |
else if (empty($CONFIG['mdn_requests'])) |
|
81 |
{ |
|
82 |
rcube_add_label('mdnrequest'); |
|
83 |
$OUTPUT->set_env('mdn_request', true); |
|
84 |
} |
fba1f5
|
85 |
} |
4e17e6
|
86 |
|
1f020b
|
87 |
|
S |
88 |
$next = $prev = $first = $last = -1; |
d17008
|
89 |
// get previous, first, next and last message UID |
1f020b
|
90 |
if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && |
df0da2
|
91 |
$IMAP->get_capability('sort')) || !empty($_REQUEST['_search'])) |
8d4bcd
|
92 |
{ |
T |
93 |
// Only if we use custom sorting |
|
94 |
$a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); |
e6f360
|
95 |
|
8fa58e
|
96 |
$MESSAGE->index = array_search((string)$MESSAGE->uid, $a_msg_index, TRUE); |
T |
97 |
$prev = isset($a_msg_index[$MESSAGE->index-1]) ? $a_msg_index[$MESSAGE->index-1] : -1 ; |
d17008
|
98 |
$first = count($a_msg_index)>0 ? $a_msg_index[0] : -1; |
8fa58e
|
99 |
$next = isset($a_msg_index[$MESSAGE->index+1]) ? $a_msg_index[$MESSAGE->index+1] : -1 ; |
d17008
|
100 |
$last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1; |
8d4bcd
|
101 |
} |
T |
102 |
else |
|
103 |
{ |
|
104 |
// this assumes that we are sorted by date_DESC |
8fa58e
|
105 |
$seq = $IMAP->get_id($MESSAGE->uid); |
8d4bcd
|
106 |
$prev = $IMAP->get_uid($seq + 1); |
d17008
|
107 |
$first = $IMAP->get_uid($IMAP->messagecount()); |
8d4bcd
|
108 |
$next = $IMAP->get_uid($seq - 1); |
d17008
|
109 |
$last = $IMAP->get_uid(1); |
8fa58e
|
110 |
$MESSAGE->index = $IMAP->messagecount() - $seq; |
8d4bcd
|
111 |
} |
4e17e6
|
112 |
|
e6f360
|
113 |
if ($prev > 0) |
f11541
|
114 |
$OUTPUT->set_env('prev_uid', $prev); |
d17008
|
115 |
if ($first >0) |
f11541
|
116 |
$OUTPUT->set_env('first_uid', $first); |
e6f360
|
117 |
if ($next > 0) |
f11541
|
118 |
$OUTPUT->set_env('next_uid', $next); |
d17008
|
119 |
if ($last >0) |
f11541
|
120 |
$OUTPUT->set_env('last_uid', $last); |
4e17e6
|
121 |
} |
T |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
function rcmail_message_attachments($attrib) |
8fa58e
|
126 |
{ |
T |
127 |
global $PRINT_MODE, $MESSAGE; |
|
128 |
|
|
129 |
$out = $ol = ''; |
4e17e6
|
130 |
|
8fa58e
|
131 |
if (sizeof($MESSAGE->attachments)) { |
T |
132 |
foreach ($MESSAGE->attachments as $attach_prop) { |
|
133 |
if ($PRINT_MODE) { |
|
134 |
$ol .= html::tag('li', null, sprintf("%s (%s)", Q($attach_prop->filename), Q(show_bytes($attach_prop->size)))); |
4e17e6
|
135 |
} |
8fa58e
|
136 |
else { |
T |
137 |
$ol .= html::tag('li', null, |
|
138 |
html::a(array( |
|
139 |
'href' => $MESSAGE->get_part_url($attach_prop->mime_id), |
|
140 |
'onclick' => sprintf( |
|
141 |
'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)', |
|
142 |
JS_OBJECT_NAME, |
|
143 |
$attach_prop->mime_id, |
|
144 |
$attach_prop->mimetype), |
|
145 |
), |
|
146 |
Q($attach_prop->filename))); |
|
147 |
} |
|
148 |
} |
4e17e6
|
149 |
|
8fa58e
|
150 |
$out = html::tag('ul', $attrib, $ol, html::$common_attrib); |
T |
151 |
} |
|
152 |
|
|
153 |
return $out; |
|
154 |
} |
4e17e6
|
155 |
|
T |
156 |
|
|
157 |
|
|
158 |
function rcmail_remote_objects_msg($attrib) |
|
159 |
{ |
f11541
|
160 |
global $CONFIG, $OUTPUT; |
4e17e6
|
161 |
|
T |
162 |
if (!$attrib['id']) |
|
163 |
$attrib['id'] = 'rcmremoteobjmsg'; |
|
164 |
|
|
165 |
// allow the following attributes to be added to the <div> tag |
|
166 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); |
|
167 |
$out = '<div' . $attrib_str . ">"; |
|
168 |
|
2bca6e
|
169 |
$out .= sprintf('%s <a href="#loadimages" onclick="%s.command(\'load-images\')">%s</a>', |
T |
170 |
Q(rcube_label('blockedimages')), |
f11541
|
171 |
JS_OBJECT_NAME, |
2bca6e
|
172 |
Q(rcube_label('showimages'))); |
4e17e6
|
173 |
|
T |
174 |
$out .= '</div>'; |
|
175 |
|
f11541
|
176 |
$OUTPUT->add_gui_object('remoteobjectsmsg', $attrib['id']); |
4e17e6
|
177 |
return $out; |
T |
178 |
} |
|
179 |
|
|
180 |
|
f11541
|
181 |
$OUTPUT->add_handlers(array( |
T |
182 |
'messageattachments' => 'rcmail_message_attachments', |
|
183 |
'blockedobjects' => 'rcmail_remote_objects_msg')); |
|
184 |
|
|
185 |
|
197601
|
186 |
if ($RCMAIL->action=='print' && template_exists('printmessage')) |
47124c
|
187 |
$OUTPUT->send('printmessage'); |
197601
|
188 |
else if ($RCMAIL->action=='preview' && template_exists('messagepreview')) |
47124c
|
189 |
$OUTPUT->send('messagepreview'); |
4e17e6
|
190 |
else |
47124c
|
191 |
$OUTPUT->send('message'); |
1f020b
|
192 |
?> |