commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/func.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
8fa58e
|
8 |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Provide webmail functionality and GUI objects | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
require_once('lib/enriched.inc'); |
fba1f5
|
23 |
require_once('include/rcube_smtp.inc'); |
4e17e6
|
24 |
|
T |
25 |
|
|
26 |
$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; |
|
27 |
|
f11541
|
28 |
if (empty($_SESSION['mbox'])) |
c5ac07
|
29 |
$_SESSION['mbox'] = $IMAP->get_mailbox_name(); |
S |
30 |
|
4e17e6
|
31 |
// set imap properties and session vars |
b3ce79
|
32 |
if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC)) |
c57996
|
33 |
$IMAP->set_mailbox(($_SESSION['mbox'] = $mbox)); |
4e17e6
|
34 |
|
b3ce79
|
35 |
if (!empty($_GET['_page'])) |
c57996
|
36 |
$IMAP->set_page(($_SESSION['page'] = intval($_GET['_page']))); |
4e17e6
|
37 |
|
fecb03
|
38 |
// set mailbox to INBOX if not set |
T |
39 |
if (empty($_SESSION['mbox'])) |
|
40 |
$_SESSION['mbox'] = $IMAP->get_mailbox_name(); |
4e17e6
|
41 |
|
6a35c8
|
42 |
// set default sort col/order to session |
T |
43 |
if (!isset($_SESSION['sort_col'])) |
|
44 |
$_SESSION['sort_col'] = $CONFIG['message_sort_col']; |
|
45 |
if (!isset($_SESSION['sort_order'])) |
|
46 |
$_SESSION['sort_order'] = $CONFIG['message_sort_order']; |
2bca6e
|
47 |
|
T |
48 |
// set message set for search result |
8d0758
|
49 |
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) |
1f020b
|
50 |
{ |
8d0758
|
51 |
$IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]); |
1f020b
|
52 |
$OUTPUT->set_env('search_request', $_REQUEST['_search']); |
S |
53 |
$OUTPUT->set_env('search_text', $_SESSION['last_text_search']); |
|
54 |
} |
4e17e6
|
55 |
|
T |
56 |
|
|
57 |
// set current mailbox in client environment |
f11541
|
58 |
$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name()); |
719804
|
59 |
$OUTPUT->set_env('quota', $IMAP->get_capability('quota')); |
ddd776
|
60 |
$OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter()); |
4e17e6
|
61 |
|
T |
62 |
if ($CONFIG['trash_mbox']) |
f11541
|
63 |
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']); |
1966c5
|
64 |
if ($CONFIG['drafts_mbox']) |
f11541
|
65 |
$OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']); |
b4b081
|
66 |
if ($CONFIG['junk_mbox']) |
f11541
|
67 |
$OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']); |
T |
68 |
|
|
69 |
if (!$OUTPUT->ajax_call) |
e3902e
|
70 |
rcube_add_label('checkingmail', 'deletemessage', 'movemessagetotrash', 'movingmessage'); |
f11541
|
71 |
|
5eee00
|
72 |
// set page title |
197601
|
73 |
if (empty($RCMAIL->action) || $RCMAIL->action == 'list') |
fed22f
|
74 |
$OUTPUT->set_pagetitle(rcmail_localize_foldername($IMAP->get_mailbox_name())); |
5eee00
|
75 |
|
4e17e6
|
76 |
|
45f56c
|
77 |
/** |
T |
78 |
* return the message list as HTML table |
|
79 |
*/ |
4e17e6
|
80 |
function rcmail_message_list($attrib) |
T |
81 |
{ |
f11541
|
82 |
global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT; |
b076a4
|
83 |
|
4e17e6
|
84 |
$skin_path = $CONFIG['skin_path']; |
e189a6
|
85 |
$image_tag = '<img src="%s%s" alt="%s" />'; |
b076a4
|
86 |
|
f3b659
|
87 |
// check to see if we have some settings for sorting |
6a35c8
|
88 |
$sort_col = $_SESSION['sort_col']; |
T |
89 |
$sort_order = $_SESSION['sort_order']; |
24053e
|
90 |
|
T |
91 |
// add some labels to client |
|
92 |
rcube_add_label('from', 'to'); |
f3b659
|
93 |
|
4e17e6
|
94 |
// get message headers |
f3b659
|
95 |
$a_headers = $IMAP->list_headers('', '', $sort_col, $sort_order); |
4e17e6
|
96 |
|
T |
97 |
// add id to message list table if not specified |
|
98 |
if (!strlen($attrib['id'])) |
|
99 |
$attrib['id'] = 'rcubemessagelist'; |
|
100 |
|
|
101 |
// allow the following attributes to be added to the <table> tag |
|
102 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); |
|
103 |
|
|
104 |
$out = '<table' . $attrib_str . ">\n"; |
e0ddd4
|
105 |
|
4e17e6
|
106 |
// define list of cols to be displayed |
T |
107 |
$a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); |
c8c1e0
|
108 |
$a_sort_cols = array('subject', 'date', 'from', 'to', 'size'); |
41bece
|
109 |
|
T |
110 |
$mbox = $IMAP->get_mailbox_name(); |
4e17e6
|
111 |
|
T |
112 |
// show 'to' instead of from in sent messages |
41bece
|
113 |
if (($mbox==$CONFIG['sent_mbox'] || $mbox==$CONFIG['drafts_mbox']) && ($f = array_search('from', $a_show_cols)) |
8c2e58
|
114 |
&& !array_search('to', $a_show_cols)) |
4e17e6
|
115 |
$a_show_cols[$f] = 'to'; |
8c2e58
|
116 |
|
e0ddd4
|
117 |
// add col definition |
T |
118 |
$out .= '<colgroup>'; |
01c86f
|
119 |
$out .= '<col class="icon" />'; |
e0ddd4
|
120 |
|
T |
121 |
foreach ($a_show_cols as $col) |
01c86f
|
122 |
$out .= sprintf('<col class="%s" />', $col); |
e0ddd4
|
123 |
|
01c86f
|
124 |
$out .= '<col class="icon" />'; |
e0ddd4
|
125 |
$out .= "</colgroup>\n"; |
4e17e6
|
126 |
|
T |
127 |
// add table title |
|
128 |
$out .= "<thead><tr>\n<td class=\"icon\"> </td>\n"; |
b076a4
|
129 |
|
f3b659
|
130 |
$javascript = ''; |
4e17e6
|
131 |
foreach ($a_show_cols as $col) |
f3b659
|
132 |
{ |
T |
133 |
// get column name |
e189a6
|
134 |
$col_name = $col != 'flag' ? Q(rcube_label($col)) : sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], ''); |
f3b659
|
135 |
|
T |
136 |
// make sort links |
|
137 |
$sort = ''; |
2a9cb3
|
138 |
if (in_array($col, $a_sort_cols)) |
f3b659
|
139 |
{ |
1cded8
|
140 |
// have buttons configured |
T |
141 |
if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton'])) |
|
142 |
{ |
|
143 |
$sort = ' '; |
b076a4
|
144 |
|
1cded8
|
145 |
// asc link |
T |
146 |
if (!empty($attrib['sortascbutton'])) |
|
147 |
{ |
f11541
|
148 |
$sort .= $OUTPUT->button(array( |
T |
149 |
'command' => 'sort', |
|
150 |
'prop' => $col.'_ASC', |
|
151 |
'image' => $attrib['sortascbutton'], |
|
152 |
'align' => 'absmiddle', |
|
153 |
'title' => 'sortasc')); |
1cded8
|
154 |
} |
b076a4
|
155 |
|
1cded8
|
156 |
// desc link |
T |
157 |
if (!empty($attrib['sortdescbutton'])) |
|
158 |
{ |
f11541
|
159 |
$sort .= $OUTPUT->button(array( |
T |
160 |
'command' => 'sort', |
|
161 |
'prop' => $col.'_DESC', |
|
162 |
'image' => $attrib['sortdescbutton'], |
|
163 |
'align' => 'absmiddle', |
|
164 |
'title' => 'sortdesc')); |
1cded8
|
165 |
} |
T |
166 |
} |
|
167 |
// just add a link tag to the header |
|
168 |
else |
b076a4
|
169 |
{ |
41bece
|
170 |
$col_name = sprintf( |
T |
171 |
'<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>', |
|
172 |
JS_OBJECT_NAME, |
|
173 |
$col, |
|
174 |
rcube_label('sortby'), |
|
175 |
$col_name); |
b076a4
|
176 |
} |
f3b659
|
177 |
} |
b076a4
|
178 |
|
T |
179 |
$sort_class = $col==$sort_col ? " sorted$sort_order" : ''; |
f3b659
|
180 |
|
T |
181 |
// put it all together |
b076a4
|
182 |
$out .= '<td class="'.$col.$sort_class.'" id="rcmHead'.$col.'">' . "$col_name$sort</td>\n"; |
f3b659
|
183 |
} |
4e17e6
|
184 |
|
T |
185 |
$out .= '<td class="icon">'.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : '')."</td>\n"; |
|
186 |
$out .= "</tr></thead>\n<tbody>\n"; |
|
187 |
|
|
188 |
// no messages in this mailbox |
|
189 |
if (!sizeof($a_headers)) |
5eee00
|
190 |
$OUTPUT->show_message('nomessagesfound', 'notice'); |
4e17e6
|
191 |
|
T |
192 |
|
|
193 |
$a_js_message_arr = array(); |
|
194 |
|
|
195 |
// create row for each message |
|
196 |
foreach ($a_headers as $i => $header) //while (list($i, $header) = each($a_headers)) |
|
197 |
{ |
e189a6
|
198 |
$message_icon = $attach_icon = $flagged_icon = ''; |
4e17e6
|
199 |
$js_row_arr = array(); |
T |
200 |
$zebra_class = $i%2 ? 'even' : 'odd'; |
|
201 |
|
|
202 |
// set messag attributes to javascript array |
6ec0a8
|
203 |
if ($header->deleted) |
S |
204 |
$js_row_arr['deleted'] = true; |
4e17e6
|
205 |
if (!$header->seen) |
T |
206 |
$js_row_arr['unread'] = true; |
|
207 |
if ($header->answered) |
|
208 |
$js_row_arr['replied'] = true; |
d73404
|
209 |
if ($header->forwarded) |
A |
210 |
$js_row_arr['forwarded'] = true; |
e189a6
|
211 |
if ($header->flagged) |
A |
212 |
$js_row_arr['flagged'] = true; |
|
213 |
|
6ec0a8
|
214 |
// set message icon |
S |
215 |
if ($attrib['deletedicon'] && $header->deleted) |
|
216 |
$message_icon = $attrib['deletedicon']; |
d73404
|
217 |
else if ($attrib['repliedicon'] && $header->answered) |
A |
218 |
{ |
|
219 |
if ($attrib['forwardedrepliedicon'] && $header->forwarded) |
|
220 |
$message_icon = $attrib['forwardedrepliedicon']; |
|
221 |
else |
|
222 |
$message_icon = $attrib['repliedicon']; |
|
223 |
} |
|
224 |
else if ($attrib['forwardedicon'] && $header->forwarded) |
|
225 |
$message_icon = $attrib['forwardedicon']; |
6ec0a8
|
226 |
else if ($attrib['unreadicon'] && !$header->seen) |
4e17e6
|
227 |
$message_icon = $attrib['unreadicon']; |
T |
228 |
else if ($attrib['messageicon']) |
|
229 |
$message_icon = $attrib['messageicon']; |
e189a6
|
230 |
|
A |
231 |
if ($attrib['flaggedicon'] && $header->flagged) |
|
232 |
$flagged_icon = $attrib['flaggedicon']; |
|
233 |
else if ($attrib['unflaggedicon'] && !$header->flagged) |
|
234 |
$flagged_icon = $attrib['unflaggedicon']; |
4e17e6
|
235 |
|
f11541
|
236 |
// set attachment icon |
8d4bcd
|
237 |
if ($attrib['attachmenticon'] && preg_match("/multipart\/[mr]/i", $header->ctype)) |
4e17e6
|
238 |
$attach_icon = $attrib['attachmenticon']; |
T |
239 |
|
15a9d1
|
240 |
$out .= sprintf('<tr id="rcmrow%d" class="message%s%s %s">'."\n", |
T |
241 |
$header->uid, |
|
242 |
$header->seen ? '' : ' unread', |
|
243 |
$header->deleted ? ' deleted' : '', |
e189a6
|
244 |
$header->flagged ? ' flagged' : '', |
15a9d1
|
245 |
$zebra_class); |
T |
246 |
|
4e17e6
|
247 |
$out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : ''); |
e189a6
|
248 |
|
1088d6
|
249 |
|
583850
|
250 |
if (!empty($header->charset)) |
A |
251 |
$IMAP->set_charset($header->charset); |
|
252 |
|
4e17e6
|
253 |
// format each col |
T |
254 |
foreach ($a_show_cols as $col) |
|
255 |
{ |
|
256 |
if ($col=='from' || $col=='to') |
8e44f4
|
257 |
$cont = Q(rcmail_address_string($header->$col, 3, false, $attrib['addicon']), 'show'); |
4e17e6
|
258 |
else if ($col=='subject') |
b4b081
|
259 |
{ |
41bece
|
260 |
$action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; |
2b962c
|
261 |
$uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid'; |
583850
|
262 |
$cont = Q($IMAP->decode_header($header->$col)); |
f11541
|
263 |
if (empty($cont)) $cont = Q(rcube_label('nosubject')); |
b2fb95
|
264 |
$cont = sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); |
b4b081
|
265 |
} |
e189a6
|
266 |
else if ($col=='flag') |
A |
267 |
$cont = $flagged_icon ? sprintf($image_tag, $skin_path, $flagged_icon, '') : ''; |
4e17e6
|
268 |
else if ($col=='size') |
T |
269 |
$cont = show_bytes($header->$col); |
|
270 |
else if ($col=='date') |
f11541
|
271 |
$cont = format_date($header->date); |
4e17e6
|
272 |
else |
2bca6e
|
273 |
$cont = Q($header->$col); |
4e17e6
|
274 |
|
2bca6e
|
275 |
$out .= '<td class="'.$col.'">' . $cont . "</td>\n"; |
4e17e6
|
276 |
} |
T |
277 |
|
|
278 |
$out .= sprintf("<td class=\"icon\">%s</td>\n", $attach_icon ? sprintf($image_tag, $skin_path, $attach_icon, '') : ''); |
|
279 |
$out .= "</tr>\n"; |
|
280 |
|
|
281 |
if (sizeof($js_row_arr)) |
|
282 |
$a_js_message_arr[$header->uid] = $js_row_arr; |
|
283 |
} |
|
284 |
|
|
285 |
// complete message table |
|
286 |
$out .= "</tbody></table>\n"; |
|
287 |
|
|
288 |
|
|
289 |
$message_count = $IMAP->messagecount(); |
|
290 |
|
|
291 |
// set client env |
f11541
|
292 |
$OUTPUT->add_gui_object('mailcontframe', 'mailcontframe'); |
T |
293 |
$OUTPUT->add_gui_object('messagelist', $attrib['id']); |
|
294 |
$OUTPUT->set_env('messagecount', $message_count); |
|
295 |
$OUTPUT->set_env('current_page', $IMAP->list_page); |
|
296 |
$OUTPUT->set_env('pagecount', ceil($message_count/$IMAP->page_size)); |
|
297 |
$OUTPUT->set_env('sort_col', $sort_col); |
|
298 |
$OUTPUT->set_env('sort_order', $sort_order); |
4e17e6
|
299 |
|
T |
300 |
if ($attrib['messageicon']) |
f11541
|
301 |
$OUTPUT->set_env('messageicon', $skin_path . $attrib['messageicon']); |
6ec0a8
|
302 |
if ($attrib['deletedicon']) |
f11541
|
303 |
$OUTPUT->set_env('deletedicon', $skin_path . $attrib['deletedicon']); |
4e17e6
|
304 |
if ($attrib['unreadicon']) |
f11541
|
305 |
$OUTPUT->set_env('unreadicon', $skin_path . $attrib['unreadicon']); |
4e17e6
|
306 |
if ($attrib['repliedicon']) |
f11541
|
307 |
$OUTPUT->set_env('repliedicon', $skin_path . $attrib['repliedicon']); |
d73404
|
308 |
if ($attrib['forwardedicon']) |
A |
309 |
$OUTPUT->set_env('forwardedicon', $skin_path . $attrib['forwardedicon']); |
|
310 |
if ($attrib['forwardedrepliedicon']) |
|
311 |
$OUTPUT->set_env('forwardedrepliedicon', $skin_path . $attrib['forwardedrepliedicon']); |
4e17e6
|
312 |
if ($attrib['attachmenticon']) |
f11541
|
313 |
$OUTPUT->set_env('attachmenticon', $skin_path . $attrib['attachmenticon']); |
e189a6
|
314 |
if ($attrib['flaggedicon']) |
A |
315 |
$OUTPUT->set_env('flaggedicon', $skin_path . $attrib['flaggedicon']); |
|
316 |
if ($attrib['unflaggedicon']) |
|
317 |
$OUTPUT->set_env('unflaggedicon', $skin_path . $attrib['unflaggedicon']); |
4e17e6
|
318 |
|
ae895a
|
319 |
$OUTPUT->set_env('messages', $a_js_message_arr); |
d24d20
|
320 |
$OUTPUT->set_env('coltypes', $a_show_cols); |
f11541
|
321 |
|
6b47de
|
322 |
$OUTPUT->include_script('list.js'); |
4e17e6
|
323 |
|
T |
324 |
return $out; |
|
325 |
} |
|
326 |
|
|
327 |
|
45f56c
|
328 |
/** |
T |
329 |
* return javascript commands to add rows to the message list |
|
330 |
*/ |
4e17e6
|
331 |
function rcmail_js_message_list($a_headers, $insert_top=FALSE) |
T |
332 |
{ |
f11541
|
333 |
global $CONFIG, $IMAP, $OUTPUT; |
4e17e6
|
334 |
|
T |
335 |
$a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); |
41bece
|
336 |
$mbox = $IMAP->get_mailbox_name(); |
4e17e6
|
337 |
|
T |
338 |
// show 'to' instead of from in sent messages |
41bece
|
339 |
if (($mbox == $CONFIG['sent_mbox'] || $mbox == $CONFIG['drafts_mbox']) |
f11541
|
340 |
&& (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false) |
4e17e6
|
341 |
$a_show_cols[$f] = 'to'; |
T |
342 |
|
f11541
|
343 |
$OUTPUT->command('set_message_coltypes', $a_show_cols); |
25d8ba
|
344 |
|
4e17e6
|
345 |
// loop through message headers |
ecd2e7
|
346 |
foreach ($a_headers as $n => $header) |
4e17e6
|
347 |
{ |
T |
348 |
$a_msg_cols = array(); |
|
349 |
$a_msg_flags = array(); |
ecd2e7
|
350 |
|
T |
351 |
if (empty($header)) |
|
352 |
continue; |
f11541
|
353 |
|
583850
|
354 |
if (!empty($header->charset)) |
A |
355 |
$IMAP->set_charset($header->charset); |
|
356 |
|
4e17e6
|
357 |
// format each col; similar as in rcmail_message_list() |
T |
358 |
foreach ($a_show_cols as $col) |
|
359 |
{ |
|
360 |
if ($col=='from' || $col=='to') |
583850
|
361 |
$cont = Q(rcmail_address_string($header->$col, 3), 'show'); |
4e17e6
|
362 |
else if ($col=='subject') |
7bbd5f
|
363 |
{ |
41bece
|
364 |
$action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; |
2b962c
|
365 |
$uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid'; |
583850
|
366 |
$cont = Q($IMAP->decode_header($header->$col)); |
7bbd5f
|
367 |
if (!$cont) $cont = Q(rcube_label('nosubject')); |
b2fb95
|
368 |
$cont = sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); |
7bbd5f
|
369 |
} |
4e17e6
|
370 |
else if ($col=='size') |
T |
371 |
$cont = show_bytes($header->$col); |
|
372 |
else if ($col=='date') |
f11541
|
373 |
$cont = format_date($header->date); |
4e17e6
|
374 |
else |
2bca6e
|
375 |
$cont = Q($header->$col); |
4e17e6
|
376 |
|
T |
377 |
$a_msg_cols[$col] = $cont; |
|
378 |
} |
|
379 |
|
6ec0a8
|
380 |
$a_msg_flags['deleted'] = $header->deleted ? 1 : 0; |
4e17e6
|
381 |
$a_msg_flags['unread'] = $header->seen ? 0 : 1; |
T |
382 |
$a_msg_flags['replied'] = $header->answered ? 1 : 0; |
d73404
|
383 |
$a_msg_flags['forwarded'] = $header->forwarded ? 1 : 0; |
e189a6
|
384 |
$a_msg_flags['flagged'] = $header->flagged ? 1 : 0; |
A |
385 |
|
f11541
|
386 |
$OUTPUT->command('add_message_row', |
T |
387 |
$header->uid, |
|
388 |
$a_msg_cols, |
|
389 |
$a_msg_flags, |
|
390 |
preg_match("/multipart\/m/i", $header->ctype), |
|
391 |
$insert_top); |
4e17e6
|
392 |
} |
T |
393 |
} |
|
394 |
|
|
395 |
|
45f56c
|
396 |
/** |
T |
397 |
* return an HTML iframe for loading mail content |
|
398 |
*/ |
b19097
|
399 |
function rcmail_messagecontent_frame($attrib) |
T |
400 |
{ |
f11541
|
401 |
global $OUTPUT; |
b19097
|
402 |
|
T |
403 |
if (empty($attrib['id'])) |
|
404 |
$attrib['id'] = 'rcmailcontentwindow'; |
|
405 |
|
|
406 |
// allow the following attributes to be added to the <iframe> tag |
|
407 |
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height', 'frameborder')); |
|
408 |
$framename = $attrib['id']; |
|
409 |
|
|
410 |
$out = sprintf('<iframe name="%s"%s></iframe>'."\n", |
|
411 |
$framename, |
|
412 |
$attrib_str); |
|
413 |
|
f11541
|
414 |
$OUTPUT->set_env('contentframe', $framename); |
T |
415 |
$OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif'); |
b19097
|
416 |
|
T |
417 |
return $out; |
|
418 |
} |
|
419 |
|
4e17e6
|
420 |
|
45f56c
|
421 |
/** |
T |
422 |
* |
|
423 |
*/ |
4e17e6
|
424 |
function rcmail_messagecount_display($attrib) |
T |
425 |
{ |
f11541
|
426 |
global $IMAP, $OUTPUT; |
4e17e6
|
427 |
|
T |
428 |
if (!$attrib['id']) |
|
429 |
$attrib['id'] = 'rcmcountdisplay'; |
|
430 |
|
f11541
|
431 |
$OUTPUT->add_gui_object('countdisplay', $attrib['id']); |
4e17e6
|
432 |
|
T |
433 |
// allow the following attributes to be added to the <span> tag |
|
434 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); |
|
435 |
|
|
436 |
|
|
437 |
$out = '<span' . $attrib_str . '>'; |
|
438 |
$out .= rcmail_get_messagecount_text(); |
|
439 |
$out .= '</span>'; |
|
440 |
return $out; |
|
441 |
} |
|
442 |
|
|
443 |
|
45f56c
|
444 |
/** |
T |
445 |
* |
|
446 |
*/ |
58e360
|
447 |
function rcmail_quota_display($attrib) |
T |
448 |
{ |
f11541
|
449 |
global $OUTPUT, $COMM_PATH; |
58e360
|
450 |
|
T |
451 |
if (!$attrib['id']) |
|
452 |
$attrib['id'] = 'rcmquotadisplay'; |
|
453 |
|
6d2714
|
454 |
if(isset($attrib['display'])) |
A |
455 |
$_SESSION['quota_display'] = $attrib['display']; |
|
456 |
|
f11541
|
457 |
$OUTPUT->add_gui_object('quotadisplay', $attrib['id']); |
58e360
|
458 |
|
T |
459 |
// allow the following attributes to be added to the <span> tag |
97f57d
|
460 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display')); |
23796e
|
461 |
|
S |
462 |
$out = '<span' . $attrib_str . '>'; |
6cd009
|
463 |
$out .= rcmail_quota_content(NULL, $attrib); |
23796e
|
464 |
$out .= '</span>'; |
S |
465 |
return $out; |
|
466 |
} |
|
467 |
|
|
468 |
|
45f56c
|
469 |
/** |
T |
470 |
* |
|
471 |
*/ |
6cd009
|
472 |
function rcmail_quota_content($quota=NULL, $attrib=NULL) |
23796e
|
473 |
{ |
876b15
|
474 |
global $IMAP, $COMM_PATH, $RCMAIL; |
3ea0e3
|
475 |
|
6d2714
|
476 |
$display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; |
A |
477 |
|
|
478 |
if (is_array($quota) && !empty($quota['used']) && !empty($quota['total'])) |
3ea0e3
|
479 |
{ |
6d2714
|
480 |
if (!isset($quota['percent'])) |
A |
481 |
$quota['percent'] = $quota['used'] / $quota['total']; |
|
482 |
} |
|
483 |
elseif (!$IMAP->get_capability('QUOTA')) |
|
484 |
return rcube_label('unknown'); |
|
485 |
else |
|
486 |
$quota = $IMAP->get_quota(); |
|
487 |
|
876b15
|
488 |
if ($quota && !($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited'))) |
6d2714
|
489 |
{ |
A |
490 |
$quota_text = sprintf('%s / %s (%.0f%%)', |
|
491 |
show_bytes($quota['used'] * 1024), |
|
492 |
show_bytes($quota['total'] * 1024), |
|
493 |
$quota['percent']); |
3ea0e3
|
494 |
|
T |
495 |
// show quota as image (by Brett Patterson) |
23796e
|
496 |
if ($display == 'image' && function_exists('imagegif')) |
3ea0e3
|
497 |
{ |
6cd009
|
498 |
if (!$attrib['width']) |
A |
499 |
$attrib['width'] = isset($_SESSION['quota_width']) ? $_SESSION['quota_width'] : 100; |
|
500 |
else |
|
501 |
$_SESSION['quota_width'] = $attrib['width']; |
|
502 |
|
|
503 |
if (!$attrib['height']) |
|
504 |
$attrib['height'] = isset($_SESSION['quota_height']) ? $_SESSION['quota_height'] : 14; |
|
505 |
else |
|
506 |
$_SESSION['quota_height'] = $attrib['height']; |
|
507 |
|
f11541
|
508 |
$quota_text = sprintf('<img src="./bin/quotaimg.php?u=%s&q=%d&w=%d&h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', |
3ea0e3
|
509 |
$quota['used'], $quota['total'], |
fda695
|
510 |
$attrib['width'], $attrib['height'], |
T |
511 |
$attrib['width'], $attrib['height'], |
|
512 |
$quota_text, |
6cd009
|
513 |
show_bytes($quota['used'] * 1024), |
A |
514 |
show_bytes($quota['total'] * 1024)); |
3ea0e3
|
515 |
} |
T |
516 |
} |
|
517 |
else |
4647e1
|
518 |
$quota_text = rcube_label('unlimited'); |
58e360
|
519 |
|
23796e
|
520 |
return $quota_text; |
58e360
|
521 |
} |
T |
522 |
|
4e17e6
|
523 |
|
45f56c
|
524 |
/** |
T |
525 |
* |
|
526 |
*/ |
4647e1
|
527 |
function rcmail_get_messagecount_text($count=NULL, $page=NULL) |
4e17e6
|
528 |
{ |
T |
529 |
global $IMAP, $MESSAGE; |
|
530 |
|
8fa58e
|
531 |
if (isset($MESSAGE->index)) |
4e17e6
|
532 |
{ |
T |
533 |
return rcube_label(array('name' => 'messagenrof', |
8fa58e
|
534 |
'vars' => array('nr' => $MESSAGE->index+1, |
4647e1
|
535 |
'count' => $count!==NULL ? $count : $IMAP->messagecount()))); |
4e17e6
|
536 |
} |
31b2ce
|
537 |
|
4647e1
|
538 |
if ($page===NULL) |
T |
539 |
$page = $IMAP->list_page; |
|
540 |
|
|
541 |
$start_msg = ($page-1) * $IMAP->page_size + 1; |
|
542 |
$max = $count!==NULL ? $count : $IMAP->messagecount(); |
4e17e6
|
543 |
|
T |
544 |
if ($max==0) |
|
545 |
$out = rcube_label('mailboxempty'); |
|
546 |
else |
|
547 |
$out = rcube_label(array('name' => 'messagesfromto', |
|
548 |
'vars' => array('from' => $start_msg, |
|
549 |
'to' => min($max, $start_msg + $IMAP->page_size - 1), |
|
550 |
'count' => $max))); |
|
551 |
|
2bca6e
|
552 |
return Q($out); |
4e17e6
|
553 |
} |
T |
554 |
|
ac5d15
|
555 |
/** |
T |
556 |
* |
|
557 |
*/ |
|
558 |
function rcmail_mailbox_name_display($attrib) |
|
559 |
{ |
|
560 |
global $RCMAIL; |
|
561 |
|
|
562 |
if (!$attrib['id']) |
|
563 |
$attrib['id'] = 'rcmmailboxname'; |
|
564 |
|
|
565 |
$RCMAIL->output->add_gui_object('mailboxname', $attrib['id']); |
|
566 |
|
|
567 |
return html::span($attrib, rcmail_get_mailbox_name_text()); |
|
568 |
} |
|
569 |
|
|
570 |
function rcmail_get_mailbox_name_text() |
|
571 |
{ |
|
572 |
global $RCMAIL; |
|
573 |
return rcmail_localize_foldername($RCMAIL->imap->get_mailbox_name()); |
|
574 |
} |
|
575 |
|
4e17e6
|
576 |
|
45f56c
|
577 |
/** |
65cc1c
|
578 |
* Convert the given message part to proper HTML |
T |
579 |
* which can be displayed the message view |
45f56c
|
580 |
* |
65cc1c
|
581 |
* @param object rcube_message_part Message part |
T |
582 |
* @param bool True if external objects (ie. images ) are allowed |
|
583 |
* @param bool True if part should be converted to plaintext |
|
584 |
* @return string Formatted HTML string |
45f56c
|
585 |
*/ |
21e724
|
586 |
function rcmail_print_body($part, $p = array()) |
45f56c
|
587 |
{ |
T |
588 |
global $REMOTE_OBJECTS; |
4e17e6
|
589 |
|
21e724
|
590 |
$p += array('safe' => false, 'plain' => false, 'inline_html' => true); |
T |
591 |
|
5cc4b1
|
592 |
// convert html to text/plain |
21e724
|
593 |
if ($part->ctype_secondary == 'html' && $p['plain']) { |
45f56c
|
594 |
$txt = new html2text($part->body, false, true); |
5cc4b1
|
595 |
$body = $txt->get_text(); |
T |
596 |
$part->ctype_secondary = 'plain'; |
45f56c
|
597 |
} |
4e17e6
|
598 |
// text/html |
45f56c
|
599 |
else if ($part->ctype_secondary == 'html') { |
2cb6d4
|
600 |
$html = $part->body; |
c1b81f
|
601 |
|
7f6258
|
602 |
// special replacements (not properly handled by washtml class) |
A |
603 |
$html_search = array( |
|
604 |
'/(<\/nobr>)(\s+)(<nobr>)/i', // space(s) between <NOBR> |
|
605 |
'/(<[\/]*st1:[^>]+>)/i', // Microsoft's Smart Tags <ST1> |
2cb6d4
|
606 |
'/<title>.*<\/title>/i', // PHP bug #32547 workaround: remove title tag |
A |
607 |
'/<html[^>]*>/im', // malformed html: remove html tags (#1485139) |
|
608 |
'/<\/html>/i', // malformed html: remove html tags (#1485139) |
7f6258
|
609 |
); |
A |
610 |
$html_replace = array( |
|
611 |
'\\1'.' '.'\\3', |
|
612 |
'', |
2cb6d4
|
613 |
'', |
A |
614 |
'', |
|
615 |
'', |
7f6258
|
616 |
); |
A |
617 |
$html = preg_replace($html_search, $html_replace, $html); |
|
618 |
|
2cb6d4
|
619 |
// charset was converted to UTF-8 in rcube_imap::get_message_part() -> change charset specification in HTML accordingly |
A |
620 |
if (preg_match('/(\s+content=[\'"]\w+\/\w+;\s*charset)=([a-z0-9-_]+)/i', $html)) |
|
621 |
$html = preg_replace('/(\s+content=[\'"]\w+\/\w+;\s*charset)=([a-z0-9-_]+)/i', '\\1='.RCMAIL_CHARSET, $html); |
|
622 |
else { |
|
623 |
// add head for malformed messages, washtml cannot work without that |
|
624 |
if (!preg_match('/<head[^>]*>(.*)<\/head>/Uims', $html)) |
|
625 |
$html = '<head></head>'. $html; |
|
626 |
$html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '</head>')), 0); |
|
627 |
} |
|
628 |
|
45f56c
|
629 |
// clean HTML with washhtml by Frederic Motte |
21e724
|
630 |
$wash_opts = array( |
45f56c
|
631 |
'show_washed' => false, |
21e724
|
632 |
'allow_remote' => $p['safe'], |
45f56c
|
633 |
'blocked_src' => "./program/blocked.gif", |
350459
|
634 |
'charset' => RCMAIL_CHARSET, |
45f56c
|
635 |
'cid_map' => $part->replaces, |
21e724
|
636 |
'html_elements' => array('body'), |
T |
637 |
); |
|
638 |
|
|
639 |
if (!$p['inline_html']) { |
|
640 |
$wash_opts['html_elements'] = array('html','head','title','body'); |
|
641 |
} |
|
642 |
|
|
643 |
$washer = new washtml($wash_opts); |
|
644 |
$washer->add_callback('form', 'rcmail_washtml_callback'); |
36c236
|
645 |
|
T |
646 |
if ($p['safe']) { // allow CSS styles, will be sanitized by rcmail_washtml_callback() |
|
647 |
$washer->add_callback('style', 'rcmail_washtml_callback'); |
|
648 |
} |
|
649 |
|
21e724
|
650 |
$body = $washer->wash($html); |
T |
651 |
$REMOTE_OBJECTS = $washer->extlinks; |
4e17e6
|
652 |
|
45f56c
|
653 |
return $body; |
T |
654 |
} |
4e17e6
|
655 |
// text/enriched |
45f56c
|
656 |
else if ($part->ctype_secondary=='enriched') { |
cfe4a6
|
657 |
$part->ctype_secondary = 'html'; |
9103d1
|
658 |
return Q(enriched_to_html($part->body), 'show'); |
45f56c
|
659 |
} |
4e17e6
|
660 |
else |
45f56c
|
661 |
$body = $part->body; |
4e17e6
|
662 |
|
T |
663 |
|
45f56c
|
664 |
/**** assert plaintext ****/ |
T |
665 |
|
|
666 |
// make links and email-addresses clickable |
|
667 |
$convert_patterns = $convert_replaces = $replace_strings = array(); |
|
668 |
|
|
669 |
$url_chars = 'a-z0-9_\-\+\*\$\/&%=@#:;'; |
|
670 |
$url_chars_within = '\?\.~,!'; |
|
671 |
|
|
672 |
$convert_patterns[] = "/([\w]+):\/\/([a-z0-9\-\.]+[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/ie"; |
|
673 |
$convert_replaces[] = "rcmail_str_replacement('<a href=\"\\1://\\2\" target=\"_blank\">\\1://\\2</a>', \$replace_strings)"; |
|
674 |
|
|
675 |
$convert_patterns[] = "/([^\/:]|\s)(www\.)([a-z0-9\-]{2,}[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/ie"; |
|
676 |
$convert_replaces[] = "rcmail_str_replacement('\\1<a href=\"http://\\2\\3\" target=\"_blank\">\\2\\3</a>', \$replace_strings)"; |
|
677 |
|
|
678 |
$convert_patterns[] = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/ie'; |
|
679 |
$convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)"; |
|
680 |
|
|
681 |
// search for patterns like links and e-mail addresses |
|
682 |
$body = preg_replace($convert_patterns, $convert_replaces, $body); |
4e17e6
|
683 |
|
45f56c
|
684 |
// split body into single lines |
T |
685 |
$a_lines = preg_split('/\r?\n/', $body); |
|
686 |
$quote_level = 0; |
4e17e6
|
687 |
|
45f56c
|
688 |
// colorize quoted parts |
T |
689 |
for ($n=0; $n < sizeof($a_lines); $n++) { |
|
690 |
$line = $a_lines[$n]; |
|
691 |
$quotation = ''; |
|
692 |
$q = 0; |
4e17e6
|
693 |
|
45f56c
|
694 |
if (preg_match('/^(>+\s*)+/', $line, $regs)) { |
T |
695 |
$q = strlen(preg_replace('/\s/', '', $regs[0])); |
|
696 |
$line = substr($line, strlen($regs[0])); |
|
697 |
|
|
698 |
if ($q > $quote_level) |
|
699 |
$quotation = str_repeat('<blockquote>', $q - $quote_level); |
|
700 |
else if ($q < $quote_level) |
|
701 |
$quotation = str_repeat("</blockquote>", $quote_level - $q); |
4e17e6
|
702 |
} |
45f56c
|
703 |
else if ($quote_level > 0) |
T |
704 |
$quotation = str_repeat("</blockquote>", $quote_level); |
|
705 |
|
|
706 |
$quote_level = $q; |
|
707 |
$a_lines[$n] = $quotation . Q($line, 'replace', false); // htmlquote plaintext |
|
708 |
} |
|
709 |
|
|
710 |
// insert the links for urls and mailtos |
|
711 |
$body = preg_replace("/##string_replacement\{([0-9]+)\}##/e", "\$replace_strings[\\1]", join("\n", $a_lines)); |
|
712 |
|
|
713 |
return "<div class=\"pre\">".$body."\n</div>"; |
21e724
|
714 |
} |
4e17e6
|
715 |
|
45f56c
|
716 |
/** |
T |
717 |
* add a string to the replacement array and return a replacement string |
|
718 |
*/ |
4e17e6
|
719 |
function rcmail_str_replacement($str, &$rep) |
21e724
|
720 |
{ |
4e17e6
|
721 |
static $count = 0; |
T |
722 |
$rep[$count] = stripslashes($str); |
|
723 |
return "##string_replacement{".($count++)."}##"; |
21e724
|
724 |
} |
4e17e6
|
725 |
|
21e724
|
726 |
|
T |
727 |
/** |
|
728 |
* Callback function for washtml cleaning class |
|
729 |
*/ |
|
730 |
function rcmail_washtml_callback($tagname, $attrib, $content) |
|
731 |
{ |
|
732 |
switch ($tagname) { |
|
733 |
case 'form': |
|
734 |
$out = html::div('form', $content); |
|
735 |
break; |
|
736 |
|
1c499a
|
737 |
case 'style': |
T |
738 |
// decode all escaped entities and reduce to ascii strings |
36c236
|
739 |
$stripped = preg_replace('/[^a-zA-Z\(:]/', '', rcmail_xss_entitiy_decode($content)); |
1c499a
|
740 |
|
36c236
|
741 |
// now check for evil strings like expression, behavior or url() |
T |
742 |
if (!preg_match('/expression|behavior|url\(|import/', $stripped)) { |
1c499a
|
743 |
$out = html::tag('style', array('type' => 'text/css'), $content); |
T |
744 |
break; |
|
745 |
} |
|
746 |
|
21e724
|
747 |
default: |
T |
748 |
$out = ''; |
|
749 |
} |
|
750 |
|
|
751 |
return $out; |
|
752 |
} |
4e17e6
|
753 |
|
T |
754 |
|
45f56c
|
755 |
/** |
T |
756 |
* return table with message headers |
|
757 |
*/ |
4e17e6
|
758 |
function rcmail_message_headers($attrib, $headers=NULL) |
T |
759 |
{ |
5b1de5
|
760 |
global $IMAP, $OUTPUT, $MESSAGE, $PRINT_MODE, $CONFIG; |
4e17e6
|
761 |
static $sa_attrib; |
T |
762 |
|
|
763 |
// keep header table attrib |
|
764 |
if (is_array($attrib) && !$sa_attrib) |
|
765 |
$sa_attrib = $attrib; |
|
766 |
else if (!is_array($attrib) && is_array($sa_attrib)) |
|
767 |
$attrib = $sa_attrib; |
|
768 |
|
|
769 |
|
|
770 |
if (!isset($MESSAGE)) |
|
771 |
return FALSE; |
|
772 |
|
|
773 |
// get associative array of headers object |
|
774 |
if (!$headers) |
8fa58e
|
775 |
$headers = is_object($MESSAGE->headers) ? get_object_vars($MESSAGE->headers) : $MESSAGE->headers; |
cfe4a6
|
776 |
|
T |
777 |
// add empty subject if none exsists |
|
778 |
if (empty($headers['subject'])) |
|
779 |
$headers['subject'] = rcube_label('nosubject'); |
5b1de5
|
780 |
|
4e17e6
|
781 |
$header_count = 0; |
T |
782 |
|
|
783 |
// allow the following attributes to be added to the <table> tag |
|
784 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); |
|
785 |
$out = '<table' . $attrib_str . ">\n"; |
|
786 |
|
|
787 |
// show these headers |
700320
|
788 |
$standard_headers = array('subject', 'from', 'organization', 'to', 'cc', 'bcc', 'replyto', 'date'); |
e5686f
|
789 |
|
4e17e6
|
790 |
foreach ($standard_headers as $hkey) |
T |
791 |
{ |
|
792 |
if (!$headers[$hkey]) |
|
793 |
continue; |
|
794 |
|
700320
|
795 |
if ($hkey == 'date') |
5b1de5
|
796 |
{ |
A |
797 |
if ($PRINT_MODE) |
|
798 |
$header_value = format_date($headers[$hkey], $CONFIG['date_long'] ? $CONFIG['date_long'] : 'x'); |
|
799 |
else |
|
800 |
$header_value = format_date($headers[$hkey]); |
|
801 |
} |
700320
|
802 |
else if ($hkey == 'replyto') |
A |
803 |
{ |
|
804 |
if ($headers['replyto'] != $headers['from']) |
|
805 |
$header_value = Q(rcmail_address_string($headers['replyto'], null, true, $attrib['addicon']), 'show'); |
|
806 |
else |
|
807 |
continue; |
|
808 |
} |
|
809 |
else if (in_array($hkey, array('from', 'to', 'cc', 'bcc'))) |
8e44f4
|
810 |
$header_value = Q(rcmail_address_string($headers[$hkey], null, true, $attrib['addicon']), 'show'); |
4e17e6
|
811 |
else |
583850
|
812 |
$header_value = Q($IMAP->decode_header($headers[$hkey])); |
4e17e6
|
813 |
|
T |
814 |
$out .= "\n<tr>\n"; |
2bca6e
|
815 |
$out .= '<td class="header-title">'.Q(rcube_label($hkey)).": </td>\n"; |
4e17e6
|
816 |
$out .= '<td class="'.$hkey.'" width="90%">'.$header_value."</td>\n</tr>"; |
T |
817 |
$header_count++; |
|
818 |
} |
|
819 |
|
e5686f
|
820 |
// all headers division |
A |
821 |
$out .= "\n".'<tr><td colspan="2" class="more-headers show-headers" |
|
822 |
onclick="return '.JS_OBJECT_NAME.'.command(\'load-headers\', \'\', this)"></td></tr>'; |
|
823 |
$out .= "\n".'<tr id="all-headers"><td colspan="2" class="all"><div id="headers-source"></div></td></tr>'; |
|
824 |
|
|
825 |
$OUTPUT->add_gui_object('all_headers_row', 'all-headers'); |
|
826 |
$OUTPUT->add_gui_object('all_headers_box', 'headers-source'); |
|
827 |
|
4e17e6
|
828 |
$out .= "\n</table>\n\n"; |
T |
829 |
|
|
830 |
return $header_count ? $out : ''; |
|
831 |
} |
|
832 |
|
|
833 |
|
45f56c
|
834 |
/** |
21605c
|
835 |
* Handler for the 'messagebody' GUI object |
45f56c
|
836 |
* |
21605c
|
837 |
* @param array Named parameters |
T |
838 |
* @return string HTML content showing the message body |
45f56c
|
839 |
*/ |
4e17e6
|
840 |
function rcmail_message_body($attrib) |
T |
841 |
{ |
8fa58e
|
842 |
global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $REMOTE_OBJECTS; |
5f8686
|
843 |
|
8fa58e
|
844 |
if (!is_array($MESSAGE->parts) && empty($MESSAGE->body)) |
4e17e6
|
845 |
return ''; |
T |
846 |
|
|
847 |
if (!$attrib['id']) |
|
848 |
$attrib['id'] = 'rcmailMsgBody'; |
|
849 |
|
8fa58e
|
850 |
$safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']); |
21605c
|
851 |
$out = ''; |
4e17e6
|
852 |
|
T |
853 |
$header_attrib = array(); |
|
854 |
foreach ($attrib as $attr => $value) |
|
855 |
if (preg_match('/^headertable([a-z]+)$/i', $attr, $regs)) |
|
856 |
$header_attrib[$regs[1]] = $value; |
|
857 |
|
8fa58e
|
858 |
if (!empty($MESSAGE->parts)) |
4e17e6
|
859 |
{ |
8fa58e
|
860 |
foreach ($MESSAGE->parts as $i => $part) |
4e17e6
|
861 |
{ |
8fa58e
|
862 |
if ($part->type == 'headers') |
8d4bcd
|
863 |
$out .= rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : NULL, $part->headers); |
8fa58e
|
864 |
else if ($part->type == 'content') |
4e17e6
|
865 |
{ |
8d4bcd
|
866 |
if (empty($part->ctype_parameters) || empty($part->ctype_parameters['charset'])) |
8fa58e
|
867 |
$part->ctype_parameters['charset'] = $MESSAGE->headers->charset; |
a0109c
|
868 |
|
8d4bcd
|
869 |
// fetch part if not available |
T |
870 |
if (!isset($part->body)) |
8fa58e
|
871 |
$part->body = $MESSAGE->get_part_content($part->mime_id); |
a0109c
|
872 |
|
21e724
|
873 |
$body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$CONFIG['prefer_html'])); |
5f8686
|
874 |
|
cfe4a6
|
875 |
if ($part->ctype_secondary == 'html') |
21605c
|
876 |
$out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'])); |
a2f2c5
|
877 |
else |
21605c
|
878 |
$out .= html::div('message-part', $body); |
4e17e6
|
879 |
} |
T |
880 |
} |
|
881 |
} |
|
882 |
else |
cfe4a6
|
883 |
$out .= html::div('message-part', html::div('pre', Q($MESSAGE->body))); |
4e17e6
|
884 |
|
T |
885 |
|
8fa58e
|
886 |
$ctype_primary = strtolower($MESSAGE->structure->ctype_primary); |
T |
887 |
$ctype_secondary = strtolower($MESSAGE->structure->ctype_secondary); |
166b61
|
888 |
|
4e17e6
|
889 |
// list images after mail body |
be5f03
|
890 |
if ($CONFIG['inline_images'] |
2da368
|
891 |
&& $ctype_primary == 'multipart' |
T |
892 |
&& !empty($MESSAGE->attachments) |
|
893 |
&& !strstr($message_body, '<html')) |
166b61
|
894 |
{ |
8fa58e
|
895 |
foreach ($MESSAGE->attachments as $attach_prop) { |
T |
896 |
if (strpos($attach_prop->mimetype, 'image/') === 0) { |
|
897 |
$out .= html::tag('hr') . html::p(array('align' => "center"), |
|
898 |
html::img(array( |
|
899 |
'src' => $MESSAGE->get_part_url($attach_prop->mime_id), |
|
900 |
'title' => $attach_prop->filename, |
|
901 |
'alt' => $attach_prop->filename, |
|
902 |
))); |
|
903 |
} |
4e17e6
|
904 |
} |
8fa58e
|
905 |
} |
4e17e6
|
906 |
|
T |
907 |
// tell client that there are blocked remote objects |
|
908 |
if ($REMOTE_OBJECTS && !$safe_mode) |
f11541
|
909 |
$OUTPUT->set_env('blockedobjects', true); |
4e17e6
|
910 |
|
21605c
|
911 |
return html::div($attrib, $out); |
4e17e6
|
912 |
} |
T |
913 |
|
|
914 |
|
|
915 |
|
45f56c
|
916 |
/** |
T |
917 |
* modify a HTML message that it can be displayed inside a HTML page |
|
918 |
*/ |
|
919 |
function rcmail_html4inline($body, $container_id) |
4e17e6
|
920 |
{ |
97bd2c
|
921 |
$base_url = ""; |
4e17e6
|
922 |
$last_style_pos = 0; |
T |
923 |
$body_lc = strtolower($body); |
97bd2c
|
924 |
|
T |
925 |
// check for <base href> |
|
926 |
if (preg_match(($base_reg = '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i'), $body, $base_regs)) |
|
927 |
$base_url = $base_regs[2]; |
4e17e6
|
928 |
|
T |
929 |
// find STYLE tags |
|
930 |
while (($pos = strpos($body_lc, '<style', $last_style_pos)) && ($pos2 = strpos($body_lc, '</style>', $pos))) |
|
931 |
{ |
ea206d
|
932 |
$pos = strpos($body_lc, '>', $pos)+1; |
T |
933 |
|
4e17e6
|
934 |
// replace all css definitions with #container [def] |
97bd2c
|
935 |
$styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id, $base_url); |
ea206d
|
936 |
|
3b12ae
|
937 |
$body = substr($body, 0, $pos) . $styles . substr($body, $pos2); |
S |
938 |
$body_lc = strtolower($body); |
4e17e6
|
939 |
$last_style_pos = $pos2; |
5e98e1
|
940 |
} |
4e17e6
|
941 |
|
T |
942 |
// resolve <base href> |
97bd2c
|
943 |
if ($base_url) |
4e17e6
|
944 |
{ |
T |
945 |
$body = preg_replace('/(src|background|href)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Uie', "'\\1=\"'.make_absolute_url('\\3', '$base_url').'\"'", $body); |
|
946 |
$body = preg_replace('/(url\s*\()(["\']?)([\.\/]+[^"\'\)\s]+)(\2)\)/Uie', "'\\1\''.make_absolute_url('\\3', '$base_url').'\')'", $body); |
|
947 |
$body = preg_replace($base_reg, '', $body); |
|
948 |
} |
fe79b1
|
949 |
|
T |
950 |
// modify HTML links to open a new window if clicked |
97bd2c
|
951 |
$body = preg_replace('/<(a|link)\s+([^>]+)>/Uie', "rcmail_alter_html_link('\\1','\\2', '$container_id');", $body); |
4e17e6
|
952 |
|
T |
953 |
// add comments arround html and other tags |
06895c
|
954 |
$out = preg_replace(array( |
d7a411
|
955 |
'/(<!DOCTYPE[^>]*>)/i', |
A |
956 |
'/(<\?xml[^>]*>)/i', |
06895c
|
957 |
'/(<\/?html[^>]*>)/i', |
T |
958 |
'/(<\/?head[^>]*>)/i', |
|
959 |
'/(<title[^>]*>.*<\/title>)/Ui', |
|
960 |
'/(<\/?meta[^>]*>)/i'), |
|
961 |
'<!--\\1-->', |
|
962 |
$body); |
a0109c
|
963 |
|
97bd2c
|
964 |
$out = preg_replace( |
45f56c
|
965 |
array('/<body([^>]*)>/i', '/<\/body>/i'), |
T |
966 |
array('<div class="rcmBody"\\1>', '</div>'), |
97bd2c
|
967 |
$out); |
a0109c
|
968 |
|
86958f
|
969 |
// quote <? of php and xml files that are specified as text/html |
T |
970 |
$out = preg_replace(array('/<\?/', '/\?>/'), array('<?', '?>'), $out); |
|
971 |
|
4e17e6
|
972 |
return $out; |
T |
973 |
} |
|
974 |
|
|
975 |
|
45f56c
|
976 |
/** |
T |
977 |
* parse link attributes and set correct target |
|
978 |
*/ |
97bd2c
|
979 |
function rcmail_alter_html_link($tag, $attrs, $container_id) |
fe79b1
|
980 |
{ |
97bd2c
|
981 |
$attrib = parse_attrib_string($attrs); |
84f5b7
|
982 |
|
97bd2c
|
983 |
if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href'])) |
T |
984 |
$attrib['href'] = "./bin/modcss.php?u=" . urlencode($attrib['href']) . "&c=" . urlencode($container_id); |
fe79b1
|
985 |
|
97bd2c
|
986 |
else if (stristr((string)$attrib['href'], 'mailto:')) |
T |
987 |
$attrib['onclick'] = sprintf( |
|
988 |
"return %s.command('compose','%s',this)", |
|
989 |
JS_OBJECT_NAME, |
|
990 |
JQ(substr($attrib['href'], 7))); |
84f5b7
|
991 |
|
fe79b1
|
992 |
else if (!empty($attrib['href']) && $attrib['href']{0}!='#') |
T |
993 |
$attrib['target'] = '_blank'; |
|
994 |
|
97bd2c
|
995 |
return "<$tag" . create_attrib_string($attrib, array('href','name','target','onclick','id','class','style','title','rel','type','media')) . ' />'; |
4e17e6
|
996 |
} |
T |
997 |
|
|
998 |
|
45f56c
|
999 |
/** |
T |
1000 |
* decode address string and re-format it as HTML links |
|
1001 |
*/ |
8e44f4
|
1002 |
function rcmail_address_string($input, $max=null, $linked=false, $addicon=null) |
T |
1003 |
{ |
f11541
|
1004 |
global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN; |
1088d6
|
1005 |
|
4e17e6
|
1006 |
$a_parts = $IMAP->decode_address_list($input); |
T |
1007 |
|
|
1008 |
if (!sizeof($a_parts)) |
|
1009 |
return $input; |
|
1010 |
|
|
1011 |
$c = count($a_parts); |
|
1012 |
$j = 0; |
|
1013 |
$out = ''; |
|
1014 |
|
8e44f4
|
1015 |
foreach ($a_parts as $part) { |
4e17e6
|
1016 |
$j++; |
8e44f4
|
1017 |
if ($PRINT_MODE) { |
90cd45
|
1018 |
$out .= sprintf('%s <%s>', Q($part['name']), $part['mailto']); |
8e44f4
|
1019 |
} |
T |
1020 |
else if (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { |
|
1021 |
if ($linked) { |
|
1022 |
$out .= html::a(array( |
|
1023 |
'href' => 'mailto:'.$part['mailto'], |
|
1024 |
'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($part['mailto'])), |
|
1025 |
'title' => $part['mailto'], |
|
1026 |
'class' => "rcmContactAddress", |
|
1027 |
), |
|
1028 |
Q($part['name'])); |
4e17e6
|
1029 |
} |
8e44f4
|
1030 |
else { |
T |
1031 |
$out .= html::span(array('title' => $part['mailto'], 'class' => "rcmContactAddress"), Q($part['name'])); |
|
1032 |
} |
|
1033 |
|
|
1034 |
if ($addicon) { |
|
1035 |
$out .= ' ' . html::a(array( |
|
1036 |
'href' => "#add", |
|
1037 |
'onclick' => sprintf("return %s.command('add-contact','%s',this)", JS_OBJECT_NAME, urlencode($part['string'])), |
|
1038 |
'title' => rcube_label('addtoaddressbook'), |
|
1039 |
), |
|
1040 |
html::img(array( |
|
1041 |
'src' => $CONFIG['skin_path'] . $addicon, |
|
1042 |
'alt' => "Add contact", |
|
1043 |
'border' => 0, |
|
1044 |
))); |
|
1045 |
} |
|
1046 |
} |
|
1047 |
else { |
4e17e6
|
1048 |
if ($part['name']) |
2bca6e
|
1049 |
$out .= Q($part['name']); |
4e17e6
|
1050 |
if ($part['mailto']) |
28bfe4
|
1051 |
$out .= (strlen($out) ? ' ' : '') . sprintf('<%s>', Q($part['mailto'])); |
8e44f4
|
1052 |
} |
4e17e6
|
1053 |
|
T |
1054 |
if ($c>$j) |
|
1055 |
$out .= ','.($max ? ' ' : ' '); |
|
1056 |
|
8e44f4
|
1057 |
if ($max && $j==$max && $c>$j) { |
4e17e6
|
1058 |
$out .= '...'; |
T |
1059 |
break; |
|
1060 |
} |
8e44f4
|
1061 |
} |
4e17e6
|
1062 |
|
T |
1063 |
return $out; |
8e44f4
|
1064 |
} |
4e17e6
|
1065 |
|
T |
1066 |
|
ccd63c
|
1067 |
/** |
T |
1068 |
* Wrap text to a given number of characters per line |
|
1069 |
* but respect the mail quotation of replies messages (>) |
|
1070 |
* |
|
1071 |
* @param string Text to wrap |
|
1072 |
* @param int The line width |
|
1073 |
* @return string The wrapped text |
|
1074 |
*/ |
|
1075 |
function rcmail_wrap_quoted($text, $max = 76) |
|
1076 |
{ |
|
1077 |
// Rebuild the message body with a maximum of $max chars, while keeping quoted message. |
|
1078 |
$lines = preg_split('/\r?\n/', trim($text)); |
|
1079 |
$out = ''; |
|
1080 |
|
|
1081 |
foreach ($lines as $line) { |
|
1082 |
if (strlen($line) > $max) { |
|
1083 |
if (preg_match('/^([>\s]+)/', $line, $regs)) { |
|
1084 |
$length = strlen($regs[0]); |
|
1085 |
$prefix = substr($line, 0, $length); |
|
1086 |
|
|
1087 |
// Remove '> ' from the line, then wordwrap() the line |
|
1088 |
$line = wordwrap(substr($line, $length), $max - $length); |
|
1089 |
|
|
1090 |
// Rebuild the line with '> ' at the beginning of each 'subline' |
|
1091 |
$newline = ''; |
|
1092 |
foreach (explode("\n", $line) as $l) { |
|
1093 |
$newline .= $prefix . $l . "\n"; |
|
1094 |
} |
|
1095 |
|
|
1096 |
// Remove the righest newline char |
|
1097 |
$line = rtrim($newline); |
|
1098 |
} |
|
1099 |
else { |
|
1100 |
$line = wordwrap($line, $max); |
|
1101 |
} |
|
1102 |
} |
|
1103 |
|
|
1104 |
// Append the line |
|
1105 |
$out .= $line . "\n"; |
|
1106 |
} |
|
1107 |
|
|
1108 |
return $out; |
|
1109 |
} |
|
1110 |
|
|
1111 |
|
4e17e6
|
1112 |
function rcmail_message_part_controls() |
T |
1113 |
{ |
8fa58e
|
1114 |
global $MESSAGE; |
4e17e6
|
1115 |
|
d5342a
|
1116 |
$part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC)); |
8fa58e
|
1117 |
if (!is_object($MESSAGE) || !is_array($MESSAGE->parts) || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part]) |
4e17e6
|
1118 |
return ''; |
T |
1119 |
|
8fa58e
|
1120 |
$part = $MESSAGE->mime_parts[$part]; |
T |
1121 |
$table = new html_table(array('cols' => 3)); |
4e17e6
|
1122 |
|
8fa58e
|
1123 |
if (!empty($part->filename)) { |
T |
1124 |
$table->add('title', Q(rcube_label('filename'))); |
|
1125 |
$table->add(null, Q($part->filename)); |
8dc048
|
1126 |
$table->add(null, '[' . html::a('?'.str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']), Q(rcube_label('download'))) . ']'); |
8fa58e
|
1127 |
} |
4e17e6
|
1128 |
|
8fa58e
|
1129 |
if (!empty($part->size)) { |
T |
1130 |
$table->add('title', Q(rcube_label('filesize'))); |
|
1131 |
$table->add(null, Q(show_bytes($part->size))); |
|
1132 |
} |
4e17e6
|
1133 |
|
8fa58e
|
1134 |
return $table->show($attrib); |
4e17e6
|
1135 |
} |
T |
1136 |
|
|
1137 |
|
|
1138 |
|
|
1139 |
function rcmail_message_part_frame($attrib) |
|
1140 |
{ |
|
1141 |
global $MESSAGE; |
|
1142 |
|
8fa58e
|
1143 |
$part = $MESSAGE->mime_parts[asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))]; |
4e17e6
|
1144 |
$ctype_primary = strtolower($part->ctype_primary); |
T |
1145 |
|
719a25
|
1146 |
$attrib['src'] = Q('./?'.str_replace('_frame=', ($ctype_primary=='text' ? '_show=' : '_preload='), $_SERVER['QUERY_STRING'])); |
4e17e6
|
1147 |
|
T |
1148 |
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height')); |
90022e
|
1149 |
$out = '<iframe '. $attrib_str . "></iframe>"; |
4e17e6
|
1150 |
|
T |
1151 |
return $out; |
|
1152 |
} |
|
1153 |
|
|
1154 |
|
45f56c
|
1155 |
/** |
T |
1156 |
* clear message composing settings |
|
1157 |
*/ |
4e17e6
|
1158 |
function rcmail_compose_cleanup() |
T |
1159 |
{ |
|
1160 |
if (!isset($_SESSION['compose'])) |
|
1161 |
return; |
70d4b9
|
1162 |
|
4e17e6
|
1163 |
// remove attachment files from temp dir |
T |
1164 |
if (is_array($_SESSION['compose']['attachments'])) |
|
1165 |
foreach ($_SESSION['compose']['attachments'] as $attachment) |
15a9d1
|
1166 |
@unlink($attachment['path']); |
4e17e6
|
1167 |
|
T |
1168 |
unset($_SESSION['compose']); |
|
1169 |
} |
fba1f5
|
1170 |
|
T |
1171 |
|
|
1172 |
/** |
|
1173 |
* Send the given message compose object using the configured method |
|
1174 |
*/ |
|
1175 |
function rcmail_deliver_message(&$message, $from, $mailto) |
|
1176 |
{ |
|
1177 |
global $CONFIG; |
|
1178 |
|
|
1179 |
$msg_body = $message->get(); |
8fa58e
|
1180 |
$headers = $message->headers(); |
79aeb3
|
1181 |
|
fba1f5
|
1182 |
// send thru SMTP server using custom SMTP library |
T |
1183 |
if ($CONFIG['smtp_server']) |
|
1184 |
{ |
|
1185 |
// generate list of recipients |
|
1186 |
$a_recipients = array($mailto); |
|
1187 |
|
|
1188 |
if (strlen($headers['Cc'])) |
|
1189 |
$a_recipients[] = $headers['Cc']; |
|
1190 |
if (strlen($headers['Bcc'])) |
|
1191 |
$a_recipients[] = $headers['Bcc']; |
|
1192 |
|
|
1193 |
// clean Bcc from header for recipients |
|
1194 |
$send_headers = $headers; |
|
1195 |
unset($send_headers['Bcc']); |
7ec922
|
1196 |
// here too, it because txtHeaders() below use $message->_headers not only $send_headers |
A |
1197 |
unset($message->_headers['Bcc']); |
fba1f5
|
1198 |
|
T |
1199 |
// send message |
|
1200 |
$smtp_response = array(); |
7ec922
|
1201 |
$sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers, true)), $msg_body, $smtp_response); |
fba1f5
|
1202 |
|
T |
1203 |
// log error |
|
1204 |
if (!$sent) |
|
1205 |
raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__, |
|
1206 |
'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE); |
|
1207 |
} |
|
1208 |
|
|
1209 |
// send mail using PHP's mail() function |
|
1210 |
else |
|
1211 |
{ |
|
1212 |
// unset some headers because they will be added by the mail() function |
|
1213 |
$headers_enc = $message->headers($headers); |
|
1214 |
$headers_php = $message->_headers; |
|
1215 |
unset($headers_php['To'], $headers_php['Subject']); |
|
1216 |
|
|
1217 |
// reset stored headers and overwrite |
|
1218 |
$message->_headers = array(); |
|
1219 |
$header_str = $message->txtHeaders($headers_php); |
|
1220 |
|
|
1221 |
if (ini_get('safe_mode')) |
|
1222 |
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); |
|
1223 |
else |
|
1224 |
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); |
|
1225 |
} |
|
1226 |
|
79aeb3
|
1227 |
if ($sent) |
A |
1228 |
{ |
|
1229 |
// remove MDN headers after sending |
ae8f19
|
1230 |
unset($headers['Return-Receipt-To'], $headers['Disposition-Notification-To']); |
79aeb3
|
1231 |
|
A |
1232 |
if ($CONFIG['smtp_log']) |
|
1233 |
write_log('sendmail', sprintf("[%s] User: %d on %s; Message for %s; %s", |
|
1234 |
date("d-M-Y H:i:s O", mktime()), |
|
1235 |
$_SESSION['user_id'], |
|
1236 |
$_SERVER['REMOTE_ADDR'], |
|
1237 |
$mailto, |
|
1238 |
!empty($smtp_response) ? join('; ', $smtp_response) : '')); |
|
1239 |
} |
fba1f5
|
1240 |
|
T |
1241 |
$message->_headers = array(); |
|
1242 |
$message->headers($headers); |
|
1243 |
|
|
1244 |
return $sent; |
|
1245 |
} |
f11541
|
1246 |
|
T |
1247 |
|
0ea884
|
1248 |
function rcmail_send_mdn($uid) |
T |
1249 |
{ |
83a763
|
1250 |
global $RCMAIL, $IMAP; |
8fa58e
|
1251 |
|
T |
1252 |
$message = new rcube_message($uid); |
0ea884
|
1253 |
|
5b3dd4
|
1254 |
if ($message->headers->mdn_to && !$message->headers->mdn_sent && $IMAP->check_permflag('MDNSENT')) |
0ea884
|
1255 |
{ |
83a763
|
1256 |
$identity = $RCMAIL->user->get_identity(); |
0ea884
|
1257 |
$sender = format_email_recipient($identity['email'], $identity['name']); |
8fa58e
|
1258 |
$recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to)); |
0ea884
|
1259 |
$mailto = $recipient['mailto']; |
T |
1260 |
|
83a763
|
1261 |
$compose = new rcube_mail_mime($RCMAIL->config->header_delimiter()); |
0ea884
|
1262 |
$compose->setParam(array( |
T |
1263 |
'text_encoding' => 'quoted-printable', |
|
1264 |
'html_encoding' => 'quoted-printable', |
|
1265 |
'head_encoding' => 'quoted-printable', |
|
1266 |
'head_charset' => RCMAIL_CHARSET, |
|
1267 |
'html_charset' => RCMAIL_CHARSET, |
|
1268 |
'text_charset' => RCMAIL_CHARSET, |
|
1269 |
)); |
|
1270 |
|
|
1271 |
// compose headers array |
|
1272 |
$headers = array( |
|
1273 |
'Date' => date('r'), |
|
1274 |
'From' => $sender, |
8fa58e
|
1275 |
'To' => $message->headers->mdn_to, |
T |
1276 |
'Subject' => rcube_label('receiptread') . ': ' . $message->subject, |
83a763
|
1277 |
'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])), |
0ea884
|
1278 |
'X-Sender' => $identity['email'], |
T |
1279 |
'Content-Type' => 'multipart/report; report-type=disposition-notification', |
|
1280 |
); |
|
1281 |
|
83a763
|
1282 |
if ($agent = $RCMAIL->config->get('useragent')) |
T |
1283 |
$headers['User-Agent'] = $agent; |
0ea884
|
1284 |
|
T |
1285 |
$body = rcube_label("yourmessage") . "\r\n\r\n" . |
8fa58e
|
1286 |
"\t" . rcube_label("to") . ': ' . rcube_imap::decode_mime_string($message->headers->to, $message->headers->charset) . "\r\n" . |
T |
1287 |
"\t" . rcube_label("subject") . ': ' . $message->subject . "\r\n" . |
83a763
|
1288 |
"\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $RCMAIL->config->get('date_long')) . "\r\n" . |
0ea884
|
1289 |
"\r\n" . rcube_label("receiptnote") . "\r\n"; |
T |
1290 |
|
83a763
|
1291 |
$ua = $RCMAIL->config->get('useragent', "RoundCube Webmail (Version ".RCMAIL_VERSION.")"); |
0ea884
|
1292 |
$report = "Reporting-UA: $ua\r\n"; |
T |
1293 |
|
8fa58e
|
1294 |
if ($message->headers->to) |
T |
1295 |
$report .= "Original-Recipient: {$message->headers->to}\r\n"; |
0ea884
|
1296 |
|
T |
1297 |
$report .= "Final-Recipient: rfc822; {$identity['email']}\r\n" . |
8fa58e
|
1298 |
"Original-Message-ID: {$message->headers->messageID}\r\n" . |
0ea884
|
1299 |
"Disposition: manual-action/MDN-sent-manually; displayed\r\n"; |
T |
1300 |
|
8fa58e
|
1301 |
$compose->headers($headers); |
T |
1302 |
$compose->setTXTBody(wordwrap($body, 75, "\r\n")); |
0ea884
|
1303 |
$compose->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline'); |
T |
1304 |
|
|
1305 |
$sent = rcmail_deliver_message($compose, $identity['email'], $mailto); |
|
1306 |
|
|
1307 |
if ($sent) |
|
1308 |
{ |
8fa58e
|
1309 |
$IMAP->set_flag($message->uid, 'MDNSENT'); |
0ea884
|
1310 |
return true; |
T |
1311 |
} |
|
1312 |
} |
|
1313 |
|
|
1314 |
return false; |
|
1315 |
} |
|
1316 |
|
|
1317 |
|
f11541
|
1318 |
// register UI objects |
T |
1319 |
$OUTPUT->add_handlers(array( |
|
1320 |
'mailboxlist' => 'rcmail_mailbox_list', |
|
1321 |
'messages' => 'rcmail_message_list', |
|
1322 |
'messagecountdisplay' => 'rcmail_messagecount_display', |
|
1323 |
'quotadisplay' => 'rcmail_quota_display', |
ac5d15
|
1324 |
'mailboxname' => 'rcmail_mailbox_name_display', |
f11541
|
1325 |
'messageheaders' => 'rcmail_message_headers', |
T |
1326 |
'messagebody' => 'rcmail_message_body', |
|
1327 |
'messagecontentframe' => 'rcmail_messagecontent_frame', |
|
1328 |
'messagepartframe' => 'rcmail_message_part_frame', |
|
1329 |
'messagepartcontrols' => 'rcmail_message_part_controls', |
47124c
|
1330 |
'searchform' => array($OUTPUT, 'search_form'), |
f11541
|
1331 |
)); |
T |
1332 |
|
93be5b
|
1333 |
?> |