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 | |
f5e7b3
|
8 |
| Copyright (C) 2005-2009, The Roundcube Dev Team | |
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 |
|
0911fa
|
44 |
$OUTPUT->set_pagetitle(abbreviate_string($MESSAGE->subject, 128, '...', true)); |
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))); |
80bc55
|
52 |
$OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter()); |
2cc1ca
|
53 |
$OUTPUT->set_env('mailbox', $mbox_name); |
11ea2a
|
54 |
|
112c91
|
55 |
if ($CONFIG['trash_mbox']) |
A |
56 |
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']); |
11ea2a
|
57 |
if ($CONFIG['flag_for_deletion']) |
A |
58 |
$OUTPUT->set_env('flag_for_deletion', true); |
|
59 |
if ($CONFIG['read_when_deleted']) |
|
60 |
$OUTPUT->set_env('read_when_deleted', true); |
|
61 |
if ($CONFIG['skip_deleted']) |
|
62 |
$OUTPUT->set_env('skip_deleted', true); |
|
63 |
if ($CONFIG['display_next']) |
|
64 |
$OUTPUT->set_env('display_next', true); |
e25a35
|
65 |
if ($MESSAGE->headers->others['list-post']) |
A |
66 |
$OUTPUT->set_env('list_post', true); |
40a186
|
67 |
if ($CONFIG['forward_attachment']) |
a509bb
|
68 |
$OUTPUT->set_env('forward_attachment', true); |
11ea2a
|
69 |
|
112c91
|
70 |
if (!$OUTPUT->ajax_call) |
c50d88
|
71 |
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash', |
A |
72 |
'movingmessage', 'deletingmessage'); |
172e33
|
73 |
|
ed5407
|
74 |
// check for unset disposition notification |
5b3dd4
|
75 |
if ($MESSAGE->headers->mdn_to && |
072fde
|
76 |
!$MESSAGE->headers->mdn_sent && !$MESSAGE->headers->seen && |
5c771c
|
77 |
($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*')) && |
5b3dd4
|
78 |
$mbox_name != $CONFIG['drafts_mbox'] && |
T |
79 |
$mbox_name != $CONFIG['sent_mbox']) |
fba1f5
|
80 |
{ |
a99968
|
81 |
$mdn_cfg = intval($CONFIG['mdn_requests']); |
A |
82 |
|
6c6bb0
|
83 |
if ($mdn_cfg == 1 || (($mdn_cfg == 3 || $mdn_cfg == 4) && rcmail_contact_exists($MESSAGE->sender['mailto']))) { |
a99968
|
84 |
// Send MDN |
A |
85 |
if (rcmail_send_mdn($MESSAGE, $smtp_error)) |
0ea884
|
86 |
$OUTPUT->show_message('receiptsent', 'confirmation'); |
ca90a9
|
87 |
else if ($smtp_error) |
A |
88 |
$OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']); |
6c6bb0
|
89 |
else |
86d43e
|
90 |
$OUTPUT->show_message('errorsendingreceipt', 'error'); |
0ea884
|
91 |
} |
6c6bb0
|
92 |
else if ($mdn_cfg != 2 && $mdn_cfg != 4) { |
a99968
|
93 |
// Ask user |
112c91
|
94 |
$OUTPUT->add_label('mdnrequest'); |
0ea884
|
95 |
$OUTPUT->set_env('mdn_request', true); |
T |
96 |
} |
fba1f5
|
97 |
} |
4e17e6
|
98 |
|
bc4960
|
99 |
if (!$MESSAGE->headers->seen && ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))) |
353657
|
100 |
$RCMAIL->plugins->exec_hook('message_read', array('uid' => $MESSAGE->uid, |
f52c93
|
101 |
'mailbox' => $mbox_name, 'message' => $MESSAGE)); |
cc97ea
|
102 |
} |
4e17e6
|
103 |
|
T |
104 |
|
|
105 |
|
|
106 |
function rcmail_message_attachments($attrib) |
8fa58e
|
107 |
{ |
T |
108 |
global $PRINT_MODE, $MESSAGE; |
83ba22
|
109 |
|
8fa58e
|
110 |
$out = $ol = ''; |
4e17e6
|
111 |
|
8fa58e
|
112 |
if (sizeof($MESSAGE->attachments)) { |
T |
113 |
foreach ($MESSAGE->attachments as $attach_prop) { |
|
114 |
if ($PRINT_MODE) { |
|
115 |
$ol .= html::tag('li', null, sprintf("%s (%s)", Q($attach_prop->filename), Q(show_bytes($attach_prop->size)))); |
4e17e6
|
116 |
} |
8fa58e
|
117 |
else { |
ee258c
|
118 |
if (mb_strlen($attach_prop->filename) > 50) { |
203ee4
|
119 |
$filename = abbreviate_string($attach_prop->filename, 50); |
T |
120 |
$title = $attach_prop->filename; |
|
121 |
} |
|
122 |
else { |
|
123 |
$filename = $attach_prop->filename; |
|
124 |
$title = ''; |
|
125 |
} |
|
126 |
|
8fa58e
|
127 |
$ol .= html::tag('li', null, |
T |
128 |
html::a(array( |
|
129 |
'href' => $MESSAGE->get_part_url($attach_prop->mime_id), |
|
130 |
'onclick' => sprintf( |
|
131 |
'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)', |
|
132 |
JS_OBJECT_NAME, |
|
133 |
$attach_prop->mime_id, |
e0bd70
|
134 |
rcmail_fix_mimetype($attach_prop->mimetype)), |
203ee4
|
135 |
'title' => Q($title), |
8fa58e
|
136 |
), |
30694e
|
137 |
Q($filename))); |
8fa58e
|
138 |
} |
T |
139 |
} |
4e17e6
|
140 |
|
8fa58e
|
141 |
$out = html::tag('ul', $attrib, $ol, html::$common_attrib); |
83ba22
|
142 |
} |
A |
143 |
|
8fa58e
|
144 |
return $out; |
T |
145 |
} |
4e17e6
|
146 |
|
T |
147 |
function rcmail_remote_objects_msg($attrib) |
62e43d
|
148 |
{ |
T |
149 |
global $MESSAGE, $RCMAIL; |
83ba22
|
150 |
|
4e17e6
|
151 |
if (!$attrib['id']) |
T |
152 |
$attrib['id'] = 'rcmremoteobjmsg'; |
83ba22
|
153 |
|
62e43d
|
154 |
$msg = Q(rcube_label('blockedimages')) . ' '; |
T |
155 |
$msg .= html::a(array('href' => "#loadimages", 'onclick' => JS_OBJECT_NAME.".command('load-images')"), Q(rcube_label('showimages'))); |
83ba22
|
156 |
|
62e43d
|
157 |
// add link to save sender in addressbook and reload message |
2a4135
|
158 |
if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('show_images') == 1) { |
62e43d
|
159 |
$msg .= ' ' . html::a(array('href' => "#alwaysload", 'onclick' => JS_OBJECT_NAME.".command('always-load')", 'style' => "white-space:nowrap"), |
T |
160 |
Q(rcube_label(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto']))))); |
4e17e6
|
161 |
} |
83ba22
|
162 |
|
62e43d
|
163 |
$RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']); |
T |
164 |
return html::div($attrib, $msg); |
a99968
|
165 |
} |
A |
166 |
|
|
167 |
function rcmail_contact_exists($email) |
|
168 |
{ |
|
169 |
global $RCMAIL; |
|
170 |
|
|
171 |
if ($email) { |
|
172 |
// @TODO: search in all address books? |
|
173 |
$CONTACTS = $RCMAIL->get_address_book(null, true); |
|
174 |
$existing = $CONTACTS->search('email', $email, true, false); |
|
175 |
if ($existing->count) |
|
176 |
return true; |
|
177 |
} |
|
178 |
|
|
179 |
return false; |
62e43d
|
180 |
} |
4e17e6
|
181 |
|
T |
182 |
|
f11541
|
183 |
$OUTPUT->add_handlers(array( |
T |
184 |
'messageattachments' => 'rcmail_message_attachments', |
ac5d15
|
185 |
'mailboxname' => 'rcmail_mailbox_name_display', |
f11541
|
186 |
'blockedobjects' => 'rcmail_remote_objects_msg')); |
T |
187 |
|
|
188 |
|
83ba22
|
189 |
if ($RCMAIL->action=='print' && $OUTPUT->template_exists('messageprint')) |
A |
190 |
$OUTPUT->send('messageprint', false); |
e58df3
|
191 |
else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview')) |
353657
|
192 |
$OUTPUT->send('messagepreview', false); |
4e17e6
|
193 |
else |
353657
|
194 |
$OUTPUT->send('message', false); |
A |
195 |
|
|
196 |
|
|
197 |
// mark message as read |
c64277
|
198 |
if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen && |
A |
199 |
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))) |
|
200 |
{ |
b46edc
|
201 |
if ($IMAP->set_flag($MESSAGE->uid, 'SEEN')) { |
A |
202 |
if ($count = rcmail_get_unseen_count($mbox_name)) { |
|
203 |
rcmail_set_unseen_count($mbox_name, $count - 1); |
|
204 |
} |
|
205 |
} |
c64277
|
206 |
} |
353657
|
207 |
|
A |
208 |
exit; |
b25dfd
|
209 |
|