commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/compose.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 |
| Compose a new mail message with all headers and attachments | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
8d4bcd
|
22 |
// define constants for message compose mode |
T |
23 |
define('RCUBE_COMPOSE_REPLY', 0x0106); |
|
24 |
define('RCUBE_COMPOSE_FORWARD', 0x0107); |
|
25 |
define('RCUBE_COMPOSE_DRAFT', 0x0108); |
069704
|
26 |
define('RCUBE_COMPOSE_EDIT', 0x0109); |
8d4bcd
|
27 |
|
f0f98f
|
28 |
$MESSAGE_FORM = NULL; |
8d4bcd
|
29 |
$MESSAGE = NULL; |
f0f98f
|
30 |
|
86df15
|
31 |
// Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or |
T |
32 |
// if a compose-ID is given (i.e. when the compose step is opened in a new window/tab). |
|
33 |
// Since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old |
f0f98f
|
34 |
// compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear |
S |
35 |
|
ace851
|
36 |
$MESSAGE_ID = get_input_value('_id', RCUBE_INPUT_GET); |
A |
37 |
if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != $MESSAGE_ID) |
4315b0
|
38 |
{ |
86df15
|
39 |
rcmail_compose_cleanup(); |
ace851
|
40 |
|
A |
41 |
// Infinite redirect prevention in case of broken session (#1487028) |
|
42 |
if ($MESSAGE_ID) |
|
43 |
raise_error(array('code' => 500, 'type' => 'php', |
|
44 |
'file' => __FILE__, 'line' => __LINE__, |
|
45 |
'message' => "Invalid session"), true, true); |
|
46 |
|
48958e
|
47 |
$_SESSION['compose'] = array( |
b48d9b
|
48 |
'id' => uniqid(mt_rand()), |
759696
|
49 |
'param' => request2param(RCUBE_INPUT_GET), |
7d8e16
|
50 |
'mailbox' => $IMAP->get_mailbox_name(), |
48958e
|
51 |
); |
c719f3
|
52 |
|
5f314d
|
53 |
// process values like "mailto:foo@bar.com?subject=new+message&cc=another" |
759696
|
54 |
if ($_SESSION['compose']['param']['to']) { |
3e8898
|
55 |
// #1486037: remove "mailto:" prefix |
A |
56 |
$_SESSION['compose']['param']['to'] = preg_replace('/^mailto:/i', '', $_SESSION['compose']['param']['to']); |
759696
|
57 |
$mailto = explode('?', $_SESSION['compose']['param']['to']); |
5f314d
|
58 |
if (count($mailto) > 1) { |
759696
|
59 |
$_SESSION['compose']['param']['to'] = $mailto[0]; |
5f314d
|
60 |
parse_str($mailto[1], $query); |
T |
61 |
foreach ($query as $f => $val) |
759696
|
62 |
$_SESSION['compose']['param'][$f] = $val; |
5f314d
|
63 |
} |
T |
64 |
} |
759696
|
65 |
|
814905
|
66 |
// select folder where to save the sent message |
T |
67 |
$_SESSION['compose']['param']['sent_mbox'] = $RCMAIL->config->get('sent_mbox'); |
|
68 |
|
759696
|
69 |
// pipe compose parameters thru plugins |
T |
70 |
$plugin = $RCMAIL->plugins->exec_hook('message_compose', $_SESSION['compose']); |
814905
|
71 |
$_SESSION['compose']['param'] = array_merge($_SESSION['compose']['param'], $plugin['param']); |
ceeab9
|
72 |
|
76791c
|
73 |
// add attachments listed by message_compose hook |
T |
74 |
if (is_array($plugin['attachments'])) { |
|
75 |
foreach ($plugin['attachments'] as $attach) { |
|
76 |
// we have structured data |
|
77 |
if (is_array($attach)) { |
|
78 |
$attachment = $attach; |
|
79 |
} |
|
80 |
// only a file path is given |
|
81 |
else { |
|
82 |
$filename = basename($attach); |
|
83 |
$attachment = array( |
|
84 |
'name' => $filename, |
|
85 |
'mimetype' => rc_mime_content_type($attach, $filename), |
|
86 |
'path' => $attach |
|
87 |
); |
|
88 |
} |
|
89 |
|
|
90 |
// save attachment if valid |
|
91 |
if (($attachment['data'] && $attachment['name']) || ($attachment['path'] && file_exists($attachment['path']))) { |
e6ce00
|
92 |
$attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment); |
76791c
|
93 |
} |
T |
94 |
|
|
95 |
if ($attachment['status'] && !$attachment['abort']) { |
|
96 |
unset($attachment['data'], $attachment['status'], $attachment['abort']); |
|
97 |
$_SESSION['compose']['attachments'][$attachment['id']] = $attachment; |
|
98 |
} |
|
99 |
} |
|
100 |
} |
5f314d
|
101 |
|
90e708
|
102 |
// check if folder for saving sent messages exists and is subscribed (#1486802) |
eeb85f
|
103 |
if ($sent_folder = $_SESSION['compose']['param']['sent_mbox']) { |
A |
104 |
rcmail_check_sent_folder($sent_folder, true); |
90e708
|
105 |
} |
T |
106 |
|
c719f3
|
107 |
// redirect to a unique URL with all parameters stored in session |
T |
108 |
$OUTPUT->redirect(array('_action' => 'compose', '_id' => $_SESSION['compose']['id'])); |
4315b0
|
109 |
} |
76791c
|
110 |
|
4e17e6
|
111 |
|
10a699
|
112 |
// add some labels to client |
3f9712
|
113 |
$OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'cancel', |
V |
114 |
'nobodywarning', 'notsentwarning', 'notuploadedwarning', 'savingmessage', 'sendingmessage', |
c296b8
|
115 |
'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'fileuploaderror', |
A |
116 |
'autocompletechars'); |
10a699
|
117 |
|
272705
|
118 |
// add config parameters to client script |
A |
119 |
if (!empty($CONFIG['drafts_mbox'])) { |
|
120 |
$OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']); |
|
121 |
$OUTPUT->set_env('draft_autosave', $CONFIG['draft_autosave']); |
|
122 |
} |
cf6a83
|
123 |
// set current mailbox in client environment |
A |
124 |
$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name()); |
0207c4
|
125 |
$OUTPUT->set_env('sig_above', $CONFIG['sig_above']); |
50f56d
|
126 |
$OUTPUT->set_env('top_posting', $CONFIG['top_posting']); |
c296b8
|
127 |
$OUTPUT->set_env('autocomplete_min_length', $CONFIG['autocomplete_min_length']); |
10a699
|
128 |
|
8d4bcd
|
129 |
// get reference message and set compose mode |
759696
|
130 |
if ($msg_uid = $_SESSION['compose']['param']['reply_uid']) |
8d4bcd
|
131 |
$compose_mode = RCUBE_COMPOSE_REPLY; |
759696
|
132 |
else if ($msg_uid = $_SESSION['compose']['param']['forward_uid']) |
8d4bcd
|
133 |
$compose_mode = RCUBE_COMPOSE_FORWARD; |
759696
|
134 |
else if ($msg_uid = $_SESSION['compose']['param']['uid']) |
069704
|
135 |
$compose_mode = RCUBE_COMPOSE_EDIT; |
759696
|
136 |
else if ($msg_uid = $_SESSION['compose']['param']['draft_uid']) { |
59ee68
|
137 |
$RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']); |
8d4bcd
|
138 |
$compose_mode = RCUBE_COMPOSE_DRAFT; |
0b21c8
|
139 |
} |
50f56d
|
140 |
|
0207c4
|
141 |
$config_show_sig = $RCMAIL->config->get('show_sig', 1); |
T |
142 |
if ($config_show_sig == 1) |
50f56d
|
143 |
$OUTPUT->set_env('show_sig', true); |
0207c4
|
144 |
else if ($config_show_sig == 2 && (empty($compose_mode) || $compose_mode == RCUBE_COMPOSE_EDIT || $compose_mode == RCUBE_COMPOSE_DRAFT)) |
50f56d
|
145 |
$OUTPUT->set_env('show_sig', true); |
0207c4
|
146 |
else if ($config_show_sig == 3 && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD)) |
50f56d
|
147 |
$OUTPUT->set_env('show_sig', true); |
0207c4
|
148 |
else |
T |
149 |
$OUTPUT->set_env('show_sig', false); |
8d4bcd
|
150 |
|
b62049
|
151 |
// set line length for body wrapping |
6b6f2e
|
152 |
$LINE_LENGTH = $RCMAIL->config->get('line_length', 72); |
b62049
|
153 |
|
8d4bcd
|
154 |
if (!empty($msg_uid)) |
4315b0
|
155 |
{ |
4e17e6
|
156 |
// similar as in program/steps/mail/show.inc |
aae0ad
|
157 |
// re-set 'prefer_html' to have possibility to use html part for compose |
b62049
|
158 |
$CONFIG['prefer_html'] = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT; |
8fa58e
|
159 |
$MESSAGE = new rcube_message($msg_uid); |
17b5fb
|
160 |
|
bc4960
|
161 |
// make sure message is marked as read |
T |
162 |
if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen) |
|
163 |
$IMAP->set_flag($msg_uid, 'SEEN'); |
|
164 |
|
8fa58e
|
165 |
if (!empty($MESSAGE->headers->charset)) |
T |
166 |
$IMAP->set_charset($MESSAGE->headers->charset); |
17b5fb
|
167 |
|
8d4bcd
|
168 |
if ($compose_mode == RCUBE_COMPOSE_REPLY) |
4315b0
|
169 |
{ |
8d4bcd
|
170 |
$_SESSION['compose']['reply_uid'] = $msg_uid; |
8fa58e
|
171 |
$_SESSION['compose']['reply_msgid'] = $MESSAGE->headers->messageID; |
T |
172 |
$_SESSION['compose']['references'] = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID); |
583f1c
|
173 |
|
759696
|
174 |
if (!empty($_SESSION['compose']['param']['all'])) |
e25a35
|
175 |
$MESSAGE->reply_all = $_SESSION['compose']['param']['all']; |
bc404f
|
176 |
|
a96183
|
177 |
$OUTPUT->set_env('compose_mode', 'reply'); |
eeb85f
|
178 |
|
A |
179 |
// Save the sent message in the same folder of the message being replied to |
|
180 |
if ($RCMAIL->config->get('reply_same_folder') && ($sent_folder = $_SESSION['compose']['mailbox']) |
|
181 |
&& rcmail_check_sent_folder($sent_folder, false) |
|
182 |
) { |
|
183 |
$_SESSION['compose']['param']['sent_mbox'] = $sent_folder; |
|
184 |
} |
4e17e6
|
185 |
} |
95fd38
|
186 |
else if ($compose_mode == RCUBE_COMPOSE_DRAFT) |
A |
187 |
{ |
bc404f
|
188 |
if ($MESSAGE->headers->others['x-draft-info']) |
95fd38
|
189 |
{ |
bbc856
|
190 |
// get reply_uid/forward_uid to flag the original message when sending |
bc404f
|
191 |
$info = rcmail_draftinfo_decode($MESSAGE->headers->others['x-draft-info']); |
T |
192 |
|
|
193 |
if ($info['type'] == 'reply') |
|
194 |
$_SESSION['compose']['reply_uid'] = $info['uid']; |
|
195 |
else if ($info['type'] == 'forward') |
|
196 |
$_SESSION['compose']['forward_uid'] = $info['uid']; |
|
197 |
|
|
198 |
$_SESSION['compose']['mailbox'] = $info['folder']; |
eeb85f
|
199 |
|
A |
200 |
// Save the sent message in the same folder of the message being replied to |
|
201 |
if ($RCMAIL->config->get('reply_same_folder') && ($sent_folder = $info['folder']) |
|
202 |
&& rcmail_check_sent_folder($sent_folder, false) |
|
203 |
) { |
|
204 |
$_SESSION['compose']['param']['sent_mbox'] = $sent_folder; |
|
205 |
} |
95fd38
|
206 |
} |
eeb85f
|
207 |
|
bc404f
|
208 |
if ($MESSAGE->headers->in_reply_to) |
T |
209 |
$_SESSION['compose']['reply_msgid'] = '<'.$MESSAGE->headers->in_reply_to.'>'; |
|
210 |
|
95fd38
|
211 |
$_SESSION['compose']['references'] = $MESSAGE->headers->references; |
A |
212 |
} |
4315b0
|
213 |
else if ($compose_mode == RCUBE_COMPOSE_FORWARD) |
S |
214 |
{ |
|
215 |
$_SESSION['compose']['forward_uid'] = $msg_uid; |
a96183
|
216 |
$OUTPUT->set_env('compose_mode', 'forward'); |
4315b0
|
217 |
} |
S |
218 |
} |
4e17e6
|
219 |
|
087c7d
|
220 |
// process $MESSAGE body/attachments, set $MESSAGE_BODY/$HTML_MODE vars and some session data |
A |
221 |
$MESSAGE_BODY = rcmail_prepare_message_body(); |
4e17e6
|
222 |
|
087c7d
|
223 |
|
A |
224 |
/****** compose mode functions ********/ |
4e17e6
|
225 |
|
T |
226 |
function rcmail_compose_headers($attrib) |
4315b0
|
227 |
{ |
8d4bcd
|
228 |
global $IMAP, $MESSAGE, $DB, $compose_mode; |
583f1c
|
229 |
static $sa_recipients = array(); |
4e17e6
|
230 |
|
T |
231 |
list($form_start, $form_end) = get_form_tags($attrib); |
8958d0
|
232 |
|
4e17e6
|
233 |
$out = ''; |
T |
234 |
$part = strtolower($attrib['part']); |
8958d0
|
235 |
|
4e17e6
|
236 |
switch ($part) |
4315b0
|
237 |
{ |
4e17e6
|
238 |
case 'from': |
8958d0
|
239 |
return $form_start . rcmail_compose_header_from($attrib); |
4e17e6
|
240 |
|
T |
241 |
case 'to': |
|
242 |
$fname = '_to'; |
759696
|
243 |
$header = $param = 'to'; |
8958d0
|
244 |
|
f11541
|
245 |
// we have a set of recipients stored is session |
759696
|
246 |
if (($mailto_id = $_SESSION['compose']['param']['mailto']) && $_SESSION['mailto'][$mailto_id]) |
fde466
|
247 |
$fvalue = urldecode($_SESSION['mailto'][$mailto_id]); |
8958d0
|
248 |
|
4e17e6
|
249 |
case 'cc': |
e99991
|
250 |
if (!$fname) { |
4e17e6
|
251 |
$fname = '_cc'; |
759696
|
252 |
$header = $param = 'cc'; |
4315b0
|
253 |
} |
4e17e6
|
254 |
case 'bcc': |
e99991
|
255 |
if (!$fname) { |
4e17e6
|
256 |
$fname = '_bcc'; |
759696
|
257 |
$header = $param = 'bcc'; |
4315b0
|
258 |
} |
8958d0
|
259 |
|
bd4209
|
260 |
$allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'tabindex'); |
47124c
|
261 |
$field_type = 'html_textarea'; |
4e17e6
|
262 |
break; |
T |
263 |
|
|
264 |
case 'replyto': |
|
265 |
case 'reply-to': |
|
266 |
$fname = '_replyto'; |
759696
|
267 |
$param = 'replyto'; |
e25a35
|
268 |
$header = 'reply-to'; |
A |
269 |
|
db1a87
|
270 |
case 'followupto': |
T |
271 |
case 'followup-to': |
e25a35
|
272 |
if (!$fname) { |
db1a87
|
273 |
$fname = '_followupto'; |
T |
274 |
$param = 'followupto'; |
cb105a
|
275 |
$header = 'mail-followup-to'; |
e25a35
|
276 |
} |
A |
277 |
|
317219
|
278 |
$allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); |
47124c
|
279 |
$field_type = 'html_inputfield'; |
5f314d
|
280 |
break; |
4315b0
|
281 |
} |
e99991
|
282 |
|
759696
|
283 |
if ($fname && !empty($_POST[$fname])) { |
01c86f
|
284 |
$fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); |
759696
|
285 |
} |
T |
286 |
else if ($fname && !$fvalue && !empty($_SESSION['compose']['param'][$param])) { |
|
287 |
$fvalue = $_SESSION['compose']['param'][$param]; |
|
288 |
} |
|
289 |
else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { |
4e17e6
|
290 |
// get recipent address(es) out of the message headers |
e25a35
|
291 |
if ($header == 'to') { |
A |
292 |
$mailfollowup = $MESSAGE->headers->others['mail-followup-to']; |
|
293 |
$mailreplyto = $MESSAGE->headers->others['mail-reply-to']; |
|
294 |
|
|
295 |
if ($MESSAGE->reply_all == 'list' && $mailfollowup) |
|
296 |
$fvalue = $mailfollowup; |
|
297 |
else if ($MESSAGE->reply_all == 'list' |
|
298 |
&& preg_match('/<mailto:([^>]+)>/i', $MESSAGE->headers->others['list-post'], $m)) |
|
299 |
$fvalue = $m[1]; |
|
300 |
else if ($mailreplyto) |
|
301 |
$fvalue = $mailreplyto; |
|
302 |
else if (!empty($MESSAGE->headers->replyto)) |
|
303 |
$fvalue = $MESSAGE->headers->replyto; |
|
304 |
else if (!empty($MESSAGE->headers->from)) |
|
305 |
$fvalue = $MESSAGE->headers->from; |
|
306 |
} |
583f1c
|
307 |
// add recipent of original message if reply to all |
e25a35
|
308 |
else if ($header == 'cc' && !empty($MESSAGE->reply_all) && $MESSAGE->reply_all != 'list') { |
8fa58e
|
309 |
if ($v = $MESSAGE->headers->to) |
8d4bcd
|
310 |
$fvalue .= $v; |
8fa58e
|
311 |
if ($v = $MESSAGE->headers->cc) |
8d4bcd
|
312 |
$fvalue .= (!empty($fvalue) ? ', ' : '') . $v; |
4315b0
|
313 |
} |
583f1c
|
314 |
|
4e17e6
|
315 |
// split recipients and put them back together in a unique way |
e99991
|
316 |
if (!empty($fvalue)) { |
583f1c
|
317 |
$to_addresses = $IMAP->decode_address_list($fvalue); |
T |
318 |
$fvalue = ''; |
51f55b
|
319 |
|
e99991
|
320 |
foreach ($to_addresses as $addr_part) { |
A |
321 |
if (empty($addr_part['mailto'])) |
|
322 |
continue; |
|
323 |
|
|
324 |
$mailto = idn_to_utf8($addr_part['mailto']); |
|
325 |
|
|
326 |
if (!in_array($mailto, $sa_recipients) |
8e98f2
|
327 |
&& (!$MESSAGE->compose_from |
e99991
|
328 |
|| !in_array_nocase($mailto, $MESSAGE->compose_from) |
A |
329 |
|| (count($to_addresses)==1 && $header=='to')) // allow reply to yourself |
|
330 |
) { |
|
331 |
if ($addr_part['name'] && $addr_part['mailto'] != $addr_part['name']) |
|
332 |
$string = format_email_recipient($mailto, $addr_part['name']); |
|
333 |
else |
|
334 |
$string = $mailto; |
|
335 |
$fvalue .= (strlen($fvalue) ? ', ':'') . $string; |
583f1c
|
336 |
$sa_recipients[] = $addr_part['mailto']; |
T |
337 |
} |
|
338 |
} |
4e17e6
|
339 |
} |
4315b0
|
340 |
} |
e99991
|
341 |
else if ($header && in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { |
1966c5
|
342 |
// get drafted headers |
8fa58e
|
343 |
if ($header=='to' && !empty($MESSAGE->headers->to)) |
T |
344 |
$fvalue = $MESSAGE->get_header('to'); |
e99991
|
345 |
else if ($header=='cc' && !empty($MESSAGE->headers->cc)) |
8fa58e
|
346 |
$fvalue = $MESSAGE->get_header('cc'); |
e99991
|
347 |
else if ($header=='bcc' && !empty($MESSAGE->headers->bcc)) |
8fa58e
|
348 |
$fvalue = $MESSAGE->get_header('bcc'); |
db1a87
|
349 |
else if ($header=='reply-to' && !empty($MESSAGE->headers->others['mail-reply-to'])) |
T |
350 |
$fvalue = $MESSAGE->get_header('mail-reply-to'); |
e25a35
|
351 |
else if ($header=='reply-to' && !empty($MESSAGE->headers->replyto)) |
A |
352 |
$fvalue = $MESSAGE->get_header('reply-to'); |
|
353 |
else if ($header=='mail-followup-to' && !empty($MESSAGE->headers->others['mail-followup-to'])) |
|
354 |
$fvalue = $MESSAGE->get_header('mail-followup-to'); |
e99991
|
355 |
|
A |
356 |
$addresses = $IMAP->decode_address_list($fvalue); |
|
357 |
$fvalue = ''; |
|
358 |
|
|
359 |
foreach ($addresses as $addr_part) { |
|
360 |
if (empty($addr_part['mailto'])) |
|
361 |
continue; |
|
362 |
|
|
363 |
$mailto = idn_to_utf8($addr_part['mailto']); |
|
364 |
|
|
365 |
if ($addr_part['name'] && $addr_part['mailto'] != $addr_part['name']) |
|
366 |
$string = format_email_recipient($mailto, $addr_part['name']); |
|
367 |
else |
|
368 |
$string = $mailto; |
|
369 |
$fvalue .= (strlen($fvalue) ? ', ':'') . $string; |
|
370 |
} |
4315b0
|
371 |
} |
583f1c
|
372 |
|
4e17e6
|
373 |
if ($fname && $field_type) |
4315b0
|
374 |
{ |
4e17e6
|
375 |
// pass the following attributes to the form class |
491a6e
|
376 |
$field_attrib = array('name' => $fname, 'spellcheck' => 'false'); |
4e17e6
|
377 |
foreach ($attrib as $attr => $value) |
T |
378 |
if (in_array($attr, $allow_attrib)) |
|
379 |
$field_attrib[$attr] = $value; |
|
380 |
|
|
381 |
// create teaxtarea object |
|
382 |
$input = new $field_type($field_attrib); |
47124c
|
383 |
$out = $input->show($fvalue); |
4315b0
|
384 |
} |
4e17e6
|
385 |
|
T |
386 |
if ($form_start) |
|
387 |
$out = $form_start.$out; |
1966c5
|
388 |
|
e99991
|
389 |
return $out; |
4315b0
|
390 |
} |
4e17e6
|
391 |
|
T |
392 |
|
1cded8
|
393 |
function rcmail_compose_header_from($attrib) |
4315b0
|
394 |
{ |
8fa58e
|
395 |
global $IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $compose_mode; |
1cded8
|
396 |
|
T |
397 |
// pass the following attributes to the form class |
|
398 |
$field_attrib = array('name' => '_from'); |
|
399 |
foreach ($attrib as $attr => $value) |
|
400 |
if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) |
|
401 |
$field_attrib[$attr] = $value; |
4e17e6
|
402 |
|
1cded8
|
403 |
// extract all recipients of the reply-message |
T |
404 |
$a_recipients = array(); |
8fa58e
|
405 |
if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers)) |
4315b0
|
406 |
{ |
8fa58e
|
407 |
$MESSAGE->compose_from = array(); |
58e360
|
408 |
|
8fa58e
|
409 |
$a_to = $IMAP->decode_address_list($MESSAGE->headers->to); |
1cded8
|
410 |
foreach ($a_to as $addr) |
4315b0
|
411 |
{ |
1cded8
|
412 |
if (!empty($addr['mailto'])) |
e25a35
|
413 |
$a_recipients[] = strtolower($addr['mailto']); |
4315b0
|
414 |
} |
4e17e6
|
415 |
|
8fa58e
|
416 |
if (!empty($MESSAGE->headers->cc)) |
4315b0
|
417 |
{ |
8fa58e
|
418 |
$a_cc = $IMAP->decode_address_list($MESSAGE->headers->cc); |
1cded8
|
419 |
foreach ($a_cc as $addr) |
4315b0
|
420 |
{ |
1cded8
|
421 |
if (!empty($addr['mailto'])) |
e25a35
|
422 |
$a_recipients[] = strtolower($addr['mailto']); |
1cded8
|
423 |
} |
T |
424 |
} |
4315b0
|
425 |
} |
4e17e6
|
426 |
|
1cded8
|
427 |
// get this user's identities |
ed205f
|
428 |
$user_identities = $USER->list_identities(); |
a0109c
|
429 |
|
ed205f
|
430 |
if (count($user_identities)) |
4315b0
|
431 |
{ |
1cded8
|
432 |
$a_signatures = array(); |
a0109c
|
433 |
|
f11541
|
434 |
$field_attrib['onchange'] = JS_OBJECT_NAME.".change_identity(this)"; |
47124c
|
435 |
$select_from = new html_select($field_attrib); |
a0109c
|
436 |
|
e25a35
|
437 |
// create SELECT element |
ed205f
|
438 |
foreach ($user_identities as $sql_arr) |
4315b0
|
439 |
{ |
e25a35
|
440 |
$email = mb_strtolower(idn_to_utf8($sql_arr['email'])); |
a0109c
|
441 |
$identity_id = $sql_arr['identity_id']; |
e25a35
|
442 |
$select_from->add(format_email_recipient($email, $sql_arr['name']), $identity_id); |
4e17e6
|
443 |
|
1cded8
|
444 |
// add signature to array |
759696
|
445 |
if (!empty($sql_arr['signature']) && empty($_SESSION['compose']['param']['nosig'])) |
4315b0
|
446 |
{ |
a0109c
|
447 |
$a_signatures[$identity_id]['text'] = $sql_arr['signature']; |
S |
448 |
$a_signatures[$identity_id]['is_html'] = ($sql_arr['html_signature'] == 1) ? true : false; |
dd792e
|
449 |
if ($a_signatures[$identity_id]['is_html']) |
4315b0
|
450 |
{ |
dd792e
|
451 |
$h2t = new html2text($a_signatures[$identity_id]['text'], false, false); |
300fc6
|
452 |
$a_signatures[$identity_id]['plain_text'] = trim($h2t->get_text()); |
a0109c
|
453 |
} |
4315b0
|
454 |
} |
a0109c
|
455 |
|
8fa58e
|
456 |
if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE->compose_from)) |
e25a35
|
457 |
$MESSAGE->compose_from[] = $email; |
4315b0
|
458 |
} |
e25a35
|
459 |
|
A |
460 |
$from_id = 0; |
4e17e6
|
461 |
|
1cded8
|
462 |
// overwrite identity selection with post parameter |
6eb858
|
463 |
if (!empty($_POST['_from'])) |
8d4bcd
|
464 |
$from_id = get_input_value('_from', RCUBE_INPUT_POST); |
416bff
|
465 |
else if (!empty($_SESSION['compose']['param']['from'])) |
A |
466 |
$from_id = $_SESSION['compose']['param']['from']; |
d2b884
|
467 |
else { |
e25a35
|
468 |
$return_path = $MESSAGE->headers->others['return-path']; |
A |
469 |
|
|
470 |
// Set identity |
|
471 |
foreach ($user_identities as $sql_arr) { |
|
472 |
// set draft's identity |
663534
|
473 |
if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { |
A |
474 |
if ($MESSAGE->headers->from == format_email_recipient($sql_arr['email'], $sql_arr['name'])) { |
e25a35
|
475 |
$from_id = $sql_arr['identity_id']; |
A |
476 |
break; |
663534
|
477 |
} |
e25a35
|
478 |
} |
A |
479 |
// set identity if it's one of the reply-message recipients (with prio for default identity) |
|
480 |
else if (in_array($sql_arr['email'], $a_recipients) && (empty($from_id) || $sql_arr['standard'])) |
|
481 |
$from_id = $sql_arr['identity_id']; |
|
482 |
// set identity when replying to mailing list |
|
483 |
else if (strpos($return_path, str_replace('@', '=', $sql_arr['email']).'@') !== false) |
|
484 |
$from_id = $sql_arr['identity_id']; |
|
485 |
|
|
486 |
if ($from_id) |
|
487 |
break; |
|
488 |
} |
|
489 |
} |
4e17e6
|
490 |
|
1cded8
|
491 |
$out = $select_from->show($from_id); |
4e17e6
|
492 |
|
1cded8
|
493 |
// add signatures to client |
f11541
|
494 |
$OUTPUT->set_env('signatures', $a_signatures); |
4315b0
|
495 |
} |
d2b884
|
496 |
// no identities, display text input field |
A |
497 |
else { |
|
498 |
$field_attrib['class'] = 'from_address'; |
47124c
|
499 |
$input_from = new html_inputfield($field_attrib); |
cc5ae9
|
500 |
$out = $input_from->show($_POST['_from']); |
4315b0
|
501 |
} |
4e17e6
|
502 |
|
1cded8
|
503 |
return $out; |
4315b0
|
504 |
} |
4e17e6
|
505 |
|
T |
506 |
|
868deb
|
507 |
function rcmail_compose_editor_mode() |
A |
508 |
{ |
|
509 |
global $RCMAIL, $MESSAGE, $compose_mode; |
|
510 |
static $useHtml; |
|
511 |
|
|
512 |
if ($useHtml !== null) |
|
513 |
return $useHtml; |
|
514 |
|
|
515 |
$html_editor = intval($RCMAIL->config->get('htmleditor')); |
|
516 |
|
|
517 |
if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { |
|
518 |
$useHtml = $MESSAGE->has_html_part(); |
|
519 |
} |
|
520 |
else if ($compose_mode == RCUBE_COMPOSE_REPLY) { |
|
521 |
$useHtml = ($html_editor == 1 || ($html_editor == 2 && $MESSAGE->has_html_part())); |
|
522 |
} |
|
523 |
else { // RCUBE_COMPOSE_FORWARD or NEW |
|
524 |
$useHtml = ($html_editor == 1); |
|
525 |
} |
|
526 |
|
|
527 |
return $useHtml; |
|
528 |
} |
|
529 |
|
|
530 |
|
087c7d
|
531 |
function rcmail_prepare_message_body() |
4315b0
|
532 |
{ |
868deb
|
533 |
global $RCMAIL, $MESSAGE, $compose_mode, $LINE_LENGTH, $HTML_MODE; |
a0109c
|
534 |
|
4e17e6
|
535 |
// use posted message body |
868deb
|
536 |
if (!empty($_POST['_message'])) { |
8fa58e
|
537 |
$body = get_input_value('_message', RCUBE_INPUT_POST, true); |
868deb
|
538 |
$isHtml = (bool) get_input_value('_is_html', RCUBE_INPUT_POST); |
8fa58e
|
539 |
} |
868deb
|
540 |
else if ($_SESSION['compose']['param']['body']) { |
759696
|
541 |
$body = $_SESSION['compose']['param']['body']; |
T |
542 |
$isHtml = false; |
|
543 |
} |
868deb
|
544 |
// reply/edit/draft/forward |
A |
545 |
else if ($compose_mode) { |
b62049
|
546 |
$has_html_part = $MESSAGE->has_html_part(); |
868deb
|
547 |
$isHtml = rcmail_compose_editor_mode(); |
A |
548 |
|
|
549 |
if ($isHtml) { |
|
550 |
if ($has_html_part) { |
|
551 |
$body = $MESSAGE->first_html_part(); |
|
552 |
} |
|
553 |
else { |
ba12c7
|
554 |
$body = $MESSAGE->first_text_part(); |
A |
555 |
// try to remove the signature |
|
556 |
if ($RCMAIL->config->get('strip_existing_sig', true)) |
|
557 |
$body = rcmail_remove_signature($body); |
|
558 |
// add HTML formatting |
|
559 |
$body = rcmail_plain_body($body); |
868deb
|
560 |
if ($body) |
A |
561 |
$body = '<pre>' . $body . '</pre>'; |
|
562 |
} |
b62049
|
563 |
} |
868deb
|
564 |
else { |
A |
565 |
if ($has_html_part) { |
|
566 |
// use html part if it has been used for message (pre)viewing |
|
567 |
// decrease line length for quoting |
|
568 |
$len = $compose_mode == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH; |
|
569 |
$txt = new html2text($MESSAGE->first_html_part(), false, true, $len); |
|
570 |
$body = $txt->get_text(); |
|
571 |
} |
|
572 |
else { |
|
573 |
$body = $MESSAGE->first_text_part($part); |
|
574 |
if ($body && $part && $part->ctype_secondary == 'plain' |
|
575 |
&& $part->ctype_parameters['format'] == 'flowed' |
|
576 |
) { |
|
577 |
$body = rcube_message::unfold_flowed($body); |
|
578 |
} |
|
579 |
} |
4e17e6
|
580 |
} |
80815d
|
581 |
|
8fa58e
|
582 |
// compose reply-body |
T |
583 |
if ($compose_mode == RCUBE_COMPOSE_REPLY) |
|
584 |
$body = rcmail_create_reply_body($body, $isHtml); |
|
585 |
// forward message body inline |
|
586 |
else if ($compose_mode == RCUBE_COMPOSE_FORWARD) |
|
587 |
$body = rcmail_create_forward_body($body, $isHtml); |
|
588 |
// load draft message body |
069704
|
589 |
else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) |
8fa58e
|
590 |
$body = rcmail_create_draft_body($body, $isHtml); |
868deb
|
591 |
} |
A |
592 |
else { // new message |
|
593 |
$isHtml = rcmail_compose_editor_mode(); |
8fa58e
|
594 |
} |
a0109c
|
595 |
|
8abe54
|
596 |
$plugin = $RCMAIL->plugins->exec_hook('message_compose_body', |
A |
597 |
array('body' => $body, 'html' => $isHtml, 'mode' => $compose_mode)); |
b575fa
|
598 |
$body = $plugin['body']; |
A |
599 |
unset($plugin); |
8abe54
|
600 |
|
b575fa
|
601 |
// add blocked.gif attachment (#1486516) |
A |
602 |
if ($isHtml && preg_match('#<img src="\./program/blocked\.gif"#', $body)) { |
|
603 |
if ($attachment = rcmail_save_image('program/blocked.gif', 'image/gif')) { |
|
604 |
$_SESSION['compose']['attachments'][$attachment['id']] = $attachment; |
|
605 |
$body = preg_replace('#\./program/blocked\.gif#', |
|
606 |
$RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id'], |
|
607 |
$body); |
|
608 |
} |
|
609 |
} |
|
610 |
|
087c7d
|
611 |
$HTML_MODE = $isHtml; |
A |
612 |
|
|
613 |
return $body; |
|
614 |
} |
|
615 |
|
|
616 |
function rcmail_compose_body($attrib) |
|
617 |
{ |
|
618 |
global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode, $LINE_LENGTH, $HTML_MODE, $MESSAGE_BODY; |
|
619 |
|
|
620 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
621 |
unset($attrib['form']); |
|
622 |
|
|
623 |
if (empty($attrib['id'])) |
|
624 |
$attrib['id'] = 'rcmComposeBody'; |
|
625 |
|
|
626 |
$attrib['name'] = '_message'; |
|
627 |
|
|
628 |
$isHtml = $HTML_MODE; |
|
629 |
|
4e17e6
|
630 |
$out = $form_start ? "$form_start\n" : ''; |
1966c5
|
631 |
|
8fa58e
|
632 |
$saveid = new html_hiddenfield(array('name' => '_draft_saveid', 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), "", $MESSAGE->headers->messageID) : '')); |
f0f98f
|
633 |
$out .= $saveid->show(); |
1966c5
|
634 |
|
47124c
|
635 |
$drafttoggle = new html_hiddenfield(array('name' => '_draft', 'value' => 'yes')); |
1966c5
|
636 |
$out .= $drafttoggle->show(); |
S |
637 |
|
47124c
|
638 |
$msgtype = new html_hiddenfield(array('name' => '_is_html', 'value' => ($isHtml?"1":"0"))); |
a0109c
|
639 |
$out .= $msgtype->show(); |
S |
640 |
|
2f746d
|
641 |
// If desired, set this textarea to be editable by TinyMCE |
6084d7
|
642 |
if ($isHtml) { |
A |
643 |
$attrib['class'] = 'mce_editor'; |
|
644 |
$textarea = new html_textarea($attrib); |
|
645 |
$out .= $textarea->show($MESSAGE_BODY); |
|
646 |
} |
|
647 |
else { |
|
648 |
$textarea = new html_textarea($attrib); |
|
649 |
$out .= $textarea->show(''); |
|
650 |
// quote plain text, inject into textarea |
|
651 |
$table = get_html_translation_table(HTML_SPECIALCHARS); |
|
652 |
$MESSAGE_BODY = strtr($MESSAGE_BODY, $table); |
|
653 |
$out = substr($out, 0, -11) . $MESSAGE_BODY . '</textarea>'; |
|
654 |
} |
|
655 |
|
4e17e6
|
656 |
$out .= $form_end ? "\n$form_end" : ''; |
a01b3b
|
657 |
|
A |
658 |
$OUTPUT->set_env('composebody', $attrib['id']); |
a0109c
|
659 |
|
3e20c4
|
660 |
// include HTML editor |
A |
661 |
rcube_html_editor(); |
|
662 |
|
dd53e2
|
663 |
// include GoogieSpell |
4ca10b
|
664 |
if (!empty($CONFIG['enable_spellcheck'])) { |
3e20c4
|
665 |
|
c287f3
|
666 |
$engine = $RCMAIL->config->get('spellcheck_engine','googie'); |
A |
667 |
$spellcheck_langs = (array) $RCMAIL->config->get('spellcheck_languages', |
|
668 |
array('da'=>'Dansk', 'de'=>'Deutsch', 'en' => 'English', 'es'=>'Español', |
|
669 |
'fr'=>'Français', 'it'=>'Italiano', 'nl'=>'Nederlands', 'pl'=>'Polski', |
|
670 |
'pt'=>'Português', 'fi'=>'Suomi', 'sv'=>'Svenska')); |
|
671 |
|
|
672 |
// googie works only with two-letter codes |
|
673 |
if ($engine == 'googie') { |
|
674 |
$lang = strtolower(substr($_SESSION['language'], 0, 2)); |
|
675 |
|
|
676 |
$spellcheck_langs_googie = array(); |
|
677 |
foreach ($spellcheck_langs as $key => $name) |
|
678 |
$spellcheck_langs_googie[strtolower(substr($key,0,2))] = $name; |
|
679 |
$spellcheck_langs = $spellcheck_langs_googie; |
|
680 |
} |
|
681 |
else { |
|
682 |
$lang = $_SESSION['language']; |
|
683 |
|
|
684 |
// if not found in the list, try with two-letter code |
|
685 |
if (!$spellcheck_langs[$lang]) |
|
686 |
$lang = strtolower(substr($lang, 0, 2)); |
|
687 |
} |
|
688 |
|
326f3d
|
689 |
if (!$spellcheck_langs[$lang]) |
T |
690 |
$lang = 'en'; |
c287f3
|
691 |
|
326f3d
|
692 |
$editor_lang_set = array(); |
T |
693 |
foreach ($spellcheck_langs as $key => $name) { |
|
694 |
$editor_lang_set[] = ($key == $lang ? '+' : '') . JQ($name).'='.JQ($key); |
c287f3
|
695 |
} |
996066
|
696 |
|
ed5d29
|
697 |
$OUTPUT->include_script('googiespell.js'); |
2bca6e
|
698 |
$OUTPUT->add_script(sprintf( |
677e1f
|
699 |
"var googie = new GoogieSpell('\$__skin_path/images/googiespell/','?_task=utils&_action=spell&lang=');\n". |
2bca6e
|
700 |
"googie.lang_chck_spell = \"%s\";\n". |
T |
701 |
"googie.lang_rsm_edt = \"%s\";\n". |
|
702 |
"googie.lang_close = \"%s\";\n". |
|
703 |
"googie.lang_revert = \"%s\";\n". |
326f3d
|
704 |
"googie.lang_no_error_found = \"%s\";\n". |
T |
705 |
"googie.setLanguages(%s);\n". |
2bca6e
|
706 |
"googie.setCurrentLanguage('%s');\n". |
309d2f
|
707 |
"googie.setSpellContainer('spellcheck-control');\n". |
2bca6e
|
708 |
"googie.decorateTextarea('%s');\n". |
T |
709 |
"%s.set_env('spellcheck', googie);", |
|
710 |
JQ(Q(rcube_label('checkspelling'))), |
|
711 |
JQ(Q(rcube_label('resumeediting'))), |
|
712 |
JQ(Q(rcube_label('close'))), |
|
713 |
JQ(Q(rcube_label('revertto'))), |
|
714 |
JQ(Q(rcube_label('nospellerrors'))), |
2717f9
|
715 |
json_serialize($spellcheck_langs), |
326f3d
|
716 |
$lang, |
2bca6e
|
717 |
$attrib['id'], |
f11541
|
718 |
JS_OBJECT_NAME), 'foot'); |
ed5d29
|
719 |
|
112c91
|
720 |
$OUTPUT->add_label('checking'); |
326f3d
|
721 |
$OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set)); |
4ca10b
|
722 |
} |
f0f98f
|
723 |
|
027af3
|
724 |
$out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>'; |
41fa0b
|
725 |
|
4e17e6
|
726 |
return $out; |
4315b0
|
727 |
} |
4e17e6
|
728 |
|
T |
729 |
|
a0109c
|
730 |
function rcmail_create_reply_body($body, $bodyIsHtml) |
4315b0
|
731 |
{ |
b62049
|
732 |
global $RCMAIL, $MESSAGE, $LINE_LENGTH; |
4e17e6
|
733 |
|
9f9664
|
734 |
// build reply prefix |
A |
735 |
$from = array_pop($RCMAIL->imap->decode_address_list($MESSAGE->get_header('from'))); |
|
736 |
$prefix = sprintf("On %s, %s wrote:", |
db1a87
|
737 |
$MESSAGE->headers->date, $from['name'] ? $from['name'] : idn_to_utf8($from['mailto'])); |
9f9664
|
738 |
|
0207c4
|
739 |
if (!$bodyIsHtml) { |
33dfdd
|
740 |
$body = preg_replace('/\r?\n/', "\n", $body); |
9f9664
|
741 |
|
2b180b
|
742 |
// try to remove the signature |
ba12c7
|
743 |
if ($RCMAIL->config->get('strip_existing_sig', true)) |
A |
744 |
$body = rcmail_remove_signature($body); |
2b180b
|
745 |
|
6b6f2e
|
746 |
// soft-wrap and quote message text |
33dfdd
|
747 |
$body = rcmail_wrap_and_quote(rtrim($body, "\n"), $LINE_LENGTH); |
4e17e6
|
748 |
|
9f9664
|
749 |
$prefix .= "\n"; |
a0109c
|
750 |
$suffix = ''; |
9f9664
|
751 |
|
0207c4
|
752 |
if ($RCMAIL->config->get('top_posting')) |
50f56d
|
753 |
$prefix = "\n\n\n" . $prefix; |
a0109c
|
754 |
} |
0207c4
|
755 |
else { |
ec603f
|
756 |
// save inline images to files |
A |
757 |
$cid_map = rcmail_write_inline_attachments($MESSAGE); |
|
758 |
// set is_safe flag (we need this for html body washing) |
|
759 |
rcmail_check_safe($MESSAGE); |
|
760 |
// clean up html tags |
|
761 |
$body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map); |
|
762 |
|
|
763 |
// build reply (quote content) |
9f9664
|
764 |
$prefix = '<p>' . Q($prefix) . "</p>\n"; |
7a48e5
|
765 |
$prefix .= '<blockquote>'; |
ce4673
|
766 |
|
0207c4
|
767 |
if ($RCMAIL->config->get('top_posting')) { |
ce4673
|
768 |
$prefix = '<br>' . $prefix; |
A |
769 |
$suffix = '</blockquote>'; |
50f56d
|
770 |
} |
A |
771 |
else { |
ce4673
|
772 |
$suffix = '</blockquote><p></p>'; |
50f56d
|
773 |
} |
a0109c
|
774 |
} |
S |
775 |
|
|
776 |
return $prefix.$body.$suffix; |
4315b0
|
777 |
} |
4e17e6
|
778 |
|
T |
779 |
|
a0109c
|
780 |
function rcmail_create_forward_body($body, $bodyIsHtml) |
4315b0
|
781 |
{ |
8c0b9e
|
782 |
global $IMAP, $MESSAGE, $OUTPUT; |
ec603f
|
783 |
|
A |
784 |
// add attachments |
|
785 |
if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE->mime_parts)) |
|
786 |
$cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); |
4e17e6
|
787 |
|
8fa58e
|
788 |
if (!$bodyIsHtml) |
a0109c
|
789 |
{ |
5758b9
|
790 |
$prefix = "\n\n\n-------- Original Message --------\n"; |
A |
791 |
$prefix .= 'Subject: ' . $MESSAGE->subject . "\n"; |
|
792 |
$prefix .= 'Date: ' . $MESSAGE->headers->date . "\n"; |
|
793 |
$prefix .= 'From: ' . $MESSAGE->get_header('from') . "\n"; |
|
794 |
$prefix .= 'To: ' . $MESSAGE->get_header('to') . "\n"; |
a4cf45
|
795 |
|
A |
796 |
if ($MESSAGE->headers->cc) |
|
797 |
$prefix .= 'Cc: ' . $MESSAGE->get_header('cc') . "\n"; |
5758b9
|
798 |
if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from) |
A |
799 |
$prefix .= 'Reply-To: ' . $MESSAGE->get_header('replyto') . "\n"; |
a4cf45
|
800 |
|
5758b9
|
801 |
$prefix .= "\n"; |
a0109c
|
802 |
} |
S |
803 |
else |
|
804 |
{ |
ec603f
|
805 |
// set is_safe flag (we need this for html body washing) |
A |
806 |
rcmail_check_safe($MESSAGE); |
|
807 |
// clean up html tags |
|
808 |
$body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map); |
|
809 |
|
4315b0
|
810 |
$prefix = sprintf( |
ce4673
|
811 |
"<br /><p>-------- Original Message --------</p>" . |
a0109c
|
812 |
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody>" . |
S |
813 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Subject: </th><td>%s</td></tr>" . |
|
814 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Date: </th><td>%s</td></tr>" . |
|
815 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">From: </th><td>%s</td></tr>" . |
5758b9
|
816 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">To: </th><td>%s</td></tr>", |
8fa58e
|
817 |
Q($MESSAGE->subject), |
T |
818 |
Q($MESSAGE->headers->date), |
3e8d89
|
819 |
htmlspecialchars(Q($MESSAGE->get_header('from'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset()), |
7d8e16
|
820 |
htmlspecialchars(Q($MESSAGE->get_header('to'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset())); |
5758b9
|
821 |
|
a4cf45
|
822 |
if ($MESSAGE->headers->cc) |
A |
823 |
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Cc: </th><td>%s</td></tr>", |
|
824 |
htmlspecialchars(Q($MESSAGE->get_header('cc'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset())); |
|
825 |
|
5758b9
|
826 |
if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from) |
A |
827 |
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Reply-To: </th><td>%s</td></tr>", |
7d8e16
|
828 |
htmlspecialchars(Q($MESSAGE->get_header('replyto'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset())); |
5758b9
|
829 |
|
A |
830 |
$prefix .= "</tbody></table><br>"; |
a0109c
|
831 |
} |
5cc4b1
|
832 |
|
4e17e6
|
833 |
return $prefix.$body; |
4315b0
|
834 |
} |
4e17e6
|
835 |
|
8d4bcd
|
836 |
|
a0109c
|
837 |
function rcmail_create_draft_body($body, $bodyIsHtml) |
4315b0
|
838 |
{ |
ec603f
|
839 |
global $MESSAGE, $OUTPUT; |
8ecb0e
|
840 |
|
T |
841 |
/** |
|
842 |
* add attachments |
8fa58e
|
843 |
* sizeof($MESSAGE->mime_parts can be 1 - e.g. attachment, but no text! |
8ecb0e
|
844 |
*/ |
7d8e16
|
845 |
if (empty($_SESSION['compose']['forward_attachments']) |
8fa58e
|
846 |
&& is_array($MESSAGE->mime_parts) |
T |
847 |
&& count($MESSAGE->mime_parts) > 0) |
ec603f
|
848 |
{ |
A |
849 |
$cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); |
1966c5
|
850 |
|
ec603f
|
851 |
// replace cid with href in inline images links |
A |
852 |
if ($cid_map) |
|
853 |
$body = str_replace(array_keys($cid_map), array_values($cid_map), $body); |
|
854 |
} |
|
855 |
|
1966c5
|
856 |
return $body; |
4315b0
|
857 |
} |
ba12c7
|
858 |
|
A |
859 |
|
|
860 |
function rcmail_remove_signature($body) |
|
861 |
{ |
|
862 |
global $RCMAIL; |
|
863 |
|
|
864 |
$len = strlen($body); |
|
865 |
$sig_max_lines = $RCMAIL->config->get('sig_max_lines', 15); |
|
866 |
|
|
867 |
while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { |
|
868 |
if ($sp == 0 || $body[$sp-1] == "\n") { |
|
869 |
// do not touch blocks with more that X lines |
|
870 |
if (substr_count($body, "\n", $sp) < $sig_max_lines) { |
|
871 |
$body = substr($body, 0, max(0, $sp-1)); |
|
872 |
} |
|
873 |
break; |
|
874 |
} |
|
875 |
} |
|
876 |
|
|
877 |
return $body; |
|
878 |
} |
|
879 |
|
|
880 |
|
1bc48e
|
881 |
function rcmail_write_compose_attachments(&$message, $bodyIsHtml) |
4315b0
|
882 |
{ |
bde421
|
883 |
global $RCMAIL; |
5503cc
|
884 |
|
021ef4
|
885 |
$cid_map = $messages = array(); |
8fa58e
|
886 |
foreach ((array)$message->mime_parts as $pid => $part) |
4315b0
|
887 |
{ |
7d8e16
|
888 |
if (($part->ctype_primary != 'message' || !$bodyIsHtml) && $part->ctype_primary != 'multipart' && |
d311d8
|
889 |
($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename) |
A |
890 |
&& $part->mimetype != 'application/ms-tnef' |
|
891 |
) { |
021ef4
|
892 |
$skip = false; |
A |
893 |
if ($part->mimetype == 'message/rfc822') { |
|
894 |
$messages[] = $part->mime_id; |
|
895 |
} else if ($messages) { |
|
896 |
// skip attachments included in message/rfc822 attachment (#1486487) |
|
897 |
foreach ($messages as $mimeid) |
|
898 |
if (strpos($part->mime_id, $mimeid.'.') === 0) { |
|
899 |
$skip = true; |
|
900 |
break; |
|
901 |
} |
|
902 |
} |
|
903 |
|
|
904 |
if (!$skip && ($attachment = rcmail_save_attachment($message, $pid))) { |
cc97ea
|
905 |
$_SESSION['compose']['attachments'][$attachment['id']] = $attachment; |
8f2b46
|
906 |
if ($bodyIsHtml && ($part->content_id || $part->content_location)) { |
bde421
|
907 |
$url = $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id']; |
8f2b46
|
908 |
if ($part->content_id) |
A |
909 |
$cid_map['cid:'.$part->content_id] = $url; |
|
910 |
else |
|
911 |
$cid_map[$part->content_location] = $url; |
ec603f
|
912 |
} |
A |
913 |
} |
8d4bcd
|
914 |
} |
4315b0
|
915 |
} |
cc97ea
|
916 |
|
8fa58e
|
917 |
$_SESSION['compose']['forward_attachments'] = true; |
ec603f
|
918 |
|
A |
919 |
return $cid_map; |
4315b0
|
920 |
} |
4e17e6
|
921 |
|
T |
922 |
|
2f746d
|
923 |
function rcmail_write_inline_attachments(&$message) |
A |
924 |
{ |
bde421
|
925 |
global $RCMAIL; |
ec603f
|
926 |
|
A |
927 |
$cid_map = array(); |
|
928 |
foreach ((array)$message->mime_parts as $pid => $part) { |
8f2b46
|
929 |
if (($part->content_id || $part->content_location) && $part->filename) { |
ec603f
|
930 |
if ($attachment = rcmail_save_attachment($message, $pid)) { |
cc97ea
|
931 |
$_SESSION['compose']['attachments'][$attachment['id']] = $attachment; |
bde421
|
932 |
$url = $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id']; |
8f2b46
|
933 |
if ($part->content_id) |
A |
934 |
$cid_map['cid:'.$part->content_id] = $url; |
|
935 |
else |
|
936 |
$cid_map[$part->content_location] = $url; |
ec603f
|
937 |
} |
2f746d
|
938 |
} |
A |
939 |
} |
8f2b46
|
940 |
|
ec603f
|
941 |
return $cid_map; |
2f746d
|
942 |
} |
A |
943 |
|
|
944 |
function rcmail_save_attachment(&$message, $pid) |
|
945 |
{ |
|
946 |
$part = $message->mime_parts[$pid]; |
a64064
|
947 |
$mem_limit = parse_bytes(ini_get('memory_limit')); |
A |
948 |
$curr_mem = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB |
|
949 |
$data = $path = null; |
|
950 |
|
|
951 |
// don't load too big attachments into memory |
|
952 |
if ($mem_limit > 0 && $part->size > $mem_limit - $curr_mem) { |
|
953 |
$rcmail = rcmail::get_instance(); |
|
954 |
$temp_dir = unslashify($rcmail->config->get('temp_dir')); |
|
955 |
$path = tempnam($temp_dir, 'rcmAttmnt'); |
|
956 |
if ($fp = fopen($path, 'w')) { |
|
957 |
$message->get_part_content($pid, $fp); |
|
958 |
fclose($fp); |
|
959 |
} else |
|
960 |
return false; |
|
961 |
} else { |
|
962 |
$data = $message->get_part_content($pid); |
|
963 |
} |
|
964 |
|
cc97ea
|
965 |
$attachment = array( |
7d8e16
|
966 |
'name' => $part->filename ? $part->filename : 'Part_'.$pid.'.'.$part->ctype_secondary, |
cc97ea
|
967 |
'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, |
T |
968 |
'content_id' => $part->content_id, |
a64064
|
969 |
'data' => $data, |
3b1426
|
970 |
'path' => $path, |
A |
971 |
'size' => $path ? filesize($path) : strlen($data), |
cc97ea
|
972 |
); |
3b1426
|
973 |
|
e6ce00
|
974 |
$attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment); |
a64064
|
975 |
|
cc97ea
|
976 |
if ($attachment['status']) { |
76791c
|
977 |
unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']); |
cc97ea
|
978 |
return $attachment; |
a64064
|
979 |
} else if ($path) { |
A |
980 |
@unlink($path); |
2f746d
|
981 |
} |
a64064
|
982 |
|
cc97ea
|
983 |
return false; |
2f746d
|
984 |
} |
A |
985 |
|
b575fa
|
986 |
function rcmail_save_image($path, $mimetype='') |
A |
987 |
{ |
|
988 |
// handle attachments in memory |
|
989 |
$data = file_get_contents($path); |
|
990 |
|
|
991 |
$attachment = array( |
|
992 |
'name' => rcmail_basename($path), |
|
993 |
'mimetype' => $mimetype ? $mimetype : rc_mime_content_type($path, $name), |
|
994 |
'data' => $data, |
|
995 |
'size' => strlen($data), |
|
996 |
); |
|
997 |
|
e6ce00
|
998 |
$attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment); |
b575fa
|
999 |
|
A |
1000 |
if ($attachment['status']) { |
|
1001 |
unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']); |
|
1002 |
return $attachment; |
|
1003 |
} |
|
1004 |
|
|
1005 |
return false; |
|
1006 |
} |
|
1007 |
|
|
1008 |
function rcmail_basename($filename) |
|
1009 |
{ |
|
1010 |
// basename() is not unicode safe and locale dependent |
|
1011 |
if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) { |
|
1012 |
return preg_replace('/^.*[\\\\\\/]/', '', $filename); |
|
1013 |
} else { |
|
1014 |
return preg_replace('/^.*[\/]/', '', $filename); |
|
1015 |
} |
|
1016 |
} |
2f746d
|
1017 |
|
4e17e6
|
1018 |
function rcmail_compose_subject($attrib) |
4315b0
|
1019 |
{ |
8fa58e
|
1020 |
global $MESSAGE, $compose_mode; |
4e17e6
|
1021 |
|
T |
1022 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
1023 |
unset($attrib['form']); |
|
1024 |
|
|
1025 |
$attrib['name'] = '_subject'; |
491a6e
|
1026 |
$attrib['spellcheck'] = 'true'; |
47124c
|
1027 |
$textfield = new html_inputfield($attrib); |
4e17e6
|
1028 |
|
T |
1029 |
$subject = ''; |
|
1030 |
|
|
1031 |
// use subject from post |
5f314d
|
1032 |
if (isset($_POST['_subject'])) { |
01c86f
|
1033 |
$subject = get_input_value('_subject', RCUBE_INPUT_POST, TRUE); |
5f314d
|
1034 |
} |
4e17e6
|
1035 |
// create a reply-subject |
5f314d
|
1036 |
else if ($compose_mode == RCUBE_COMPOSE_REPLY) { |
23a2ee
|
1037 |
if (preg_match('/^re:/i', $MESSAGE->subject)) |
8fa58e
|
1038 |
$subject = $MESSAGE->subject; |
520c36
|
1039 |
else |
8fa58e
|
1040 |
$subject = 'Re: '.$MESSAGE->subject; |
4315b0
|
1041 |
} |
4e17e6
|
1042 |
// create a forward-subject |
5f314d
|
1043 |
else if ($compose_mode == RCUBE_COMPOSE_FORWARD) { |
23a2ee
|
1044 |
if (preg_match('/^fwd:/i', $MESSAGE->subject)) |
8fa58e
|
1045 |
$subject = $MESSAGE->subject; |
09941e
|
1046 |
else |
8fa58e
|
1047 |
$subject = 'Fwd: '.$MESSAGE->subject; |
4315b0
|
1048 |
} |
1966c5
|
1049 |
// creeate a draft-subject |
069704
|
1050 |
else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { |
8fa58e
|
1051 |
$subject = $MESSAGE->subject; |
5f314d
|
1052 |
} |
759696
|
1053 |
else if (!empty($_SESSION['compose']['param']['subject'])) { |
T |
1054 |
$subject = $_SESSION['compose']['param']['subject']; |
5f314d
|
1055 |
} |
4e17e6
|
1056 |
|
T |
1057 |
$out = $form_start ? "$form_start\n" : ''; |
|
1058 |
$out .= $textfield->show($subject); |
|
1059 |
$out .= $form_end ? "\n$form_end" : ''; |
e99991
|
1060 |
|
4e17e6
|
1061 |
return $out; |
4315b0
|
1062 |
} |
4e17e6
|
1063 |
|
T |
1064 |
|
|
1065 |
function rcmail_compose_attachment_list($attrib) |
4315b0
|
1066 |
{ |
f11541
|
1067 |
global $OUTPUT, $CONFIG; |
4e17e6
|
1068 |
|
T |
1069 |
// add ID if not given |
|
1070 |
if (!$attrib['id']) |
|
1071 |
$attrib['id'] = 'rcmAttachmentList'; |
|
1072 |
|
8fa58e
|
1073 |
$out = "\n"; |
01ffe0
|
1074 |
$jslist = array(); |
087c7d
|
1075 |
|
4e17e6
|
1076 |
if (is_array($_SESSION['compose']['attachments'])) |
4315b0
|
1077 |
{ |
991a25
|
1078 |
if ($attrib['deleteicon']) { |
8fa58e
|
1079 |
$button = html::img(array( |
T |
1080 |
'src' => $CONFIG['skin_path'] . $attrib['deleteicon'], |
1fb587
|
1081 |
'alt' => rcube_label('delete') |
991a25
|
1082 |
)); |
T |
1083 |
} |
a894ba
|
1084 |
else |
8fa58e
|
1085 |
$button = Q(rcube_label('delete')); |
a894ba
|
1086 |
|
aade7b
|
1087 |
foreach ($_SESSION['compose']['attachments'] as $id => $a_prop) |
6d5dba
|
1088 |
{ |
T |
1089 |
if (empty($a_prop)) |
|
1090 |
continue; |
|
1091 |
|
01ffe0
|
1092 |
$out .= html::tag('li', array('id' => 'rcmfile'.$id), |
8fa58e
|
1093 |
html::a(array( |
T |
1094 |
'href' => "#delete", |
|
1095 |
'title' => rcube_label('delete'), |
cc97ea
|
1096 |
'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", JS_OBJECT_NAME, $id)), |
8fa58e
|
1097 |
$button) . Q($a_prop['name'])); |
01ffe0
|
1098 |
|
T |
1099 |
$jslist['rcmfile'.$id] = array('name' => $a_prop['name'], 'complete' => true, 'mimetype' => $a_prop['mimetype']); |
6d5dba
|
1100 |
} |
4315b0
|
1101 |
} |
4e17e6
|
1102 |
|
21d682
|
1103 |
if ($attrib['deleteicon']) |
A |
1104 |
$_SESSION['compose']['deleteicon'] = $CONFIG['skin_path'] . $attrib['deleteicon']; |
3f9712
|
1105 |
if ($attrib['cancelicon']) |
V |
1106 |
$OUTPUT->set_env('cancelicon', $CONFIG['skin_path'] . $attrib['cancelicon']); |
ebf872
|
1107 |
if ($attrib['loadingicon']) |
A |
1108 |
$OUTPUT->set_env('loadingicon', $CONFIG['skin_path'] . $attrib['loadingicon']); |
21d682
|
1109 |
|
01ffe0
|
1110 |
$OUTPUT->set_env('attachments', $jslist); |
f11541
|
1111 |
$OUTPUT->add_gui_object('attachmentlist', $attrib['id']); |
4e17e6
|
1112 |
|
8fa58e
|
1113 |
return html::tag('ul', $attrib, $out, html::$common_attrib); |
4315b0
|
1114 |
} |
4e17e6
|
1115 |
|
T |
1116 |
|
|
1117 |
function rcmail_compose_attachment_form($attrib) |
4315b0
|
1118 |
{ |
197601
|
1119 |
global $OUTPUT; |
4e17e6
|
1120 |
|
T |
1121 |
// add ID if not given |
|
1122 |
if (!$attrib['id']) |
|
1123 |
$attrib['id'] = 'rcmUploadbox'; |
7df0e3
|
1124 |
|
A |
1125 |
// find max filesize value |
|
1126 |
$max_filesize = parse_bytes(ini_get('upload_max_filesize')); |
|
1127 |
$max_postsize = parse_bytes(ini_get('post_max_size')); |
|
1128 |
if ($max_postsize && $max_postsize < $max_filesize) |
|
1129 |
$max_filesize = $max_postsize; |
|
1130 |
$max_filesize = show_bytes($max_filesize); |
4e17e6
|
1131 |
|
2b77e8
|
1132 |
$button = new html_inputfield(array('type' => 'button')); |
4e17e6
|
1133 |
|
197601
|
1134 |
$out = html::div($attrib, |
d37e1e
|
1135 |
$OUTPUT->form_tag(array('name' => 'uploadform', 'method' => 'post', 'enctype' => 'multipart/form-data'), |
2b77e8
|
1136 |
html::div(null, rcmail_compose_attachment_field(array('size' => $attrib[attachmentfieldsize]))) . |
7df0e3
|
1137 |
html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize)))) . |
c17dc6
|
1138 |
html::div('buttons', |
71f60c
|
1139 |
$button->show(rcube_label('close'), array('class' => 'button', 'onclick' => "$('#$attrib[id]').hide()")) . ' ' . |
2b77e8
|
1140 |
$button->show(rcube_label('upload'), array('class' => 'button mainaction', 'onclick' => JS_OBJECT_NAME . ".command('send-attachment', this.form)")) |
c17dc6
|
1141 |
) |
A |
1142 |
) |
197601
|
1143 |
); |
4e17e6
|
1144 |
|
f11541
|
1145 |
$OUTPUT->add_gui_object('uploadbox', $attrib['id']); |
4e17e6
|
1146 |
return $out; |
4315b0
|
1147 |
} |
4e17e6
|
1148 |
|
T |
1149 |
|
|
1150 |
function rcmail_compose_attachment_field($attrib) |
4315b0
|
1151 |
{ |
e2c610
|
1152 |
$attrib['type'] = 'file'; |
A |
1153 |
$attrib['name'] = '_attachments[]'; |
|
1154 |
$field = new html_inputfield($attrib); |
|
1155 |
return $field->show(); |
4315b0
|
1156 |
} |
4e17e6
|
1157 |
|
66e2bf
|
1158 |
|
4e17e6
|
1159 |
function rcmail_priority_selector($attrib) |
4315b0
|
1160 |
{ |
ff08ee
|
1161 |
global $MESSAGE; |
T |
1162 |
|
4e17e6
|
1163 |
list($form_start, $form_end) = get_form_tags($attrib); |
T |
1164 |
unset($attrib['form']); |
8958d0
|
1165 |
|
4e17e6
|
1166 |
$attrib['name'] = '_priority'; |
47124c
|
1167 |
$selector = new html_select($attrib); |
4e17e6
|
1168 |
|
T |
1169 |
$selector->add(array(rcube_label('lowest'), |
|
1170 |
rcube_label('low'), |
|
1171 |
rcube_label('normal'), |
|
1172 |
rcube_label('high'), |
|
1173 |
rcube_label('highest')), |
7902df
|
1174 |
array(5, 4, 0, 2, 1)); |
8958d0
|
1175 |
|
79eb4e
|
1176 |
if (isset($_POST['_priority'])) |
A |
1177 |
$sel = $_POST['_priority']; |
|
1178 |
else if (intval($MESSAGE->headers->priority) != 3) |
|
1179 |
$sel = intval($MESSAGE->headers->priority); |
|
1180 |
else |
|
1181 |
$sel = 0; |
4e17e6
|
1182 |
|
T |
1183 |
$out = $form_start ? "$form_start\n" : ''; |
|
1184 |
$out .= $selector->show($sel); |
|
1185 |
$out .= $form_end ? "\n$form_end" : ''; |
8958d0
|
1186 |
|
4e17e6
|
1187 |
return $out; |
4315b0
|
1188 |
} |
4e17e6
|
1189 |
|
T |
1190 |
|
620439
|
1191 |
function rcmail_receipt_checkbox($attrib) |
4315b0
|
1192 |
{ |
b3660b
|
1193 |
global $RCMAIL, $MESSAGE, $compose_mode; |
8958d0
|
1194 |
|
620439
|
1195 |
list($form_start, $form_end) = get_form_tags($attrib); |
T |
1196 |
unset($attrib['form']); |
8958d0
|
1197 |
|
66e2bf
|
1198 |
if (!isset($attrib['id'])) |
T |
1199 |
$attrib['id'] = 'receipt'; |
620439
|
1200 |
|
T |
1201 |
$attrib['name'] = '_receipt'; |
66e2bf
|
1202 |
$attrib['value'] = '1'; |
47124c
|
1203 |
$checkbox = new html_checkbox($attrib); |
620439
|
1204 |
|
b3660b
|
1205 |
if ($MESSAGE && in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) |
A |
1206 |
$mdn_default = (bool) $MESSAGE->headers->mdn_to; |
|
1207 |
else |
|
1208 |
$mdn_default = $RCMAIL->config->get('mdn_default'); |
|
1209 |
|
620439
|
1210 |
$out = $form_start ? "$form_start\n" : ''; |
b3660b
|
1211 |
$out .= $checkbox->show($mdn_default); |
620439
|
1212 |
$out .= $form_end ? "\n$form_end" : ''; |
T |
1213 |
|
|
1214 |
return $out; |
4315b0
|
1215 |
} |
620439
|
1216 |
|
T |
1217 |
|
f22ea7
|
1218 |
function rcmail_dsn_checkbox($attrib) |
A |
1219 |
{ |
|
1220 |
global $RCMAIL; |
|
1221 |
|
|
1222 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
1223 |
unset($attrib['form']); |
|
1224 |
|
|
1225 |
if (!isset($attrib['id'])) |
|
1226 |
$attrib['id'] = 'dsn'; |
|
1227 |
|
|
1228 |
$attrib['name'] = '_dsn'; |
|
1229 |
$attrib['value'] = '1'; |
|
1230 |
$checkbox = new html_checkbox($attrib); |
|
1231 |
|
|
1232 |
$out = $form_start ? "$form_start\n" : ''; |
|
1233 |
$out .= $checkbox->show($RCMAIL->config->get('dsn_default')); |
|
1234 |
$out .= $form_end ? "\n$form_end" : ''; |
|
1235 |
|
|
1236 |
return $out; |
|
1237 |
} |
|
1238 |
|
|
1239 |
|
a0109c
|
1240 |
function rcmail_editor_selector($attrib) |
S |
1241 |
{ |
|
1242 |
global $CONFIG, $MESSAGE, $compose_mode; |
|
1243 |
|
8fa58e
|
1244 |
// determine whether HTML or plain text should be checked |
868deb
|
1245 |
$useHtml = rcmail_compose_editor_mode(); |
d9344f
|
1246 |
|
309d2f
|
1247 |
if (empty($attrib['editorid'])) |
a01b3b
|
1248 |
$attrib['editorid'] = 'rcmComposeBody'; |
79af0b
|
1249 |
|
309d2f
|
1250 |
if (empty($attrib['name'])) |
A |
1251 |
$attrib['name'] = 'editorSelect'; |
8958d0
|
1252 |
|
5821ff
|
1253 |
$attrib['onchange'] = "return rcmail_toggle_editor(this, '".$attrib['editorid']."', '_is_html')"; |
309d2f
|
1254 |
|
A |
1255 |
$select = new html_select($attrib); |
|
1256 |
|
|
1257 |
$select->add(Q(rcube_label('htmltoggle')), 'html'); |
|
1258 |
$select->add(Q(rcube_label('plaintoggle')), 'plain'); |
|
1259 |
|
|
1260 |
return $select->show($useHtml ? 'html' : 'plain'); |
79af0b
|
1261 |
|
868deb
|
1262 |
foreach ($choices as $value => $text) { |
6b1fc0
|
1263 |
$attrib['id'] = '_' . $value; |
d9344f
|
1264 |
$attrib['value'] = $value; |
8fa58e
|
1265 |
$selector .= $radio->show($chosenvalue, $attrib) . html::label($attrib['id'], Q(rcube_label($text))); |
4315b0
|
1266 |
} |
a0109c
|
1267 |
|
S |
1268 |
return $selector; |
|
1269 |
} |
|
1270 |
|
|
1271 |
|
faf876
|
1272 |
function rcmail_store_target_selection($attrib) |
T |
1273 |
{ |
|
1274 |
$attrib['name'] = '_store_target'; |
a81be1
|
1275 |
$select = rcmail_mailbox_select(array_merge($attrib, array('noselection' => '- '.rcube_label('dontsave').' -'))); |
814905
|
1276 |
return $select->show($_SESSION['compose']['param']['sent_mbox'], $attrib); |
faf876
|
1277 |
} |
T |
1278 |
|
|
1279 |
|
eeb85f
|
1280 |
function rcmail_check_sent_folder($folder, $create=false) |
A |
1281 |
{ |
|
1282 |
global $IMAP; |
|
1283 |
|
|
1284 |
if ($IMAP->mailbox_exists($folder, true)) { |
|
1285 |
return true; |
|
1286 |
} |
|
1287 |
|
|
1288 |
// folder may exist but isn't subscribed (#1485241) |
|
1289 |
if ($create) { |
|
1290 |
if (!$IMAP->mailbox_exists($folder)) |
|
1291 |
return $IMAP->create_mailbox($folder, true); |
|
1292 |
else |
|
1293 |
return $IMAP->subscribe($folder); |
|
1294 |
} |
|
1295 |
|
|
1296 |
return false; |
|
1297 |
} |
|
1298 |
|
|
1299 |
|
4e17e6
|
1300 |
function get_form_tags($attrib) |
4315b0
|
1301 |
{ |
197601
|
1302 |
global $RCMAIL, $MESSAGE_FORM; |
4e17e6
|
1303 |
|
T |
1304 |
$form_start = ''; |
8958d0
|
1305 |
if (!$MESSAGE_FORM) |
4315b0
|
1306 |
{ |
197601
|
1307 |
$hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task)); |
4e17e6
|
1308 |
$hiddenfields->add(array('name' => '_action', 'value' => 'send')); |
1966c5
|
1309 |
|
197601
|
1310 |
$form_start = empty($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : ''; |
4e17e6
|
1311 |
$form_start .= $hiddenfields->show(); |
4315b0
|
1312 |
} |
eeb85f
|
1313 |
|
8958d0
|
1314 |
$form_end = ($MESSAGE_FORM && !strlen($attrib['form'])) ? '</form>' : ''; |
597170
|
1315 |
$form_name = !empty($attrib['form']) ? $attrib['form'] : 'form'; |
eeb85f
|
1316 |
|
8958d0
|
1317 |
if (!$MESSAGE_FORM) |
197601
|
1318 |
$RCMAIL->output->add_gui_object('messageform', $form_name); |
eeb85f
|
1319 |
|
4e17e6
|
1320 |
$MESSAGE_FORM = $form_name; |
T |
1321 |
|
47124c
|
1322 |
return array($form_start, $form_end); |
4315b0
|
1323 |
} |
4e17e6
|
1324 |
|
T |
1325 |
|
f11541
|
1326 |
// register UI objects |
T |
1327 |
$OUTPUT->add_handlers(array( |
|
1328 |
'composeheaders' => 'rcmail_compose_headers', |
|
1329 |
'composesubject' => 'rcmail_compose_subject', |
|
1330 |
'composebody' => 'rcmail_compose_body', |
|
1331 |
'composeattachmentlist' => 'rcmail_compose_attachment_list', |
|
1332 |
'composeattachmentform' => 'rcmail_compose_attachment_form', |
|
1333 |
'composeattachment' => 'rcmail_compose_attachment_field', |
|
1334 |
'priorityselector' => 'rcmail_priority_selector', |
|
1335 |
'editorselector' => 'rcmail_editor_selector', |
|
1336 |
'receiptcheckbox' => 'rcmail_receipt_checkbox', |
f22ea7
|
1337 |
'dsncheckbox' => 'rcmail_dsn_checkbox', |
faf876
|
1338 |
'storetarget' => 'rcmail_store_target_selection', |
f11541
|
1339 |
)); |
a0530a
|
1340 |
|
47124c
|
1341 |
$OUTPUT->send('compose'); |
a0530a
|
1342 |
|
b25dfd
|
1343 |
|