commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/compose.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
|
8 |
| Copyright (C) 2005, 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 |
|
|
22 |
|
|
23 |
require_once('Mail/mimeDecode.php'); |
|
24 |
|
|
25 |
|
|
26 |
$MESSAGE_FORM = NULL; |
|
27 |
$REPLY_MESSAGE = NULL; |
|
28 |
$FORWARD_MESSAGE = NULL; |
|
29 |
|
|
30 |
|
|
31 |
if (!is_array($_SESSION['compose'])) |
|
32 |
$_SESSION['compose'] = array('id' => uniqid(rand())); |
|
33 |
|
|
34 |
|
10a699
|
35 |
// add some labels to client |
977a29
|
36 |
rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'sendingmessage', 'notsentwarning'); |
10a699
|
37 |
|
T |
38 |
|
4e17e6
|
39 |
if ($_GET['_reply_uid'] || $_GET['_forward_uid']) |
T |
40 |
{ |
|
41 |
$msg_uid = $_GET['_reply_uid'] ? $_GET['_reply_uid'] : $_GET['_forward_uid']; |
|
42 |
|
|
43 |
// similar as in program/steps/mail/show.inc |
|
44 |
$MESSAGE = array(); |
|
45 |
$MESSAGE['headers'] = $IMAP->get_headers($msg_uid); |
|
46 |
|
|
47 |
$MESSAGE['source'] = rcmail_message_source($msg_uid); |
|
48 |
|
|
49 |
$mmd = new Mail_mimeDecode($MESSAGE['source']); |
|
50 |
$MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE, |
|
51 |
'decode_headers' => TRUE, |
|
52 |
'decode_bodies' => FALSE)); |
583f1c
|
53 |
|
4e17e6
|
54 |
$MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); |
T |
55 |
$MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']); |
|
56 |
|
|
57 |
if ($_GET['_reply_uid']) |
|
58 |
{ |
583f1c
|
59 |
$REPLY_MESSAGE = &$MESSAGE; |
4e17e6
|
60 |
$_SESSION['compose']['reply_uid'] = $_GET['_reply_uid']; |
T |
61 |
$_SESSION['compose']['reply_msgid'] = $REPLY_MESSAGE['headers']->messageID; |
479399
|
62 |
$_SESSION['compose']['references'] = $REPLY_MESSAGE['headers']->reference; |
f88d41
|
63 |
$_SESSION['compose']['references'] .= !empty($REPLY_MESSAGE['headers']->reference) ? ' ' : ''; |
T |
64 |
$_SESSION['compose']['references'] .= $REPLY_MESSAGE['headers']->messageID; |
583f1c
|
65 |
|
T |
66 |
if ($_GET['_all']) |
|
67 |
$REPLY_MESSAGE['reply_all'] = 1; |
4e17e6
|
68 |
} |
T |
69 |
else |
|
70 |
{ |
|
71 |
$FORWARD_MESSAGE = $MESSAGE; |
|
72 |
$_SESSION['compose']['forward_uid'] = $_GET['_forward_uid']; |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
/****** compose mode functions ********/ |
|
79 |
|
|
80 |
|
|
81 |
function rcmail_compose_headers($attrib) |
|
82 |
{ |
|
83 |
global $IMAP, $REPLY_MESSAGE, $DB; |
583f1c
|
84 |
static $sa_recipients = array(); |
4e17e6
|
85 |
|
T |
86 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
87 |
|
|
88 |
$out = ''; |
|
89 |
$part = strtolower($attrib['part']); |
|
90 |
|
|
91 |
switch ($part) |
|
92 |
{ |
|
93 |
case 'from': |
1cded8
|
94 |
return rcmail_compose_header_from($attrib); |
4e17e6
|
95 |
|
T |
96 |
case 'to': |
|
97 |
$fname = '_to'; |
|
98 |
$header = 'to'; |
1cded8
|
99 |
|
4e17e6
|
100 |
// we have contact id's as get parameters |
4fd971
|
101 |
if (!empty($_GET['_to']) && preg_match('/^[0-9]+(,[0-9]+)*$/', $_GET['_to'])) |
4e17e6
|
102 |
{ |
T |
103 |
$a_recipients = array(); |
d7cb77
|
104 |
$sql_result = $DB->query("SELECT name, email |
1cded8
|
105 |
FROM ".get_table_name('contacts')." |
T |
106 |
WHERE user_id=? |
|
107 |
AND del<>1 |
d7cb77
|
108 |
AND contact_id IN (".$_GET['_to'].")", |
S |
109 |
$_SESSION['user_id']); |
4e17e6
|
110 |
|
T |
111 |
while ($sql_arr = $DB->fetch_assoc($sql_result)) |
|
112 |
$a_recipients[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); |
|
113 |
|
|
114 |
if (sizeof($a_recipients)) |
|
115 |
$fvalue = join(', ', $a_recipients); |
|
116 |
} |
597170
|
117 |
else if (!empty($_GET['_to'])) |
4e17e6
|
118 |
$fvalue = $_GET['_to']; |
T |
119 |
|
|
120 |
case 'cc': |
|
121 |
if (!$fname) |
|
122 |
{ |
|
123 |
$fname = '_cc'; |
583f1c
|
124 |
$header = 'cc'; |
4e17e6
|
125 |
} |
T |
126 |
case 'bcc': |
|
127 |
if (!$fname) |
|
128 |
$fname = '_bcc'; |
|
129 |
|
317219
|
130 |
$allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'wrap', 'tabindex'); |
4e17e6
|
131 |
$field_type = 'textarea'; |
T |
132 |
break; |
|
133 |
|
|
134 |
case 'replyto': |
|
135 |
case 'reply-to': |
|
136 |
$fname = '_replyto'; |
317219
|
137 |
$allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); |
4e17e6
|
138 |
$field_type = 'textfield'; |
T |
139 |
break; |
|
140 |
|
|
141 |
} |
583f1c
|
142 |
|
4e17e6
|
143 |
|
597170
|
144 |
if ($fname && !empty($_POST[$fname])) |
01c86f
|
145 |
$fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); |
4e17e6
|
146 |
else if ($header && is_object($REPLY_MESSAGE['headers'])) |
T |
147 |
{ |
|
148 |
// get recipent address(es) out of the message headers |
|
149 |
if ($header=='to' && $REPLY_MESSAGE['headers']->replyto) |
|
150 |
$fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->replyto); |
58e360
|
151 |
|
4e17e6
|
152 |
else if ($header=='to' && $REPLY_MESSAGE['headers']->from) |
T |
153 |
$fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->from); |
58e360
|
154 |
|
583f1c
|
155 |
// add recipent of original message if reply to all |
T |
156 |
else if ($header=='cc' && $REPLY_MESSAGE['reply_all']) |
|
157 |
{ |
|
158 |
if ($IMAP->decode_header($REPLY_MESSAGE['headers']->to)) |
|
159 |
$fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->to); |
|
160 |
|
|
161 |
if ($IMAP->decode_header($REPLY_MESSAGE['headers']->cc)) |
|
162 |
{ |
|
163 |
if($fvalue) |
|
164 |
$fvalue .= ', '; |
|
165 |
|
|
166 |
$fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->cc); |
|
167 |
} |
|
168 |
} |
|
169 |
|
4e17e6
|
170 |
// split recipients and put them back together in a unique way |
583f1c
|
171 |
if (!empty($fvalue)) |
T |
172 |
{ |
|
173 |
$to_addresses = $IMAP->decode_address_list($fvalue); |
|
174 |
$fvalue = ''; |
|
175 |
foreach ($to_addresses as $addr_part) |
|
176 |
{ |
58e360
|
177 |
if (!in_array($addr_part['mailto'], $sa_recipients) && (!$REPLY_MESSAGE['FROM'] || !in_array($addr_part['mailto'], $REPLY_MESSAGE['FROM']))) |
583f1c
|
178 |
{ |
T |
179 |
$fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string']; |
|
180 |
$sa_recipients[] = $addr_part['mailto']; |
|
181 |
} |
|
182 |
} |
|
183 |
} |
4e17e6
|
184 |
} |
583f1c
|
185 |
|
4e17e6
|
186 |
|
T |
187 |
if ($fname && $field_type) |
|
188 |
{ |
|
189 |
// pass the following attributes to the form class |
|
190 |
$field_attrib = array('name' => $fname); |
|
191 |
foreach ($attrib as $attr => $value) |
|
192 |
if (in_array($attr, $allow_attrib)) |
|
193 |
$field_attrib[$attr] = $value; |
|
194 |
|
|
195 |
// create teaxtarea object |
|
196 |
$input = new $field_type($field_attrib); |
|
197 |
$out = $input->show($fvalue); |
|
198 |
} |
|
199 |
|
|
200 |
if ($form_start) |
|
201 |
$out = $form_start.$out; |
|
202 |
|
|
203 |
return $out; |
|
204 |
} |
|
205 |
|
|
206 |
|
1cded8
|
207 |
|
T |
208 |
function rcmail_compose_header_from($attrib) |
4e17e6
|
209 |
{ |
1cded8
|
210 |
global $IMAP, $REPLY_MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME; |
T |
211 |
|
|
212 |
// pass the following attributes to the form class |
|
213 |
$field_attrib = array('name' => '_from'); |
|
214 |
foreach ($attrib as $attr => $value) |
|
215 |
if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) |
|
216 |
$field_attrib[$attr] = $value; |
4e17e6
|
217 |
|
1cded8
|
218 |
// extract all recipients of the reply-message |
T |
219 |
$a_recipients = array(); |
|
220 |
if ($REPLY_MESSAGE && is_object($REPLY_MESSAGE['headers'])) |
|
221 |
{ |
58e360
|
222 |
$REPLY_MESSAGE['FROM'] = array(); |
T |
223 |
|
1cded8
|
224 |
$a_to = $IMAP->decode_address_list($REPLY_MESSAGE['headers']->to); |
T |
225 |
foreach ($a_to as $addr) |
|
226 |
{ |
|
227 |
if (!empty($addr['mailto'])) |
|
228 |
$a_recipients[] = $addr['mailto']; |
|
229 |
} |
4e17e6
|
230 |
|
1cded8
|
231 |
if (!empty($REPLY_MESSAGE['headers']->cc)) |
T |
232 |
{ |
|
233 |
$a_cc = $IMAP->decode_address_list($REPLY_MESSAGE['headers']->cc); |
|
234 |
foreach ($a_cc as $addr) |
|
235 |
{ |
|
236 |
if (!empty($addr['mailto'])) |
|
237 |
$a_recipients[] = $addr['mailto']; |
|
238 |
} |
|
239 |
} |
|
240 |
} |
4e17e6
|
241 |
|
1cded8
|
242 |
// get this user's identities |
T |
243 |
$sql_result = $DB->query("SELECT identity_id, name, email, signature |
|
244 |
FROM ".get_table_name('identities')." |
|
245 |
WHERE user_id=? |
|
246 |
AND del<>1 |
|
247 |
ORDER BY ".$DB->quoteIdentifier('standard')." DESC, name ASC", |
|
248 |
$_SESSION['user_id']); |
|
249 |
|
|
250 |
if ($DB->num_rows($sql_result)) |
|
251 |
{ |
|
252 |
$from_id = 0; |
|
253 |
$a_signatures = array(); |
|
254 |
|
|
255 |
$field_attrib['onchange'] = "$JS_OBJECT_NAME.change_identity(this)"; |
|
256 |
$select_from = new select($field_attrib); |
|
257 |
|
|
258 |
while ($sql_arr = $DB->fetch_assoc($sql_result)) |
|
259 |
{ |
|
260 |
$select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $sql_arr['identity_id']); |
4e17e6
|
261 |
|
1cded8
|
262 |
// add signature to array |
T |
263 |
if (!empty($sql_arr['signature'])) |
|
264 |
$a_signatures[$sql_arr['identity_id']] = $sql_arr['signature']; |
|
265 |
|
|
266 |
// set identity if it's one of the reply-message recipients |
|
267 |
if (in_array($sql_arr['email'], $a_recipients)) |
|
268 |
$from_id = $sql_arr['identity_id']; |
58e360
|
269 |
|
T |
270 |
if ($REPLY_MESSAGE && is_array($REPLY_MESSAGE['FROM'])) |
|
271 |
$REPLY_MESSAGE['FROM'][] = $sql_arr['email']; |
1cded8
|
272 |
} |
4e17e6
|
273 |
|
1cded8
|
274 |
// overwrite identity selection with post parameter |
T |
275 |
if (isset($_POST['_from'])) |
|
276 |
$from_id = $_POST['_from']; |
4e17e6
|
277 |
|
1cded8
|
278 |
$out = $select_from->show($from_id); |
T |
279 |
|
4e17e6
|
280 |
|
1cded8
|
281 |
// add signatures to client |
T |
282 |
$OUTPUT->add_script(sprintf("%s.set_env('signatures', %s);", $JS_OBJECT_NAME, array2js($a_signatures))); |
|
283 |
} |
|
284 |
else |
|
285 |
{ |
|
286 |
$input_from = new textfield($field_attrib); |
|
287 |
$out = $input_from->show($_POST['_from']); |
|
288 |
} |
|
289 |
|
|
290 |
if ($form_start) |
|
291 |
$out = $form_start.$out; |
4e17e6
|
292 |
|
1cded8
|
293 |
return $out; |
4e17e6
|
294 |
} |
T |
295 |
|
1cded8
|
296 |
|
4e17e6
|
297 |
|
T |
298 |
function rcmail_compose_body($attrib) |
|
299 |
{ |
dd53e2
|
300 |
global $CONFIG, $OUTPUT, $REPLY_MESSAGE, $FORWARD_MESSAGE; |
4e17e6
|
301 |
|
T |
302 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
303 |
unset($attrib['form']); |
dd53e2
|
304 |
|
T |
305 |
if (empty($attrib['id'])) |
|
306 |
$attrib['id'] = 'rcmComposeMessage'; |
4e17e6
|
307 |
|
T |
308 |
$attrib['name'] = '_message'; |
|
309 |
$textarea = new textarea($attrib); |
|
310 |
|
|
311 |
$body = ''; |
|
312 |
|
|
313 |
// use posted message body |
597170
|
314 |
if (!empty($_POST['_message'])) |
ea7c46
|
315 |
$body = get_input_value('_message', RCUBE_INPUT_POST, TRUE); |
4e17e6
|
316 |
|
T |
317 |
// compose reply-body |
|
318 |
else if (is_array($REPLY_MESSAGE['parts'])) |
|
319 |
{ |
|
320 |
$body = rcmail_first_text_part($REPLY_MESSAGE['parts']); |
|
321 |
if (strlen($body)) |
|
322 |
$body = rcmail_create_reply_body($body); |
|
323 |
} |
|
324 |
|
|
325 |
// forward message body inline |
|
326 |
else if (is_array($FORWARD_MESSAGE['parts'])) |
|
327 |
{ |
|
328 |
$body = rcmail_first_text_part($FORWARD_MESSAGE['parts']); |
|
329 |
if (strlen($body)) |
|
330 |
$body = rcmail_create_forward_body($body); |
|
331 |
} |
|
332 |
|
|
333 |
$out = $form_start ? "$form_start\n" : ''; |
|
334 |
$out .= $textarea->show($body); |
|
335 |
$out .= $form_end ? "\n$form_end" : ''; |
dd53e2
|
336 |
|
T |
337 |
// include GoogieSpell |
|
338 |
$OUTPUT->include_script('googiespell.js'); |
|
339 |
|
|
340 |
$OUTPUT->add_script(sprintf("var googie1 = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n". |
|
341 |
"googie1.decorateTextarea('%s');", |
|
342 |
$GLOBALS['COMM_PATH'], |
|
343 |
$attrib['id']), 'foot'); |
|
344 |
|
4e17e6
|
345 |
return $out; |
T |
346 |
} |
|
347 |
|
|
348 |
|
|
349 |
function rcmail_create_reply_body($body) |
|
350 |
{ |
|
351 |
global $IMAP, $REPLY_MESSAGE; |
|
352 |
|
|
353 |
// soft-wrap message first |
|
354 |
$body = wordwrap($body, 75); |
|
355 |
|
|
356 |
// split body into single lines |
|
357 |
$a_lines = preg_split('/\r?\n/', $body); |
|
358 |
|
|
359 |
// add > to each line |
|
360 |
for($n=0; $n<sizeof($a_lines); $n++) |
|
361 |
{ |
|
362 |
if (strpos($a_lines[$n], '>')===0) |
|
363 |
$a_lines[$n] = '>'.$a_lines[$n]; |
|
364 |
else |
|
365 |
$a_lines[$n] = '> '.$a_lines[$n]; |
|
366 |
} |
|
367 |
|
|
368 |
$body = join("\n", $a_lines); |
|
369 |
|
|
370 |
// add title line |
|
371 |
$pefix = sprintf("\n\n\nOn %s, %s wrote:\n", |
|
372 |
$REPLY_MESSAGE['headers']->date, |
|
373 |
$IMAP->decode_header($REPLY_MESSAGE['headers']->from)); |
1cded8
|
374 |
|
T |
375 |
|
|
376 |
// try to remove the signature |
749b07
|
377 |
if ($sp = strrpos($body, '-- ')) |
1cded8
|
378 |
{ |
T |
379 |
if ($body{$sp+3}==' ' || $body{$sp+3}=="\n" || $body{$sp+3}=="\r") |
|
380 |
$body = substr($body, 0, $sp-1); |
|
381 |
} |
4e17e6
|
382 |
|
T |
383 |
return $pefix.$body; |
|
384 |
} |
|
385 |
|
|
386 |
|
|
387 |
function rcmail_create_forward_body($body) |
|
388 |
{ |
|
389 |
global $IMAP, $FORWARD_MESSAGE; |
|
390 |
|
|
391 |
// soft-wrap message first |
|
392 |
$body = wordwrap($body, 80); |
|
393 |
|
|
394 |
$prefix = sprintf("\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", |
|
395 |
$FORWARD_MESSAGE['subject'], |
|
396 |
$FORWARD_MESSAGE['headers']->date, |
|
397 |
$IMAP->decode_header($FORWARD_MESSAGE['headers']->from), |
|
398 |
$IMAP->decode_header($FORWARD_MESSAGE['headers']->to)); |
|
399 |
|
597170
|
400 |
// add attachments |
T |
401 |
if (!isset($_SESSION['compose']['forward_attachments']) && is_array($FORWARD_MESSAGE['parts']) && sizeof($FORWARD_MESSAGE['parts'])>1) |
|
402 |
{ |
|
403 |
$temp_dir = rcmail_create_compose_tempdir(); |
|
404 |
|
|
405 |
if (!is_array($_SESSION['compose']['attachments'])) |
|
406 |
$_SESSION['compose']['attachments'] = array(); |
|
407 |
|
|
408 |
foreach ($FORWARD_MESSAGE['parts'] as $part) |
|
409 |
{ |
a43e0c
|
410 |
if ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || |
S |
411 |
(empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name']))) |
|
412 |
{ |
|
413 |
$tmp_path = tempnam($temp_dir, 'rcmAttmnt'); |
|
414 |
if ($fp = fopen($tmp_path, 'w')) |
|
415 |
{ |
|
416 |
fwrite($fp, $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding'])); |
|
417 |
fclose($fp); |
597170
|
418 |
|
a43e0c
|
419 |
if ($part->d_parameters['filename']) |
S |
420 |
$_SESSION['compose']['attachments'][] = array('name' => $part->d_parameters['filename'], |
|
421 |
'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, |
|
422 |
'path' => $tmp_path); |
|
423 |
|
|
424 |
else if ($part->ctype_parameters['name']) |
|
425 |
$_SESSION['compose']['attachments'][] = array('name' => $part->ctype_parameters['name'], |
|
426 |
'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, |
|
427 |
'path' => $tmp_path); |
f8d0a5
|
428 |
|
S |
429 |
else if ($part->headers['content-description']) |
|
430 |
$_SESSION['compose']['attachments'][] = array('name' => $part->headers['content-description'], |
|
431 |
'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, |
|
432 |
'path' => $tmp_path); |
a43e0c
|
433 |
} |
S |
434 |
} |
597170
|
435 |
} |
T |
436 |
|
|
437 |
$_SESSION['compose']['forward_attachments'] = TRUE; |
|
438 |
} |
|
439 |
|
4e17e6
|
440 |
return $prefix.$body; |
T |
441 |
} |
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
function rcmail_compose_subject($attrib) |
|
446 |
{ |
|
447 |
global $CONFIG, $REPLY_MESSAGE, $FORWARD_MESSAGE; |
|
448 |
|
|
449 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
450 |
unset($attrib['form']); |
|
451 |
|
|
452 |
$attrib['name'] = '_subject'; |
|
453 |
$textfield = new textfield($attrib); |
|
454 |
|
|
455 |
$subject = ''; |
|
456 |
|
|
457 |
// use subject from post |
597170
|
458 |
if (isset($_POST['_subject'])) |
01c86f
|
459 |
$subject = get_input_value('_subject', RCUBE_INPUT_POST, TRUE); |
4e17e6
|
460 |
|
T |
461 |
// create a reply-subject |
|
462 |
else if (isset($REPLY_MESSAGE['subject'])) |
520c36
|
463 |
{ |
09941e
|
464 |
if (eregi('^re:', $REPLY_MESSAGE['subject'])) |
520c36
|
465 |
$subject = $REPLY_MESSAGE['subject']; |
T |
466 |
else |
|
467 |
$subject = 'Re: '.$REPLY_MESSAGE['subject']; |
|
468 |
} |
4e17e6
|
469 |
|
T |
470 |
// create a forward-subject |
|
471 |
else if (isset($FORWARD_MESSAGE['subject'])) |
09941e
|
472 |
{ |
T |
473 |
if (eregi('^fwd:', $REPLY_MESSAGE['subject'])) |
|
474 |
$subject = $FORWARD_MESSAGE['subject']; |
|
475 |
else |
|
476 |
$subject = 'Fwd: '.$FORWARD_MESSAGE['subject']; |
|
477 |
} |
4e17e6
|
478 |
|
T |
479 |
|
|
480 |
$out = $form_start ? "$form_start\n" : ''; |
|
481 |
$out .= $textfield->show($subject); |
|
482 |
$out .= $form_end ? "\n$form_end" : ''; |
|
483 |
|
|
484 |
return $out; |
|
485 |
} |
|
486 |
|
|
487 |
|
|
488 |
function rcmail_compose_attachment_list($attrib) |
|
489 |
{ |
|
490 |
global $OUTPUT, $JS_OBJECT_NAME; |
|
491 |
|
|
492 |
// add ID if not given |
|
493 |
if (!$attrib['id']) |
|
494 |
$attrib['id'] = 'rcmAttachmentList'; |
|
495 |
|
|
496 |
// allow the following attributes to be added to the <ul> tag |
|
497 |
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style')); |
|
498 |
|
|
499 |
$out = '<ul'. $attrib_str . ">\n"; |
|
500 |
|
|
501 |
if (is_array($_SESSION['compose']['attachments'])) |
|
502 |
{ |
|
503 |
foreach ($_SESSION['compose']['attachments'] as $i => $a_prop) |
|
504 |
$out .= sprintf("<li>%s</li>\n", $a_prop['name']); |
|
505 |
} |
|
506 |
|
|
507 |
$OUTPUT->add_script(sprintf("%s.gui_object('attachmentlist', '%s');", $JS_OBJECT_NAME, $attrib['id'])); |
|
508 |
|
|
509 |
$out .= '</ul>'; |
|
510 |
return $out; |
|
511 |
} |
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
function rcmail_compose_attachment_form($attrib) |
|
516 |
{ |
|
517 |
global $OUTPUT, $JS_OBJECT_NAME, $SESS_HIDDEN_FIELD; |
|
518 |
|
|
519 |
// add ID if not given |
|
520 |
if (!$attrib['id']) |
|
521 |
$attrib['id'] = 'rcmUploadbox'; |
|
522 |
|
|
523 |
// allow the following attributes to be added to the <div> tag |
|
524 |
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style')); |
|
525 |
$input_field = rcmail_compose_attachment_field(array()); |
|
526 |
$label_send = rcube_label('upload'); |
|
527 |
$label_close = rcube_label('close'); |
|
528 |
|
|
529 |
$out = <<<EOF |
|
530 |
<div$attrib_str> |
|
531 |
<form action="./" method="post" enctype="multipart/form-data"> |
|
532 |
$SESS_HIDDEN_FIELD |
|
533 |
$input_field<br /> |
|
534 |
<input type="button" value="$label_close" class="button" onclick="document.getElementById('$attrib[id]').style.visibility='hidden'" /> |
|
535 |
<input type="button" value="$label_send" class="button" onclick="$JS_OBJECT_NAME.command('send-attachment', this.form)" /> |
|
536 |
</form> |
|
537 |
</div> |
|
538 |
EOF; |
|
539 |
|
|
540 |
|
|
541 |
$OUTPUT->add_script(sprintf("%s.gui_object('uploadbox', '%s');", $JS_OBJECT_NAME, $attrib['id'])); |
|
542 |
return $out; |
|
543 |
} |
|
544 |
|
|
545 |
|
|
546 |
function rcmail_compose_attachment_field($attrib) |
|
547 |
{ |
|
548 |
// allow the following attributes to be added to the <input> tag |
|
549 |
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'size')); |
|
550 |
|
|
551 |
$out = '<input type="file" name="_attachments[]"'. $attrib_str . " />"; |
|
552 |
return $out; |
|
553 |
} |
|
554 |
|
|
555 |
|
|
556 |
function rcmail_priority_selector($attrib) |
|
557 |
{ |
|
558 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
559 |
unset($attrib['form']); |
|
560 |
|
|
561 |
$attrib['name'] = '_priority'; |
|
562 |
$selector = new select($attrib); |
|
563 |
|
|
564 |
$selector->add(array(rcube_label('lowest'), |
|
565 |
rcube_label('low'), |
|
566 |
rcube_label('normal'), |
|
567 |
rcube_label('high'), |
|
568 |
rcube_label('highest')), |
7902df
|
569 |
array(5, 4, 0, 2, 1)); |
4e17e6
|
570 |
|
597170
|
571 |
$sel = isset($_POST['_priority']) ? $_POST['_priority'] : 0; |
4e17e6
|
572 |
|
T |
573 |
$out = $form_start ? "$form_start\n" : ''; |
|
574 |
$out .= $selector->show($sel); |
|
575 |
$out .= $form_end ? "\n$form_end" : ''; |
|
576 |
|
|
577 |
return $out; |
|
578 |
} |
|
579 |
|
|
580 |
|
620439
|
581 |
function rcmail_receipt_checkbox($attrib) |
T |
582 |
{ |
|
583 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
584 |
unset($attrib['form']); |
|
585 |
|
|
586 |
$attrib['name'] = '_receipt'; |
|
587 |
$checkbox = new checkbox(array('name' => '_receipt', 'id' => 'receipt', 'value' => 1)); |
|
588 |
|
|
589 |
$out = $form_start ? "$form_start\n" : ''; |
|
590 |
$out .= $checkbox->show(0); |
|
591 |
$out .= $form_end ? "\n$form_end" : ''; |
|
592 |
|
|
593 |
return $out; |
|
594 |
} |
|
595 |
|
|
596 |
|
4e17e6
|
597 |
function get_form_tags($attrib) |
T |
598 |
{ |
|
599 |
global $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $MESSAGE_FORM, $SESS_HIDDEN_FIELD; |
|
600 |
|
|
601 |
$form_start = ''; |
|
602 |
if (!strlen($MESSAGE_FORM)) |
|
603 |
{ |
|
604 |
$hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task'])); |
|
605 |
$hiddenfields->add(array('name' => '_action', 'value' => 'send')); |
|
606 |
|
597170
|
607 |
$form_start = empty($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; |
4e17e6
|
608 |
$form_start .= "\n$SESS_HIDDEN_FIELD\n"; |
T |
609 |
$form_start .= $hiddenfields->show(); |
|
610 |
} |
|
611 |
|
|
612 |
$form_end = (strlen($MESSAGE_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; |
597170
|
613 |
$form_name = !empty($attrib['form']) ? $attrib['form'] : 'form'; |
4e17e6
|
614 |
|
T |
615 |
if (!strlen($MESSAGE_FORM)) |
|
616 |
$OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('messageform', '$form_name');"); |
|
617 |
|
|
618 |
$MESSAGE_FORM = $form_name; |
|
619 |
|
|
620 |
return array($form_start, $form_end); |
|
621 |
} |
|
622 |
|
|
623 |
|
|
624 |
function format_email_recipient($email, $name='') |
|
625 |
{ |
|
626 |
if ($name && $name != $email) |
|
627 |
return sprintf('%s <%s>', strpos($name, ",") ? '"'.$name.'"' : $name, $email); |
|
628 |
else |
|
629 |
return $email; |
|
630 |
} |
|
631 |
|
|
632 |
|
fd8c50
|
633 |
function rcmail_charset_pulldown($selected='ISO-8859-1') |
T |
634 |
{ |
|
635 |
$select = new select(); |
|
636 |
|
|
637 |
|
|
638 |
return $select->show($selected); |
|
639 |
} |
|
640 |
|
|
641 |
|
4e17e6
|
642 |
/****** get contacts for this user and add them to client scripts ********/ |
T |
643 |
|
d7cb77
|
644 |
$sql_result = $DB->query("SELECT name, email |
S |
645 |
FROM ".get_table_name('contacts')." WHERE user_id=? |
1cded8
|
646 |
AND del<>1",$_SESSION['user_id']); |
4e17e6
|
647 |
|
T |
648 |
if ($DB->num_rows($sql_result)) |
|
649 |
{ |
|
650 |
$a_contacts = array(); |
|
651 |
while ($sql_arr = $DB->fetch_assoc($sql_result)) |
|
652 |
if ($sql_arr['email']) |
|
653 |
$a_contacts[] = format_email_recipient($sql_arr['email'], rep_specialchars_output($sql_arr['name'], 'js')); |
|
654 |
|
|
655 |
$OUTPUT->add_script(sprintf("$JS_OBJECT_NAME.set_env('contacts', %s);", array2js($a_contacts))); |
|
656 |
} |
|
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
parse_template('compose'); |
|
662 |
?> |