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 | |
8fa58e
|
8 |
| Copyright (C) 2005-2008, 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); |
|
26 |
|
4e17e6
|
27 |
|
a894ba
|
28 |
// remove an attachment |
197601
|
29 |
if ($RCMAIL->action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_POST['_file'], $regs)) |
4315b0
|
30 |
{ |
aade7b
|
31 |
$id = $regs[1]; |
T |
32 |
if (is_array($_SESSION['compose']['attachments'][$id])) |
4315b0
|
33 |
{ |
aade7b
|
34 |
@unlink($_SESSION['compose']['attachments'][$id]['path']); |
ccd63c
|
35 |
unset($_SESSION['compose']['attachments'][$id]); |
f11541
|
36 |
$OUTPUT->command('remove_from_attachment_list', "rcmfile$id"); |
T |
37 |
$OUTPUT->send(); |
a894ba
|
38 |
} |
2f746d
|
39 |
exit; |
4315b0
|
40 |
} |
aade7b
|
41 |
|
197601
|
42 |
if ($RCMAIL->action=='display-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs)) |
4315b0
|
43 |
{ |
S |
44 |
$id = $regs[1]; |
|
45 |
if (is_array($_SESSION['compose']['attachments'][$id])) |
|
46 |
{ |
|
47 |
$apath = $_SESSION['compose']['attachments'][$id]['path']; |
|
48 |
header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']); |
|
49 |
header('Content-Length: ' . filesize($apath)); |
|
50 |
readfile($apath); |
|
51 |
} |
|
52 |
exit; |
|
53 |
} |
f0f98f
|
54 |
|
S |
55 |
$MESSAGE_FORM = NULL; |
8d4bcd
|
56 |
$MESSAGE = NULL; |
f0f98f
|
57 |
|
86df15
|
58 |
// Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or |
T |
59 |
// if a compose-ID is given (i.e. when the compose step is opened in a new window/tab). |
|
60 |
// Since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old |
f0f98f
|
61 |
// compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear |
S |
62 |
|
86df15
|
63 |
if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_value('_id', RCUBE_INPUT_GET)) |
4315b0
|
64 |
{ |
86df15
|
65 |
rcmail_compose_cleanup(); |
c719f3
|
66 |
$_SESSION['compose'] = array('id' => uniqid(rand()), 'param' => array_map('strip_tags', $_GET)); |
T |
67 |
|
5f314d
|
68 |
// process values like "mailto:foo@bar.com?subject=new+message&cc=another" |
T |
69 |
if ($_SESSION['compose']['param']['_to']) { |
|
70 |
$mailto = explode('?', $_SESSION['compose']['param']['_to']); |
|
71 |
if (count($mailto) > 1) { |
|
72 |
$_SESSION['compose']['param']['_to'] = $mailto[0]; |
|
73 |
parse_str($mailto[1], $query); |
|
74 |
foreach ($query as $f => $val) |
|
75 |
$_SESSION['compose']['param']["_$f"] = $val; |
|
76 |
} |
|
77 |
} |
|
78 |
|
c719f3
|
79 |
// redirect to a unique URL with all parameters stored in session |
T |
80 |
$OUTPUT->redirect(array('_action' => 'compose', '_id' => $_SESSION['compose']['id'])); |
4315b0
|
81 |
} |
4e17e6
|
82 |
|
10a699
|
83 |
// add some labels to client |
a0109c
|
84 |
rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', 'converting'); |
10a699
|
85 |
|
d656f1
|
86 |
// add config parameter to client script |
f11541
|
87 |
$OUTPUT->set_env('draft_autosave', !empty($CONFIG['drafts_mbox']) ? $CONFIG['draft_autosave'] : 0); |
d656f1
|
88 |
|
10a699
|
89 |
|
8d4bcd
|
90 |
// get reference message and set compose mode |
c719f3
|
91 |
if ($msg_uid = $_SESSION['compose']['param']['_reply_uid']) |
8d4bcd
|
92 |
$compose_mode = RCUBE_COMPOSE_REPLY; |
c719f3
|
93 |
else if ($msg_uid = $_SESSION['compose']['param']['_forward_uid']) |
8d4bcd
|
94 |
$compose_mode = RCUBE_COMPOSE_FORWARD; |
c719f3
|
95 |
else if ($msg_uid = $_SESSION['compose']['param']['_draft_uid']) |
8d4bcd
|
96 |
$compose_mode = RCUBE_COMPOSE_DRAFT; |
T |
97 |
|
|
98 |
if (!empty($msg_uid)) |
4315b0
|
99 |
{ |
4e17e6
|
100 |
// similar as in program/steps/mail/show.inc |
8fa58e
|
101 |
$MESSAGE = new rcube_message($msg_uid); |
17b5fb
|
102 |
|
8fa58e
|
103 |
if (!empty($MESSAGE->headers->charset)) |
T |
104 |
$IMAP->set_charset($MESSAGE->headers->charset); |
17b5fb
|
105 |
|
8d4bcd
|
106 |
if ($compose_mode == RCUBE_COMPOSE_REPLY) |
4315b0
|
107 |
{ |
8d4bcd
|
108 |
$_SESSION['compose']['reply_uid'] = $msg_uid; |
8fa58e
|
109 |
$_SESSION['compose']['reply_msgid'] = $MESSAGE->headers->messageID; |
T |
110 |
$_SESSION['compose']['references'] = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID); |
583f1c
|
111 |
|
c719f3
|
112 |
if (!empty($_SESSION['compose']['param']['_all'])) |
8fa58e
|
113 |
$MESSAGE->reply_all = 1; |
4e17e6
|
114 |
} |
95fd38
|
115 |
else if ($compose_mode == RCUBE_COMPOSE_DRAFT) |
A |
116 |
{ |
|
117 |
if($MESSAGE->headers->in_reply_to) |
|
118 |
{ |
687009
|
119 |
// TODO: how to get reply_uid/forward_uid value, maybe we must set X-Reply-UID/X-Forward-UID |
95fd38
|
120 |
// $_SESSION['compose']['reply_uid'] = ? |
687009
|
121 |
// $_SESSION['compose']['forward_uid'] = ? |
95fd38
|
122 |
$_SESSION['compose']['reply_msgid'] = '<'.$MESSAGE->headers->in_reply_to.'>'; |
A |
123 |
} |
|
124 |
$_SESSION['compose']['references'] = $MESSAGE->headers->references; |
|
125 |
} |
4315b0
|
126 |
else if ($compose_mode == RCUBE_COMPOSE_FORWARD) |
S |
127 |
{ |
|
128 |
$_SESSION['compose']['forward_uid'] = $msg_uid; |
|
129 |
} |
|
130 |
} |
4e17e6
|
131 |
|
T |
132 |
/****** compose mode functions ********/ |
|
133 |
|
|
134 |
|
|
135 |
function rcmail_compose_headers($attrib) |
4315b0
|
136 |
{ |
8d4bcd
|
137 |
global $IMAP, $MESSAGE, $DB, $compose_mode; |
583f1c
|
138 |
static $sa_recipients = array(); |
4e17e6
|
139 |
|
T |
140 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
141 |
|
|
142 |
$out = ''; |
|
143 |
$part = strtolower($attrib['part']); |
|
144 |
|
|
145 |
switch ($part) |
4315b0
|
146 |
{ |
4e17e6
|
147 |
case 'from': |
1cded8
|
148 |
return rcmail_compose_header_from($attrib); |
4e17e6
|
149 |
|
T |
150 |
case 'to': |
|
151 |
$fname = '_to'; |
|
152 |
$header = 'to'; |
f11541
|
153 |
|
T |
154 |
// we have a set of recipients stored is session |
c719f3
|
155 |
if (($mailto_id = $_SESSION['compose']['param']['_mailto']) && $_SESSION['mailto'][$mailto_id]) |
fde466
|
156 |
$fvalue = urldecode($_SESSION['mailto'][$mailto_id]); |
5f314d
|
157 |
|
4e17e6
|
158 |
case 'cc': |
T |
159 |
if (!$fname) |
4315b0
|
160 |
{ |
4e17e6
|
161 |
$fname = '_cc'; |
583f1c
|
162 |
$header = 'cc'; |
4315b0
|
163 |
} |
4e17e6
|
164 |
case 'bcc': |
T |
165 |
if (!$fname) |
4315b0
|
166 |
{ |
4e17e6
|
167 |
$fname = '_bcc'; |
462799
|
168 |
$header = 'bcc'; |
4315b0
|
169 |
} |
4e17e6
|
170 |
|
bd4209
|
171 |
$allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'tabindex'); |
47124c
|
172 |
$field_type = 'html_textarea'; |
4e17e6
|
173 |
break; |
T |
174 |
|
|
175 |
case 'replyto': |
|
176 |
case 'reply-to': |
|
177 |
$fname = '_replyto'; |
317219
|
178 |
$allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); |
47124c
|
179 |
$field_type = 'html_inputfield'; |
5f314d
|
180 |
break; |
4315b0
|
181 |
} |
1966c5
|
182 |
|
597170
|
183 |
if ($fname && !empty($_POST[$fname])) |
01c86f
|
184 |
$fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); |
5f314d
|
185 |
else if ($fname && !$fvalue && !empty($_SESSION['compose']['param'][$fname])) |
T |
186 |
$fvalue = $_SESSION['compose']['param'][$fname]; |
8d4bcd
|
187 |
|
T |
188 |
else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) |
4315b0
|
189 |
{ |
4e17e6
|
190 |
// get recipent address(es) out of the message headers |
8fa58e
|
191 |
if ($header=='to' && !empty($MESSAGE->headers->replyto)) |
T |
192 |
$fvalue = $MESSAGE->headers->replyto; |
58e360
|
193 |
|
8fa58e
|
194 |
else if ($header=='to' && !empty($MESSAGE->headers->from)) |
T |
195 |
$fvalue = $MESSAGE->headers->from; |
58e360
|
196 |
|
583f1c
|
197 |
// add recipent of original message if reply to all |
8fa58e
|
198 |
else if ($header=='cc' && !empty($MESSAGE->reply_all)) |
4315b0
|
199 |
{ |
8fa58e
|
200 |
if ($v = $MESSAGE->headers->to) |
8d4bcd
|
201 |
$fvalue .= $v; |
583f1c
|
202 |
|
8fa58e
|
203 |
if ($v = $MESSAGE->headers->cc) |
8d4bcd
|
204 |
$fvalue .= (!empty($fvalue) ? ', ' : '') . $v; |
4315b0
|
205 |
} |
583f1c
|
206 |
|
4e17e6
|
207 |
// split recipients and put them back together in a unique way |
583f1c
|
208 |
if (!empty($fvalue)) |
4315b0
|
209 |
{ |
583f1c
|
210 |
$to_addresses = $IMAP->decode_address_list($fvalue); |
T |
211 |
$fvalue = ''; |
51f55b
|
212 |
|
583f1c
|
213 |
foreach ($to_addresses as $addr_part) |
4315b0
|
214 |
{ |
51f55b
|
215 |
if (!empty($addr_part['mailto']) |
A |
216 |
&& !in_array($addr_part['mailto'], $sa_recipients) |
|
217 |
&& (!$MESSAGE->compose_from |
|
218 |
|| !in_array($addr_part['mailto'], $MESSAGE->compose_from) |
|
219 |
|| count($to_addresses)==1)) // allow reply to yourself |
4315b0
|
220 |
{ |
583f1c
|
221 |
$fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string']; |
T |
222 |
$sa_recipients[] = $addr_part['mailto']; |
|
223 |
} |
|
224 |
} |
4e17e6
|
225 |
} |
4315b0
|
226 |
} |
8d4bcd
|
227 |
else if ($header && $compose_mode == RCUBE_COMPOSE_DRAFT) |
4315b0
|
228 |
{ |
1966c5
|
229 |
// get drafted headers |
8fa58e
|
230 |
if ($header=='to' && !empty($MESSAGE->headers->to)) |
T |
231 |
$fvalue = $MESSAGE->get_header('to'); |
1966c5
|
232 |
|
8fa58e
|
233 |
if ($header=='cc' && !empty($MESSAGE->headers->cc)) |
T |
234 |
$fvalue = $MESSAGE->get_header('cc'); |
1966c5
|
235 |
|
8fa58e
|
236 |
if ($header=='bcc' && !empty($MESSAGE->headers->bcc)) |
T |
237 |
$fvalue = $MESSAGE->get_header('bcc'); |
4315b0
|
238 |
} |
583f1c
|
239 |
|
4e17e6
|
240 |
|
T |
241 |
if ($fname && $field_type) |
4315b0
|
242 |
{ |
4e17e6
|
243 |
// pass the following attributes to the form class |
491a6e
|
244 |
$field_attrib = array('name' => $fname, 'spellcheck' => 'false'); |
4e17e6
|
245 |
foreach ($attrib as $attr => $value) |
T |
246 |
if (in_array($attr, $allow_attrib)) |
|
247 |
$field_attrib[$attr] = $value; |
|
248 |
|
|
249 |
// create teaxtarea object |
|
250 |
$input = new $field_type($field_attrib); |
47124c
|
251 |
$out = $input->show($fvalue); |
4315b0
|
252 |
} |
4e17e6
|
253 |
|
T |
254 |
if ($form_start) |
|
255 |
$out = $form_start.$out; |
1966c5
|
256 |
|
4e17e6
|
257 |
return $out; |
4315b0
|
258 |
} |
4e17e6
|
259 |
|
T |
260 |
|
1cded8
|
261 |
|
T |
262 |
function rcmail_compose_header_from($attrib) |
4315b0
|
263 |
{ |
8fa58e
|
264 |
global $IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $compose_mode; |
1cded8
|
265 |
|
T |
266 |
// pass the following attributes to the form class |
|
267 |
$field_attrib = array('name' => '_from'); |
|
268 |
foreach ($attrib as $attr => $value) |
|
269 |
if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) |
|
270 |
$field_attrib[$attr] = $value; |
4e17e6
|
271 |
|
1cded8
|
272 |
// extract all recipients of the reply-message |
T |
273 |
$a_recipients = array(); |
8fa58e
|
274 |
if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers)) |
4315b0
|
275 |
{ |
8fa58e
|
276 |
$MESSAGE->compose_from = array(); |
58e360
|
277 |
|
8fa58e
|
278 |
$a_to = $IMAP->decode_address_list($MESSAGE->headers->to); |
1cded8
|
279 |
foreach ($a_to as $addr) |
4315b0
|
280 |
{ |
1cded8
|
281 |
if (!empty($addr['mailto'])) |
T |
282 |
$a_recipients[] = $addr['mailto']; |
4315b0
|
283 |
} |
4e17e6
|
284 |
|
8fa58e
|
285 |
if (!empty($MESSAGE->headers->cc)) |
4315b0
|
286 |
{ |
8fa58e
|
287 |
$a_cc = $IMAP->decode_address_list($MESSAGE->headers->cc); |
1cded8
|
288 |
foreach ($a_cc as $addr) |
4315b0
|
289 |
{ |
1cded8
|
290 |
if (!empty($addr['mailto'])) |
T |
291 |
$a_recipients[] = $addr['mailto']; |
|
292 |
} |
|
293 |
} |
4315b0
|
294 |
} |
4e17e6
|
295 |
|
1cded8
|
296 |
// get this user's identities |
fba1f5
|
297 |
$sql_result = $USER->list_identities(); |
a0109c
|
298 |
|
1cded8
|
299 |
if ($DB->num_rows($sql_result)) |
4315b0
|
300 |
{ |
1cded8
|
301 |
$from_id = 0; |
T |
302 |
$a_signatures = array(); |
a0109c
|
303 |
|
f11541
|
304 |
$field_attrib['onchange'] = JS_OBJECT_NAME.".change_identity(this)"; |
47124c
|
305 |
$select_from = new html_select($field_attrib); |
a0109c
|
306 |
|
1cded8
|
307 |
while ($sql_arr = $DB->fetch_assoc($sql_result)) |
4315b0
|
308 |
{ |
a0109c
|
309 |
$identity_id = $sql_arr['identity_id']; |
S |
310 |
$select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $identity_id); |
4e17e6
|
311 |
|
1cded8
|
312 |
// add signature to array |
T |
313 |
if (!empty($sql_arr['signature'])) |
4315b0
|
314 |
{ |
a0109c
|
315 |
$a_signatures[$identity_id]['text'] = $sql_arr['signature']; |
S |
316 |
$a_signatures[$identity_id]['is_html'] = ($sql_arr['html_signature'] == 1) ? true : false; |
dd792e
|
317 |
if ($a_signatures[$identity_id]['is_html']) |
4315b0
|
318 |
{ |
dd792e
|
319 |
$h2t = new html2text($a_signatures[$identity_id]['text'], false, false); |
S |
320 |
$plainTextPart = $h2t->get_text(); |
e7d37a
|
321 |
$a_signatures[$identity_id]['plain_text'] = trim(html_entity_decode($plainTextPart, ENT_NOQUOTES, 'UTF-8')); |
a0109c
|
322 |
} |
4315b0
|
323 |
} |
a0109c
|
324 |
|
1cded8
|
325 |
// set identity if it's one of the reply-message recipients |
T |
326 |
if (in_array($sql_arr['email'], $a_recipients)) |
|
327 |
$from_id = $sql_arr['identity_id']; |
a0109c
|
328 |
|
8fa58e
|
329 |
if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE->compose_from)) |
T |
330 |
$MESSAGE->compose_from[] = $sql_arr['email']; |
1966c5
|
331 |
|
8fa58e
|
332 |
if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE->headers->from, $sql_arr['email'])) |
1966c5
|
333 |
$from_id = $sql_arr['identity_id']; |
4315b0
|
334 |
} |
4e17e6
|
335 |
|
1cded8
|
336 |
// overwrite identity selection with post parameter |
T |
337 |
if (isset($_POST['_from'])) |
8d4bcd
|
338 |
$from_id = get_input_value('_from', RCUBE_INPUT_POST); |
4e17e6
|
339 |
|
1cded8
|
340 |
$out = $select_from->show($from_id); |
4e17e6
|
341 |
|
1cded8
|
342 |
// add signatures to client |
f11541
|
343 |
$OUTPUT->set_env('signatures', $a_signatures); |
4315b0
|
344 |
} |
1cded8
|
345 |
else |
4315b0
|
346 |
{ |
47124c
|
347 |
$input_from = new html_inputfield($field_attrib); |
1cded8
|
348 |
$out = $input_from->show($_POST['_from']); |
4315b0
|
349 |
} |
1966c5
|
350 |
|
1cded8
|
351 |
if ($form_start) |
T |
352 |
$out = $form_start.$out; |
4e17e6
|
353 |
|
1cded8
|
354 |
return $out; |
4315b0
|
355 |
} |
4e17e6
|
356 |
|
T |
357 |
|
|
358 |
function rcmail_compose_body($attrib) |
4315b0
|
359 |
{ |
197601
|
360 |
global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode; |
4e17e6
|
361 |
|
T |
362 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
363 |
unset($attrib['form']); |
dd53e2
|
364 |
|
T |
365 |
if (empty($attrib['id'])) |
|
366 |
$attrib['id'] = 'rcmComposeMessage'; |
a0109c
|
367 |
|
4e17e6
|
368 |
$attrib['name'] = '_message'; |
a0109c
|
369 |
|
S |
370 |
if ($CONFIG['htmleditor']) |
|
371 |
$isHtml = true; |
|
372 |
else |
|
373 |
$isHtml = false; |
4e17e6
|
374 |
|
T |
375 |
$body = ''; |
a0109c
|
376 |
|
4e17e6
|
377 |
// use posted message body |
597170
|
378 |
if (!empty($_POST['_message'])) |
8fa58e
|
379 |
{ |
T |
380 |
$body = get_input_value('_message', RCUBE_INPUT_POST, true); |
|
381 |
} |
|
382 |
else if ($compose_mode) |
|
383 |
{ |
|
384 |
if ($isHtml && $MESSAGE->has_html_part()) |
a0109c
|
385 |
{ |
8fa58e
|
386 |
$body = $MESSAGE->first_html_part(); |
a0109c
|
387 |
$isHtml = true; |
4e17e6
|
388 |
} |
8fa58e
|
389 |
else |
4e17e6
|
390 |
{ |
8fa58e
|
391 |
$body = $MESSAGE->first_text_part(); |
a0109c
|
392 |
$isHtml = false; |
4e17e6
|
393 |
} |
8fa58e
|
394 |
|
T |
395 |
// compose reply-body |
|
396 |
if ($compose_mode == RCUBE_COMPOSE_REPLY) |
|
397 |
$body = rcmail_create_reply_body($body, $isHtml); |
|
398 |
// forward message body inline |
|
399 |
else if ($compose_mode == RCUBE_COMPOSE_FORWARD) |
|
400 |
$body = rcmail_create_forward_body($body, $isHtml); |
|
401 |
// load draft message body |
|
402 |
else if ($compose_mode == RCUBE_COMPOSE_DRAFT) |
|
403 |
$body = rcmail_create_draft_body($body, $isHtml); |
2f746d
|
404 |
|
A |
405 |
if ($isHtml) { |
|
406 |
// replace cid with href in inline images links |
|
407 |
foreach ((array)$_SESSION['compose']['attachments'] as $pid => $attachment) { |
|
408 |
if ($attachment['content_id']) { |
|
409 |
$body = str_replace('cid:'. $attachment['content_id'], |
|
410 |
$OUTPUT->app->comm_path.'&_action=display-attachment&_file=rcmfile'.$pid, $body); |
|
411 |
} |
|
412 |
} |
|
413 |
} |
5f314d
|
414 |
} |
T |
415 |
else if (!empty($_SESSION['compose']['param']['_body'])) |
|
416 |
{ |
|
417 |
$body = $_SESSION['compose']['param']['_body']; |
8fa58e
|
418 |
} |
a0109c
|
419 |
|
326f3d
|
420 |
$lang = $tinylang = strtolower(substr($_SESSION['language'], 0, 2)); |
T |
421 |
if (!file_exists(INSTALL_PATH . 'program/js/tiny_mce/langs/'.$tinylang.'.js')) |
8e5def
|
422 |
$tinylang = 'en'; |
S |
423 |
|
a0109c
|
424 |
$OUTPUT->include_script('tiny_mce/tiny_mce.js'); |
S |
425 |
$OUTPUT->include_script("editor.js"); |
4ca10b
|
426 |
$OUTPUT->add_script('rcmail_editor_init("$__skin_path", "'.JQ($tinylang).'", '.intval($CONFIG['enable_spellcheck']).');'); |
a0109c
|
427 |
|
4e17e6
|
428 |
$out = $form_start ? "$form_start\n" : ''; |
1966c5
|
429 |
|
8fa58e
|
430 |
$saveid = new html_hiddenfield(array('name' => '_draft_saveid', 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), "", $MESSAGE->headers->messageID) : '')); |
f0f98f
|
431 |
$out .= $saveid->show(); |
1966c5
|
432 |
|
47124c
|
433 |
$drafttoggle = new html_hiddenfield(array('name' => '_draft', 'value' => 'yes')); |
1966c5
|
434 |
$out .= $drafttoggle->show(); |
S |
435 |
|
47124c
|
436 |
$msgtype = new html_hiddenfield(array('name' => '_is_html', 'value' => ($isHtml?"1":"0"))); |
a0109c
|
437 |
$out .= $msgtype->show(); |
S |
438 |
|
2f746d
|
439 |
// If desired, set this textarea to be editable by TinyMCE |
A |
440 |
if ($isHtml) $attrib['class'] = 'mce_editor'; |
47124c
|
441 |
$textarea = new html_textarea($attrib); |
4e17e6
|
442 |
$out .= $textarea->show($body); |
T |
443 |
$out .= $form_end ? "\n$form_end" : ''; |
a0109c
|
444 |
|
dd53e2
|
445 |
// include GoogieSpell |
4ca10b
|
446 |
if (!empty($CONFIG['enable_spellcheck'])) { |
326f3d
|
447 |
$spellcheck_langs = (array)$RCMAIL->config->get('spellcheck_languages', array('da'=>'Dansk', 'de'=>'Deutsch', 'en' => 'English', 'es'=>'Español', 'fr'=>'Français', 'it'=>'Italiano', 'nl'=>'Nederlands', 'pl'=>'Polski', 'pt'=>'Português', 'fi'=>'Suomi', 'sv'=>'Svenska')); |
T |
448 |
if (!$spellcheck_langs[$lang]) |
|
449 |
$lang = 'en'; |
|
450 |
|
|
451 |
$editor_lang_set = array(); |
|
452 |
foreach ($spellcheck_langs as $key => $name) { |
|
453 |
$editor_lang_set[] = ($key == $lang ? '+' : '') . JQ($name).'='.JQ($key); |
4ca10b
|
454 |
} |
996066
|
455 |
|
ed5d29
|
456 |
$OUTPUT->include_script('googiespell.js'); |
2bca6e
|
457 |
$OUTPUT->add_script(sprintf( |
T |
458 |
"var googie = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n". |
|
459 |
"googie.lang_chck_spell = \"%s\";\n". |
|
460 |
"googie.lang_rsm_edt = \"%s\";\n". |
|
461 |
"googie.lang_close = \"%s\";\n". |
|
462 |
"googie.lang_revert = \"%s\";\n". |
326f3d
|
463 |
"googie.lang_no_error_found = \"%s\";\n". |
T |
464 |
"googie.setLanguages(%s);\n". |
2bca6e
|
465 |
"googie.setCurrentLanguage('%s');\n". |
T |
466 |
"googie.decorateTextarea('%s');\n". |
|
467 |
"%s.set_env('spellcheck', googie);", |
197601
|
468 |
$RCMAIL->comm_path, |
2bca6e
|
469 |
JQ(Q(rcube_label('checkspelling'))), |
T |
470 |
JQ(Q(rcube_label('resumeediting'))), |
|
471 |
JQ(Q(rcube_label('close'))), |
|
472 |
JQ(Q(rcube_label('revertto'))), |
|
473 |
JQ(Q(rcube_label('nospellerrors'))), |
326f3d
|
474 |
json_serialize($spellcheck_langs), |
T |
475 |
$lang, |
2bca6e
|
476 |
$attrib['id'], |
f11541
|
477 |
JS_OBJECT_NAME), 'foot'); |
ed5d29
|
478 |
|
T |
479 |
rcube_add_label('checking'); |
326f3d
|
480 |
$OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set)); |
4ca10b
|
481 |
} |
f0f98f
|
482 |
|
027af3
|
483 |
$out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>'; |
41fa0b
|
484 |
|
4e17e6
|
485 |
return $out; |
4315b0
|
486 |
} |
4e17e6
|
487 |
|
T |
488 |
|
a0109c
|
489 |
function rcmail_create_reply_body($body, $bodyIsHtml) |
4315b0
|
490 |
{ |
8c0b9e
|
491 |
global $IMAP, $MESSAGE, $OUTPUT; |
4e17e6
|
492 |
|
a0109c
|
493 |
if (! $bodyIsHtml) |
S |
494 |
{ |
|
495 |
// soft-wrap message first |
ccd63c
|
496 |
$body = rcmail_wrap_quoted($body, 75); |
4e17e6
|
497 |
|
a0109c
|
498 |
// split body into single lines |
S |
499 |
$a_lines = preg_split('/\r?\n/', $body); |
4e17e6
|
500 |
|
a0109c
|
501 |
// add > to each line |
S |
502 |
for($n=0; $n<sizeof($a_lines); $n++) |
4315b0
|
503 |
{ |
a0109c
|
504 |
if (strpos($a_lines[$n], '>')===0) |
S |
505 |
$a_lines[$n] = '>'.$a_lines[$n]; |
|
506 |
else |
|
507 |
$a_lines[$n] = '> '.$a_lines[$n]; |
4315b0
|
508 |
} |
4e17e6
|
509 |
|
a0109c
|
510 |
$body = join("\n", $a_lines); |
4e17e6
|
511 |
|
a0109c
|
512 |
// add title line |
2f746d
|
513 |
$prefix = sprintf("On %s, %s wrote:\n", |
8fa58e
|
514 |
$MESSAGE->headers->date, |
T |
515 |
$MESSAGE->get_header('from')); |
1cded8
|
516 |
|
a0109c
|
517 |
// try to remove the signature |
a63e10
|
518 |
if ($sp = strrpos($body, '-- ')) |
a0109c
|
519 |
{ |
S |
520 |
if ($body{$sp+3}==' ' || $body{$sp+3}=="\n" || $body{$sp+3}=="\r") |
|
521 |
$body = substr($body, 0, $sp-1); |
|
522 |
} |
|
523 |
$suffix = ''; |
|
524 |
} |
|
525 |
else |
|
526 |
{ |
2f746d
|
527 |
$prefix = sprintf("On %s, %s wrote:<br />\n", |
8fa58e
|
528 |
$MESSAGE->headers->date, |
8c0b9e
|
529 |
htmlspecialchars(Q($MESSAGE->get_header('from'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset(), true)); |
8fa58e
|
530 |
$prefix .= '<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">'; |
4315b0
|
531 |
$suffix = "</blockquote>"; |
2f746d
|
532 |
|
A |
533 |
rcmail_write_inline_attachments($MESSAGE); |
a0109c
|
534 |
} |
S |
535 |
|
|
536 |
return $prefix.$body.$suffix; |
4315b0
|
537 |
} |
4e17e6
|
538 |
|
T |
539 |
|
a0109c
|
540 |
function rcmail_create_forward_body($body, $bodyIsHtml) |
4315b0
|
541 |
{ |
8c0b9e
|
542 |
global $IMAP, $MESSAGE, $OUTPUT; |
4e17e6
|
543 |
|
8fa58e
|
544 |
if (!$bodyIsHtml) |
a0109c
|
545 |
{ |
5758b9
|
546 |
$prefix = "\n\n\n-------- Original Message --------\n"; |
A |
547 |
$prefix .= 'Subject: ' . $MESSAGE->subject . "\n"; |
|
548 |
$prefix .= 'Date: ' . $MESSAGE->headers->date . "\n"; |
|
549 |
$prefix .= 'From: ' . $MESSAGE->get_header('from') . "\n"; |
|
550 |
$prefix .= 'To: ' . $MESSAGE->get_header('to') . "\n"; |
|
551 |
if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from) |
|
552 |
$prefix .= 'Reply-To: ' . $MESSAGE->get_header('replyto') . "\n"; |
|
553 |
$prefix .= "\n"; |
a0109c
|
554 |
} |
S |
555 |
else |
|
556 |
{ |
4315b0
|
557 |
$prefix = sprintf( |
8fa58e
|
558 |
"<br><br>-------- Original Message --------" . |
a0109c
|
559 |
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody>" . |
S |
560 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Subject: </th><td>%s</td></tr>" . |
|
561 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Date: </th><td>%s</td></tr>" . |
|
562 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">From: </th><td>%s</td></tr>" . |
5758b9
|
563 |
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">To: </th><td>%s</td></tr>", |
8fa58e
|
564 |
Q($MESSAGE->subject), |
T |
565 |
Q($MESSAGE->headers->date), |
8c0b9e
|
566 |
htmlspecialchars(Q($MESSAGE->get_header('from'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset(), true), |
5758b9
|
567 |
htmlspecialchars(Q($MESSAGE->get_header('to'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset(), true)); |
A |
568 |
|
|
569 |
if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from) |
|
570 |
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Reply-To: </th><td>%s</td></tr>", |
|
571 |
htmlspecialchars(Q($MESSAGE->get_header('replyto'), 'replace'), ENT_COMPAT, $OUTPUT->get_charset(), true)); |
|
572 |
|
|
573 |
$prefix .= "</tbody></table><br>"; |
a0109c
|
574 |
} |
S |
575 |
|
597170
|
576 |
// add attachments |
8fa58e
|
577 |
if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE->mime_parts)) |
1bc48e
|
578 |
rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); |
5cc4b1
|
579 |
|
4e17e6
|
580 |
return $prefix.$body; |
4315b0
|
581 |
} |
4e17e6
|
582 |
|
8d4bcd
|
583 |
|
a0109c
|
584 |
function rcmail_create_draft_body($body, $bodyIsHtml) |
4315b0
|
585 |
{ |
8fa58e
|
586 |
global $MESSAGE; |
8ecb0e
|
587 |
|
T |
588 |
/** |
|
589 |
* add attachments |
8fa58e
|
590 |
* sizeof($MESSAGE->mime_parts can be 1 - e.g. attachment, but no text! |
8ecb0e
|
591 |
*/ |
T |
592 |
if (!isset($_SESSION['compose']['forward_attachments']) |
8fa58e
|
593 |
&& is_array($MESSAGE->mime_parts) |
T |
594 |
&& count($MESSAGE->mime_parts) > 0) |
1bc48e
|
595 |
rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); |
1966c5
|
596 |
|
S |
597 |
return $body; |
4315b0
|
598 |
} |
8d4bcd
|
599 |
|
T |
600 |
|
1bc48e
|
601 |
function rcmail_write_compose_attachments(&$message, $bodyIsHtml) |
4315b0
|
602 |
{ |
8fa58e
|
603 |
foreach ((array)$message->mime_parts as $pid => $part) |
4315b0
|
604 |
{ |
1bc48e
|
605 |
if (($part->ctype_primary != 'message' || !$bodyIsHtml) && |
2f746d
|
606 |
($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] |
A |
607 |
|| (empty($part->disposition) && $part->filename))) |
4315b0
|
608 |
{ |
2f746d
|
609 |
if ($attachment = rcmail_save_attachment($message, $pid)) |
A |
610 |
$_SESSION['compose']['attachments'][] = $attachment; |
8d4bcd
|
611 |
} |
4315b0
|
612 |
} |
8d4bcd
|
613 |
|
8fa58e
|
614 |
$_SESSION['compose']['forward_attachments'] = true; |
4315b0
|
615 |
} |
4e17e6
|
616 |
|
T |
617 |
|
2f746d
|
618 |
function rcmail_write_inline_attachments(&$message) |
A |
619 |
{ |
|
620 |
foreach ((array)$message->mime_parts as $pid => $part) |
|
621 |
{ |
|
622 |
if ($part->content_id && $part->filename) |
|
623 |
{ |
|
624 |
if ($attachment = rcmail_save_attachment($message, $pid)) |
|
625 |
$_SESSION['compose']['attachments'][] = $attachment; |
|
626 |
} |
|
627 |
} |
|
628 |
} |
|
629 |
|
|
630 |
function rcmail_save_attachment(&$message, $pid) |
|
631 |
{ |
|
632 |
global $RCMAIL; |
|
633 |
|
|
634 |
$temp_dir = unslashify($RCMAIL->config->get('temp_dir')); |
|
635 |
$tmp_path = tempnam($temp_dir, 'rcmAttmnt'); |
|
636 |
$part = $message->mime_parts[$pid]; |
|
637 |
|
|
638 |
if ($fp = fopen($tmp_path, 'w')) |
|
639 |
{ |
|
640 |
$message->get_part_content($pid, $fp); |
|
641 |
fclose($fp); |
|
642 |
|
|
643 |
return array( |
|
644 |
'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, |
|
645 |
'name' => $part->filename, |
|
646 |
'path' => $tmp_path, |
|
647 |
'content_id' => $part->content_id |
|
648 |
); |
|
649 |
} |
|
650 |
} |
|
651 |
|
|
652 |
|
4e17e6
|
653 |
function rcmail_compose_subject($attrib) |
4315b0
|
654 |
{ |
8fa58e
|
655 |
global $MESSAGE, $compose_mode; |
4e17e6
|
656 |
|
T |
657 |
list($form_start, $form_end) = get_form_tags($attrib); |
|
658 |
unset($attrib['form']); |
|
659 |
|
|
660 |
$attrib['name'] = '_subject'; |
491a6e
|
661 |
$attrib['spellcheck'] = 'true'; |
47124c
|
662 |
$textfield = new html_inputfield($attrib); |
4e17e6
|
663 |
|
T |
664 |
$subject = ''; |
|
665 |
|
|
666 |
// use subject from post |
5f314d
|
667 |
if (isset($_POST['_subject'])) { |
01c86f
|
668 |
$subject = get_input_value('_subject', RCUBE_INPUT_POST, TRUE); |
5f314d
|
669 |
} |
4e17e6
|
670 |
// create a reply-subject |
5f314d
|
671 |
else if ($compose_mode == RCUBE_COMPOSE_REPLY) { |
8fa58e
|
672 |
if (eregi('^re:', $MESSAGE->subject)) |
T |
673 |
$subject = $MESSAGE->subject; |
520c36
|
674 |
else |
8fa58e
|
675 |
$subject = 'Re: '.$MESSAGE->subject; |
4315b0
|
676 |
} |
4e17e6
|
677 |
// create a forward-subject |
5f314d
|
678 |
else if ($compose_mode == RCUBE_COMPOSE_FORWARD) { |
8fa58e
|
679 |
if (eregi('^fwd:', $MESSAGE->subject)) |
T |
680 |
$subject = $MESSAGE->subject; |
09941e
|
681 |
else |
8fa58e
|
682 |
$subject = 'Fwd: '.$MESSAGE->subject; |
4315b0
|
683 |
} |
1966c5
|
684 |
// creeate a draft-subject |
5f314d
|
685 |
else if ($compose_mode == RCUBE_COMPOSE_DRAFT) { |
8fa58e
|
686 |
$subject = $MESSAGE->subject; |
5f314d
|
687 |
} |
T |
688 |
else if (!empty($_SESSION['compose']['param']['_subject'])) { |
|
689 |
$subject = $_SESSION['compose']['param']['_subject']; |
|
690 |
} |
4e17e6
|
691 |
|
T |
692 |
$out = $form_start ? "$form_start\n" : ''; |
|
693 |
$out .= $textfield->show($subject); |
|
694 |
$out .= $form_end ? "\n$form_end" : ''; |
|
695 |
|
|
696 |
return $out; |
4315b0
|
697 |
} |
4e17e6
|
698 |
|
T |
699 |
|
|
700 |
function rcmail_compose_attachment_list($attrib) |
4315b0
|
701 |
{ |
f11541
|
702 |
global $OUTPUT, $CONFIG; |
4e17e6
|
703 |
|
T |
704 |
// add ID if not given |
|
705 |
if (!$attrib['id']) |
|
706 |
$attrib['id'] = 'rcmAttachmentList'; |
|
707 |
|
8fa58e
|
708 |
$out = "\n"; |
4e17e6
|
709 |
|
T |
710 |
if (is_array($_SESSION['compose']['attachments'])) |
4315b0
|
711 |
{ |
a894ba
|
712 |
if ($attrib['deleteicon']) |
8fa58e
|
713 |
$button = html::img(array( |
T |
714 |
'src' => $CONFIG['skin_path'] . $attrib['deleteicon'], |
|
715 |
'alt' => rcube_label('delete'), |
|
716 |
'style' => "border:0;padding-right:2px;vertical-align:middle")); |
a894ba
|
717 |
else |
8fa58e
|
718 |
$button = Q(rcube_label('delete')); |
a894ba
|
719 |
|
aade7b
|
720 |
foreach ($_SESSION['compose']['attachments'] as $id => $a_prop) |
6d5dba
|
721 |
{ |
T |
722 |
if (empty($a_prop)) |
|
723 |
continue; |
|
724 |
|
8fa58e
|
725 |
$out .= html::tag('li', array('id' => "rcmfile".$id), |
T |
726 |
html::a(array( |
|
727 |
'href' => "#delete", |
|
728 |
'title' => rcube_label('delete'), |
59200c
|
729 |
'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%d', this)", JS_OBJECT_NAME, $id)), |
8fa58e
|
730 |
$button) . Q($a_prop['name'])); |
6d5dba
|
731 |
} |
4315b0
|
732 |
} |
4e17e6
|
733 |
|
f11541
|
734 |
$OUTPUT->add_gui_object('attachmentlist', $attrib['id']); |
4e17e6
|
735 |
|
8fa58e
|
736 |
return html::tag('ul', $attrib, $out, html::$common_attrib); |
4315b0
|
737 |
} |
4e17e6
|
738 |
|
T |
739 |
|
|
740 |
function rcmail_compose_attachment_form($attrib) |
4315b0
|
741 |
{ |
197601
|
742 |
global $OUTPUT; |
4e17e6
|
743 |
|
T |
744 |
// add ID if not given |
|
745 |
if (!$attrib['id']) |
|
746 |
$attrib['id'] = 'rcmUploadbox'; |
|
747 |
|
885ebb
|
748 |
$button = new html_inputfield(array('type' => 'button', 'class' => 'button')); |
4e17e6
|
749 |
|
197601
|
750 |
$out = html::div($attrib, |
885ebb
|
751 |
$OUTPUT->form_tag(array('name' => 'form', 'method' => 'post', 'enctype' => 'multipart/form-data')) . |
8beee1
|
752 |
html::div(null, rcmail_compose_attachment_field(array())) . |
T |
753 |
html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))))) . |
|
754 |
html::div('buttons', |
|
755 |
$button->show(rcube_label('close'), array('onclick' => "document.getElementById('$attrib[id]').style.visibility='hidden'")) . ' ' . |
|
756 |
$button->show(rcube_label('upload'), array('onclick' => JS_OBJECT_NAME . ".command('send-attachment', this.form)"))) |
197601
|
757 |
); |
T |
758 |
|
4e17e6
|
759 |
|
f11541
|
760 |
$OUTPUT->add_gui_object('uploadbox', $attrib['id']); |
4e17e6
|
761 |
return $out; |
4315b0
|
762 |
} |
4e17e6
|
763 |
|
T |
764 |
|
|
765 |
function rcmail_compose_attachment_field($attrib) |
4315b0
|
766 |
{ |
4e17e6
|
767 |
// allow the following attributes to be added to the <input> tag |
T |
768 |
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'size')); |
|
769 |
|
|
770 |
$out = '<input type="file" name="_attachments[]"'. $attrib_str . " />"; |
|
771 |
return $out; |
4315b0
|
772 |
} |
4e17e6
|
773 |
|
66e2bf
|
774 |
|
4e17e6
|
775 |
function rcmail_priority_selector($attrib) |
4315b0
|
776 |
{ |
ff08ee
|
777 |
global $MESSAGE; |
T |
778 |
|
4e17e6
|
779 |
list($form_start, $form_end) = get_form_tags($attrib); |
T |
780 |
unset($attrib['form']); |
|
781 |
|
|
782 |
$attrib['name'] = '_priority'; |
47124c
|
783 |
$selector = new html_select($attrib); |
4e17e6
|
784 |
|
T |
785 |
$selector->add(array(rcube_label('lowest'), |
|
786 |
rcube_label('low'), |
|
787 |
rcube_label('normal'), |
|
788 |
rcube_label('high'), |
|
789 |
rcube_label('highest')), |
7902df
|
790 |
array(5, 4, 0, 2, 1)); |
4e17e6
|
791 |
|
8fa58e
|
792 |
$sel = isset($_POST['_priority']) ? $_POST['_priority'] : intval($MESSAGE->headers->priority); |
4e17e6
|
793 |
|
T |
794 |
$out = $form_start ? "$form_start\n" : ''; |
|
795 |
$out .= $selector->show($sel); |
|
796 |
$out .= $form_end ? "\n$form_end" : ''; |
|
797 |
|
|
798 |
return $out; |
4315b0
|
799 |
} |
4e17e6
|
800 |
|
T |
801 |
|
620439
|
802 |
function rcmail_receipt_checkbox($attrib) |
4315b0
|
803 |
{ |
e47aad
|
804 |
global $MESSAGE, $compose_mode; |
ff08ee
|
805 |
|
620439
|
806 |
list($form_start, $form_end) = get_form_tags($attrib); |
T |
807 |
unset($attrib['form']); |
66e2bf
|
808 |
|
T |
809 |
if (!isset($attrib['id'])) |
|
810 |
$attrib['id'] = 'receipt'; |
620439
|
811 |
|
T |
812 |
$attrib['name'] = '_receipt'; |
66e2bf
|
813 |
$attrib['value'] = '1'; |
47124c
|
814 |
$checkbox = new html_checkbox($attrib); |
620439
|
815 |
|
T |
816 |
$out = $form_start ? "$form_start\n" : ''; |
e47aad
|
817 |
$out .= $checkbox->show( |
A |
818 |
$compose_mode == RCUBE_COMPOSE_DRAFT && $MESSAGE->headers->mdn_to ? 1 : 0); |
620439
|
819 |
$out .= $form_end ? "\n$form_end" : ''; |
T |
820 |
|
|
821 |
return $out; |
4315b0
|
822 |
} |
620439
|
823 |
|
T |
824 |
|
a0109c
|
825 |
function rcmail_editor_selector($attrib) |
S |
826 |
{ |
|
827 |
global $CONFIG, $MESSAGE, $compose_mode; |
|
828 |
|
|
829 |
$choices = array( |
6b1fc0
|
830 |
'html' => 'htmltoggle', |
S |
831 |
'plain' => 'plaintoggle' |
a0109c
|
832 |
); |
S |
833 |
|
8fa58e
|
834 |
// determine whether HTML or plain text should be checked |
T |
835 |
$useHtml = $CONFIG['htmleditor'] ? true : false; |
a0109c
|
836 |
|
8fa58e
|
837 |
if ($compose_mode) |
T |
838 |
$useHtml = ($useHtml && $MESSAGE->has_html_part()); |
d9344f
|
839 |
|
a0109c
|
840 |
$selector = ''; |
8fa58e
|
841 |
$chosenvalue = $useHtml ? 'html' : 'plain'; |
T |
842 |
$radio = new html_radiobutton(array('name' => '_editorSelect', 'onclick' => 'return rcmail_toggle_editor(this)')); |
a0109c
|
843 |
foreach ($choices as $value => $text) |
4315b0
|
844 |
{ |
6b1fc0
|
845 |
$attrib['id'] = '_' . $value; |
d9344f
|
846 |
$attrib['value'] = $value; |
8fa58e
|
847 |
$selector .= $radio->show($chosenvalue, $attrib) . html::label($attrib['id'], Q(rcube_label($text))); |
4315b0
|
848 |
} |
a0109c
|
849 |
|
S |
850 |
return $selector; |
|
851 |
} |
|
852 |
|
|
853 |
|
faf876
|
854 |
function rcmail_store_target_selection($attrib) |
T |
855 |
{ |
|
856 |
$attrib['name'] = '_store_target'; |
a81be1
|
857 |
$select = rcmail_mailbox_select(array_merge($attrib, array('noselection' => '- '.rcube_label('dontsave').' -'))); |
faf876
|
858 |
return $select->show(rcmail::get_instance()->config->get('sent_mbox'), $attrib); |
T |
859 |
} |
|
860 |
|
|
861 |
|
4e17e6
|
862 |
function get_form_tags($attrib) |
4315b0
|
863 |
{ |
197601
|
864 |
global $RCMAIL, $MESSAGE_FORM; |
4e17e6
|
865 |
|
T |
866 |
$form_start = ''; |
|
867 |
if (!strlen($MESSAGE_FORM)) |
4315b0
|
868 |
{ |
197601
|
869 |
$hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task)); |
4e17e6
|
870 |
$hiddenfields->add(array('name' => '_action', 'value' => 'send')); |
1966c5
|
871 |
|
197601
|
872 |
$form_start = empty($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : ''; |
4e17e6
|
873 |
$form_start .= $hiddenfields->show(); |
4315b0
|
874 |
} |
4e17e6
|
875 |
|
T |
876 |
$form_end = (strlen($MESSAGE_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; |
597170
|
877 |
$form_name = !empty($attrib['form']) ? $attrib['form'] : 'form'; |
4e17e6
|
878 |
|
T |
879 |
if (!strlen($MESSAGE_FORM)) |
197601
|
880 |
$RCMAIL->output->add_gui_object('messageform', $form_name); |
4e17e6
|
881 |
|
T |
882 |
$MESSAGE_FORM = $form_name; |
|
883 |
|
47124c
|
884 |
return array($form_start, $form_end); |
4315b0
|
885 |
} |
4e17e6
|
886 |
|
T |
887 |
|
f11541
|
888 |
// register UI objects |
T |
889 |
$OUTPUT->add_handlers(array( |
|
890 |
'composeheaders' => 'rcmail_compose_headers', |
|
891 |
'composesubject' => 'rcmail_compose_subject', |
|
892 |
'composebody' => 'rcmail_compose_body', |
|
893 |
'composeattachmentlist' => 'rcmail_compose_attachment_list', |
|
894 |
'composeattachmentform' => 'rcmail_compose_attachment_form', |
|
895 |
'composeattachment' => 'rcmail_compose_attachment_field', |
|
896 |
'priorityselector' => 'rcmail_priority_selector', |
|
897 |
'editorselector' => 'rcmail_editor_selector', |
|
898 |
'receiptcheckbox' => 'rcmail_receipt_checkbox', |
faf876
|
899 |
'storetarget' => 'rcmail_store_target_selection', |
f11541
|
900 |
)); |
fd8c50
|
901 |
|
4e17e6
|
902 |
/****** get contacts for this user and add them to client scripts ********/ |
f11541
|
903 |
|
fba1f5
|
904 |
$CONTACTS = new rcube_contacts($DB, $USER->ID); |
f11541
|
905 |
$CONTACTS->set_pagesize(1000); |
c658ed
|
906 |
|
T |
907 |
$a_contacts = array(); |
4e17e6
|
908 |
|
f11541
|
909 |
if ($result = $CONTACTS->list_records()) |
148e7b
|
910 |
{ |
f11541
|
911 |
while ($sql_arr = $result->iterate()) |
4e17e6
|
912 |
if ($sql_arr['email']) |
0c6f4b
|
913 |
$a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); |
148e7b
|
914 |
} |
b67bcc
|
915 |
if (!empty($CONFIG['ldap_public']) && is_array($CONFIG['ldap_public'])) |
148e7b
|
916 |
{ |
d75921
|
917 |
/* LDAP autocompletion */ |
T |
918 |
foreach ($CONFIG['ldap_public'] as $ldapserv_config) |
c658ed
|
919 |
{ |
a0530a
|
920 |
if ($ldapserv_config['fuzzy_search'] != 1 || |
A |
921 |
$ldapserv_config['global_search'] != 1) |
d75921
|
922 |
{ |
T |
923 |
continue; |
a0530a
|
924 |
} |
d75921
|
925 |
|
T |
926 |
$LDAP = new rcube_ldap($ldapserv_config); |
|
927 |
$LDAP->connect(); |
|
928 |
$LDAP->set_pagesize(1000); |
|
929 |
|
|
930 |
$results = $LDAP->search($ldapserv_config['mail_field'], ""); |
|
931 |
|
|
932 |
for ($i = 0; $i < $results->count; $i++) |
|
933 |
{ |
|
934 |
if ($results->records[$i]['email'] != '') |
|
935 |
{ |
|
936 |
$email = $results->records[$i]['email']; |
|
937 |
$name = $results->records[$i]['name']; |
c658ed
|
938 |
|
0c6f4b
|
939 |
$a_contacts[] = format_email_recipient($email, $name); |
d75921
|
940 |
} |
T |
941 |
} |
|
942 |
$LDAP->close(); |
|
943 |
} |
148e7b
|
944 |
} |
T |
945 |
if ($a_contacts) |
|
946 |
{ |
c658ed
|
947 |
$OUTPUT->set_env('contacts', $a_contacts); |
a0530a
|
948 |
} |
A |
949 |
|
47124c
|
950 |
$OUTPUT->send('compose'); |
a0530a
|
951 |
|
d9344f
|
952 |
?> |