annotate program/steps/mail/compose.inc @ 0:4681f974d28b

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:52:31 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /**
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4 +-----------------------------------------------------------------------+
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 | program/steps/mail/compose.inc |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
7 | This file is part of the Roundcube Webmail client |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 | Copyright (C) 2005-2016, The Roundcube Dev Team |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 | Licensed under the GNU General Public License version 3 or |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 | any later version with exceptions for skins & plugins. |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12 | See the README file for a full license statement. |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 | PURPOSE: |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 | Compose a new mail message with all headers and attachments |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 +-----------------------------------------------------------------------+
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 +-----------------------------------------------------------------------+
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 */
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 // define constants for message compose mode
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 define('RCUBE_COMPOSE_REPLY', 'reply');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 define('RCUBE_COMPOSE_FORWARD', 'forward');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 define('RCUBE_COMPOSE_DRAFT', 'draft');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 define('RCUBE_COMPOSE_EDIT', 'edit');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 $MESSAGE_FORM = null;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 $COMPOSE_ID = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GET);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 $COMPOSE = null;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 if ($COMPOSE_ID && $_SESSION['compose_data_'.$COMPOSE_ID])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 $COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 // give replicated session storage some time to synchronize
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 $retries = 0;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 while ($COMPOSE_ID && !is_array($COMPOSE) && $RCMAIL->db->is_replicated() && $retries++ < 5) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38 usleep(500000);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39 $RCMAIL->session->reload();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 if ($_SESSION['compose_data_'.$COMPOSE_ID]) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 $COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 // Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 // if a compose-ID is given (i.e. when the compose step is opened in a new window/tab).
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47 if (!is_array($COMPOSE)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
48 // Infinite redirect prevention in case of broken session (#1487028)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
49 if ($COMPOSE_ID) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50 // if we know the message with specified ID was already sent
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 // we can ignore the error and compose a new message (#1490009)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52 if ($COMPOSE_ID != $_SESSION['last_compose_session']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53 rcube::raise_error(array('code' => 450), false, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
56
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57 $COMPOSE_ID = uniqid(mt_rand());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 $params = rcube_utils::request2param(rcube_utils::INPUT_GET, 'task|action', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60 $_SESSION['compose_data_'.$COMPOSE_ID] = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61 'id' => $COMPOSE_ID,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62 'param' => $params,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 'mailbox' => $params['mbox'] ?: $RCMAIL->storage->get_folder(),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 $COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
66 rcmail_process_compose_params($COMPOSE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
67
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 // check if folder for saving sent messages exists and is subscribed (#1486802)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 if ($sent_folder = $COMPOSE['param']['sent_mbox']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70 rcmail_check_sent_folder($sent_folder, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
71 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
72
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73 // redirect to a unique URL with all parameters stored in session
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
74 $OUTPUT->redirect(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
75 '_action' => 'compose',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
76 '_id' => $COMPOSE['id'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77 '_search' => $_REQUEST['_search'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
78 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
79 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
81
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82 // add some labels to client
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'cancel',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84 'nobodywarning', 'notsentwarning', 'notuploadedwarning', 'savingmessage', 'sendingmessage',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85 'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
86 'fileuploaderror', 'sendmessage', 'newresponse', 'responsename', 'responsetext', 'save',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 'selectimportfile', 'messageissent', 'loadingdata', 'nopubkeyfor', 'nopubkeyforsender',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 'encryptnoattachments','encryptedsendialog','searchpubkeyservers', 'importpubkeys',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
90 'encryptpubkeysfound', 'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
91 'keyrevoked', 'keyimportsuccess', 'keyservererror', 'attaching', 'namex', 'attachmentrename',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 'disclosedrecipwarning', 'disclosedreciptitle', 'bccinstead', 'nosubjecttitle');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94 $OUTPUT->set_pagetitle($RCMAIL->gettext('compose'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 $OUTPUT->set_env('compose_id', $COMPOSE['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97 $OUTPUT->set_env('session_id', session_id());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98 $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
99 $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100 $OUTPUT->set_env('sig_below', $RCMAIL->config->get('sig_below'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102 $OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 $OUTPUT->set_env('max_disclosed_recipients', (int) $RCMAIL->config->get('max_disclosed_recipients', 5));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104 $OUTPUT->set_env('is_sent', false);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 $OUTPUT->set_env('mimetypes', rcmail_supported_mimetypes());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 $drafts_mbox = $RCMAIL->config->get('drafts_mbox');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 $config_show_sig = $RCMAIL->config->get('show_sig', 1);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110 // add config parameters to client script
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111 if (strlen($drafts_mbox)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112 $OUTPUT->set_env('drafts_mailbox', $drafts_mbox);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113 $OUTPUT->set_env('draft_autosave', $RCMAIL->config->get('draft_autosave'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116 // default font for HTML editor
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 $font = rcmail::font_defs($RCMAIL->config->get('default_font'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118 if ($font && !is_array($font)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119 $OUTPUT->set_env('default_font', $font);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 // default font size for HTML editor
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123 if ($font_size = $RCMAIL->config->get('default_font_size')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
124 $OUTPUT->set_env('default_font_size', $font_size);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
125 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
126
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127 // get reference message and set compose mode
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 if ($msg_uid = $COMPOSE['param']['draft_uid']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 $compose_mode = RCUBE_COMPOSE_DRAFT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 $OUTPUT->set_env('draft_id', $msg_uid);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 $RCMAIL->storage->set_folder($drafts_mbox);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
133 else if ($msg_uid = $COMPOSE['param']['reply_uid']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
134 $compose_mode = RCUBE_COMPOSE_REPLY;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136 else if ($msg_uid = $COMPOSE['param']['forward_uid']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137 $compose_mode = RCUBE_COMPOSE_FORWARD;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 $COMPOSE['forward_uid'] = $msg_uid;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 $COMPOSE['as_attachment'] = !empty($COMPOSE['param']['attachment']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141 else if ($msg_uid = $COMPOSE['param']['uid']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142 $compose_mode = RCUBE_COMPOSE_EDIT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 if ($compose_mode) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 $COMPOSE['mode'] = $compose_mode;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 $OUTPUT->set_env('compose_mode', $compose_mode);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
148 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
149
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 if ($compose_mode == RCUBE_COMPOSE_EDIT || $compose_mode == RCUBE_COMPOSE_DRAFT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 // don't add signature in draft/edit mode, we'll also not remove the old-one
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 // but only on page display, later we should be able to change identity/sig (#1489229)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 if ($config_show_sig == 1 || $config_show_sig == 2) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154 $OUTPUT->set_env('show_sig_later', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 else if ($config_show_sig == 1)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 $OUTPUT->set_env('show_sig', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159 else if ($config_show_sig == 2 && empty($compose_mode))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 $OUTPUT->set_env('show_sig', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161 else if ($config_show_sig == 3 && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 $OUTPUT->set_env('show_sig', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 // set line length for body wrapping
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 $LINE_LENGTH = $RCMAIL->config->get('line_length', 72);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 if (!empty($msg_uid) && empty($COMPOSE['as_attachment'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 $mbox_name = $RCMAIL->storage->get_folder();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 // set format before rcube_message construction
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 // use the same format as for the message view
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 if (isset($_SESSION['msg_formats'][$mbox_name.':'.$msg_uid])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173 $RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$msg_uid]);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176 $prefer_html = $RCMAIL->config->get('prefer_html') || $RCMAIL->config->get('htmleditor')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177 || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179 $RCMAIL->config->set('prefer_html', $prefer_html);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182 $MESSAGE = new rcube_message($msg_uid);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 // make sure message is marked as read
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 if ($MESSAGE->headers && $MESSAGE->context === null && empty($MESSAGE->headers->flags['SEEN'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186 $RCMAIL->storage->set_flag($msg_uid, 'SEEN');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 if (!empty($MESSAGE->headers->charset)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 $RCMAIL->storage->set_charset($MESSAGE->headers->charset);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 if (!$MESSAGE->headers) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 // error
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 else if ($compose_mode == RCUBE_COMPOSE_FORWARD || $compose_mode == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 if ($compose_mode == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 $COMPOSE['reply_uid'] = $MESSAGE->context === null ? $msg_uid : null;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 if (!empty($COMPOSE['param']['all'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 $MESSAGE->reply_all = $COMPOSE['param']['all'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 $COMPOSE['forward_uid'] = $msg_uid;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 $COMPOSE['reply_msgid'] = $MESSAGE->headers->messageID;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 $COMPOSE['references'] = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 // Save the sent message in the same folder of the message being replied to
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 if ($RCMAIL->config->get('reply_same_folder') && ($sent_folder = $COMPOSE['mailbox'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 && rcmail_check_sent_folder($sent_folder, false)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215 $COMPOSE['param']['sent_mbox'] = $sent_folder;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
216 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 if ($compose_mode == RCUBE_COMPOSE_DRAFT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220 if ($draft_info = $MESSAGE->headers->get('x-draft-info')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
221 // get reply_uid/forward_uid to flag the original message when sending
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
222 $info = rcmail_draftinfo_decode($draft_info);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
223
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
224 if ($info['type'] == 'reply')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 $COMPOSE['reply_uid'] = $info['uid'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 else if ($info['type'] == 'forward')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
227 $COMPOSE['forward_uid'] = $info['uid'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
228
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229 $COMPOSE['mailbox'] = $info['folder'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
230
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
231 // Save the sent message in the same folder of the message being replied to
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232 if ($RCMAIL->config->get('reply_same_folder') && ($sent_folder = $info['folder'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 && rcmail_check_sent_folder($sent_folder, false)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 $COMPOSE['param']['sent_mbox'] = $sent_folder;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
237 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
238
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 $COMPOSE['param']['message-id'] = $MESSAGE->headers->get('message-id');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 // use message UID as draft_id
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242 $OUTPUT->set_env('draft_id', $msg_uid);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
245 if ($in_reply_to = $MESSAGE->headers->get('in-reply-to')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246 $COMPOSE['reply_msgid'] = '<' . $in_reply_to . '>';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249 $COMPOSE['references'] = $MESSAGE->headers->references;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 $MESSAGE = new stdClass();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 // apply mailto: URL parameters
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 if (!empty($COMPOSE['param']['in-reply-to'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257 $COMPOSE['reply_msgid'] = '<' . $COMPOSE['param']['in-reply-to'] . '>';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 if (!empty($COMPOSE['param']['references'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261 $COMPOSE['references'] = $COMPOSE['param']['references'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 if (!empty($COMPOSE['reply_msgid'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
266 $OUTPUT->set_env('reply_msgid', $COMPOSE['reply_msgid']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
267 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269 $MESSAGE->compose = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 // get user's identities
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272 $MESSAGE->identities = $RCMAIL->user->list_identities(null, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
273
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
274 // Set From field value
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
275 if (!empty($_POST['_from'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
276 $MESSAGE->compose['from'] = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 else if (!empty($COMPOSE['param']['from'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 $MESSAGE->compose['from'] = $COMPOSE['param']['from'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281 else if (count($MESSAGE->identities)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 $ident = rcmail_identity_select($MESSAGE, $MESSAGE->identities, $compose_mode);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
284 $MESSAGE->compose['from'] = $ident['identity_id'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
285 $MESSAGE->compose['ident'] = $ident;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 // process $MESSAGE body/attachments, set $MESSAGE_BODY/$HTML_MODE vars and some session data
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289 $MESSAGE_BODY = rcmail_prepare_message_body();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
290
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
291 $OUTPUT->include_script('publickey.js');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
292
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293 // register UI objects
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 $OUTPUT->add_handlers(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
295 'composeheaders' => 'rcmail_compose_headers',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296 'composesubject' => 'rcmail_compose_subject',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 'composebody' => 'rcmail_compose_body',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 'composeattachmentlist' => 'rcmail_compose_attachment_list',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 'composeattachmentform' => 'rcmail_compose_attachment_form',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
300 'composeattachment' => 'rcmail_compose_attachment_field',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 'filedroparea' => 'compose_file_drop_area',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 'priorityselector' => 'rcmail_priority_selector',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 'editorselector' => 'rcmail_editor_selector',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 'receiptcheckbox' => 'rcmail_mdn_checkbox', // deprecated
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305 'mdncheckbox' => 'rcmail_mdn_checkbox',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 'dsncheckbox' => 'rcmail_dsn_checkbox',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 'storetarget' => 'rcmail_store_target_selection',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308 'addressbooks' => 'rcmail_addressbook_list',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 'addresslist' => 'rcmail_contacts_list',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 'responseslist' => 'rcmail_compose_responses_list',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
313 $OUTPUT->send('compose');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
314
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316 /****** compose mode functions ********/
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 // process compose request parameters
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 function rcmail_process_compose_params(&$COMPOSE)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 if ($COMPOSE['param']['to']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 $mailto = explode('?', $COMPOSE['param']['to'], 2);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324 // #1486037: remove "mailto:" prefix
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325 $COMPOSE['param']['to'] = preg_replace('/^mailto:/i', '', $mailto[0]);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 // #1490346: decode the recipient address
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327 // #1490510: use raw encoding for correct "+" character handling as specified in RFC6068
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 $COMPOSE['param']['to'] = rawurldecode($COMPOSE['param']['to']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
329
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
330 // Supported case-insensitive tokens in mailto URL
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 $url_tokens = array('to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'body');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 if (!empty($mailto[1])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334 parse_str($mailto[1], $query);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 foreach ($query as $f => $val) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336 if (($key = array_search(strtolower($f), $url_tokens)) !== false) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 $f = $url_tokens[$key];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 // merge mailto: addresses with addresses from 'to' parameter
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 if ($f == 'to' && !empty($COMPOSE['param']['to'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 $to_addresses = rcube_mime::decode_address_list($COMPOSE['param']['to'], null, true, null, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343 $add_addresses = rcube_mime::decode_address_list($val, null, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 foreach ($add_addresses as $addr) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 if (!in_array($addr['mailto'], $to_addresses)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 $to_addresses[] = $addr['mailto'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 $COMPOSE['param']['to'] = (!empty($to_addresses) ? ', ' : '') . $addr['string'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 $COMPOSE['param'][$f] = $val;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
359 // resolve _forward_uid=* to an absolute list of messages from a search result
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
360 if ($COMPOSE['param']['forward_uid'] == '*' && is_object($_SESSION['search'][1])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361 $COMPOSE['param']['forward_uid'] = $_SESSION['search'][1]->get();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364 // clean HTML message body which can be submitted by URL
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365 if (!empty($COMPOSE['param']['body'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 if ($COMPOSE['param']['html'] = strpos($COMPOSE['param']['body'], '<') !== false) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
367 $wash_params = array('safe' => false, 'inline_html' => true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 $COMPOSE['param']['body'] = rcmail_wash_html($COMPOSE['param']['body'], $wash_params, array());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369 $COMPOSE['param']['body'] = preg_replace('/<!--[^>\n]+>/', '', $COMPOSE['param']['body']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 $COMPOSE['param']['body'] = preg_replace('/<\/?body>/', '', $COMPOSE['param']['body']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
371 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
372 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 $RCMAIL = rcmail::get_instance();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376 // select folder where to save the sent message
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
377 $COMPOSE['param']['sent_mbox'] = $RCMAIL->config->get('sent_mbox');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
378
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
379 // pipe compose parameters thru plugins
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
380 $plugin = $RCMAIL->plugins->exec_hook('message_compose', $COMPOSE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
381 $COMPOSE['param'] = array_merge($COMPOSE['param'], $plugin['param']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383 // add attachments listed by message_compose hook
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
384 if (is_array($plugin['attachments'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
385 foreach ($plugin['attachments'] as $attach) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 // we have structured data
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
387 if (is_array($attach)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
388 $attachment = $attach + array('group' => $COMPOSE_ID);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
389 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390 // only a file path is given
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392 $filename = basename($attach);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
393 $attachment = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
394 'group' => $COMPOSE_ID,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
395 'name' => $filename,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
396 'mimetype' => rcube_mime::file_content_type($attach, $filename),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
397 'size' => filesize($attach),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
398 'path' => $attach,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
399 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
400 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402 // save attachment if valid
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403 if (($attachment['data'] && $attachment['name']) || ($attachment['path'] && file_exists($attachment['path']))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 $attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
405 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
406
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
407 if ($attachment['status'] && !$attachment['abort']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
408 unset($attachment['data'], $attachment['status'], $attachment['abort']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
409 $COMPOSE['attachments'][$attachment['id']] = $attachment;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
410 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
411 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
412 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
413 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
414
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
415 function rcmail_compose_headers($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
416 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 global $RCMAIL, $MESSAGE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
419 list($form_start,) = get_form_tags($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
420
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
421 $out = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
422 $part = strtolower($attrib['part']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424 switch ($part) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425 case 'from':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
426 return $form_start . rcmail_compose_header_from($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
427
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428 case 'to':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 case 'cc':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 case 'bcc':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
431 $fname = '_' . $part;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
432 $header = $param = $part;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
433
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434 $allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'tabindex');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435 $field_type = 'html_textarea';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436 break;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438 case 'replyto':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 case 'reply-to':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440 $fname = '_replyto';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441 $param = 'replyto';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 $header = 'reply-to';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
443
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
444 case 'followupto':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 case 'followup-to':
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 if (!$fname) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447 $fname = '_followupto';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
448 $param = 'followupto';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
449 $header = 'mail-followup-to';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
450 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
451
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
452 $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
453 $field_type = 'html_inputfield';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
454 break;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
455 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
456
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457 if ($fname && $field_type) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
458 // pass the following attributes to the form class
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
459 $field_attrib = array('name' => $fname, 'spellcheck' => 'false');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460 foreach ($attrib as $attr => $value) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 if (in_array($attr, $allow_attrib)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 $field_attrib[$attr] = $value;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466 // create teaxtarea object
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
467 $input = new $field_type($field_attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
468 $out = $input->show(rcmail_compose_header_value($param));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471 if ($form_start) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
472 $out = $form_start . $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
473 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
474
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
475 // configure autocompletion
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476 $RCMAIL->autocomplete_init();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
477
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
478 return $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
480
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
481
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
482 function rcmail_compose_header_from($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484 global $MESSAGE, $OUTPUT, $RCMAIL, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
485
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
486 // pass the following attributes to the form class
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
487 $field_attrib = array('name' => '_from');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
488 foreach ($attrib as $attr => $value) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
489 if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 $field_attrib[$attr] = $value;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 if (count($MESSAGE->identities)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 $a_signatures = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
496 $identities = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
497 $top_posting = intval($RCMAIL->config->get('reply_mode')) > 0
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 && !$RCMAIL->config->get('sig_below')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 && ($COMPOSE['mode'] == RCUBE_COMPOSE_REPLY || $COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501 $separator = $top_posting ? '---' : '-- ';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 $add_separator = (bool) $RCMAIL->config->get('sig_separator');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504 $field_attrib['onchange'] = rcmail_output::JS_OBJECT_NAME.".change_identity(this)";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 $select_from = new html_select($field_attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
506
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 // create SELECT element
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
508 foreach ($MESSAGE->identities as $sql_arr) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
509 $identity_id = $sql_arr['identity_id'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 $select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $identity_id);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 // add signature to array
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513 if (!empty($sql_arr['signature']) && empty($COMPOSE['param']['nosig'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 $text = $html = $sql_arr['signature'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
515
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
516 if ($sql_arr['html_signature']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
517 $text = $RCMAIL->html2text($html, array('links' => false));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
518 $text = trim($text, "\r\n");
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
519 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
520 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 $t2h = new rcube_text2html($text, false);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522 $html = $t2h->get_html();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525 if ($add_separator && !preg_match('/^--[ -]\r?\n/m', $text)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
526 $text = $separator . "\n" . ltrim($text, "\r\n");
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
527 $html = $separator . "<br>" . $html;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
528 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
529
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530 $a_signatures[$identity_id]['text'] = $text;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531 $a_signatures[$identity_id]['html'] = $html;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 // add bcc and reply-to
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535 if (!empty($sql_arr['reply-to'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 $identities[$identity_id]['replyto'] = $sql_arr['reply-to'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
537 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 if (!empty($sql_arr['bcc'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 $identities[$identity_id]['bcc'] = $sql_arr['bcc'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542 $identities[$identity_id]['email'] = $sql_arr['email'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545 $out = $select_from->show($MESSAGE->compose['from']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 // add signatures to client
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548 $OUTPUT->set_env('signatures', $a_signatures);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
549 $OUTPUT->set_env('identities', $identities);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551 // no identities, display text input field
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
553 $field_attrib['class'] = 'from_address';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
554 $input_from = new html_inputfield($field_attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 $out = $input_from->show($MESSAGE->compose['from']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
557
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
558 return $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
559 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
560
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
561 function rcmail_compose_header_value($header)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
562 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
563 global $COMPOSE, $MESSAGE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
564
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
565 $RCMAIL = rcube::get_instance();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566 $fvalue = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
567 $decode_header = true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
568 $charset = $MESSAGE->headers->charset;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
569 $separator = trim($RCMAIL->config->get('recipients_separator', ',')) . ' ';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
570
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
571 // we have a set of recipients stored is session
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
572 if ($header == 'to' && ($mailto_id = $COMPOSE['param']['mailto'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
573 && $_SESSION['mailto'][$mailto_id]
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575 $fvalue = urldecode($_SESSION['mailto'][$mailto_id]);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
576 $decode_header = false;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
577 $charset = $RCMAIL->output->charset;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
578
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
579 // make session to not grow up too much
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
580 unset($_SESSION['mailto'][$mailto_id]);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
581 $COMPOSE['param']['to'] = $fvalue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
582 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
583 else if (!empty($_POST['_' . $header])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
584 $fvalue = rcube_utils::get_input_value('_' . $header, rcube_utils::INPUT_POST, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
585 $charset = $RCMAIL->output->charset;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
586 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
587 else if (!empty($COMPOSE['param'][$header])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
588 $fvalue = $COMPOSE['param'][$header];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
589 $charset = $RCMAIL->output->charset;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
590 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
591 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
592 // get recipent address(es) out of the message headers
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
593 if ($header == 'to') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
594 $mailfollowup = $MESSAGE->headers->others['mail-followup-to'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
595 $mailreplyto = $MESSAGE->headers->others['mail-reply-to'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
596
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
597 // Reply to mailing list...
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
598 if ($MESSAGE->reply_all == 'list' && $mailfollowup) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
599 $fvalue = $mailfollowup;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
600 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
601 else if ($MESSAGE->reply_all == 'list'
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
602 && preg_match('/<mailto:([^>]+)>/i', $MESSAGE->headers->others['list-post'], $m)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
603 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
604 $fvalue = $m[1];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
605 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
606 // Reply to...
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
607 else if ($MESSAGE->reply_all && $mailfollowup) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
608 $fvalue = $mailfollowup;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
609 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
610 else if ($mailreplyto) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
611 $fvalue = $mailreplyto;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
612 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
613 else if (!empty($MESSAGE->headers->replyto)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
614 $fvalue = $MESSAGE->headers->replyto;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
615 $replyto = true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
616 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
617 else if (!empty($MESSAGE->headers->from)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
618 $fvalue = $MESSAGE->headers->from;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
619 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
620
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
621 // Reply to message sent by yourself (#1487074, #1489230, #1490439)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
622 // Reply-To address need to be unset (#1490233)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
623 if (!empty($MESSAGE->compose['ident']) && empty($replyto)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
624 foreach (array($fvalue, $MESSAGE->headers->from) as $sender) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
625 $senders = rcube_mime::decode_address_list($sender, null, false, $charset, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
626
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
627 if (in_array($MESSAGE->compose['ident']['email_ascii'], $senders)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
628 $fvalue = $MESSAGE->headers->to;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
629 break;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
630 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
631 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
632 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
633 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
634 // add recipient of original message if reply to all
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
635 else if ($header == 'cc' && !empty($MESSAGE->reply_all) && $MESSAGE->reply_all != 'list') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
636 if ($v = $MESSAGE->headers->to) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
637 $fvalue .= $v;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
638 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
639 if ($v = $MESSAGE->headers->cc) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
640 $fvalue .= (!empty($fvalue) ? $separator : '') . $v;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
641 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
642 // Use Sender header (#1489011)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
643 if ($v = $MESSAGE->headers->get('Sender', false)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
644 // Skip common mailing lists addresses: *-bounces@ and *-request@ (#1490452)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
645 if (empty($MESSAGE->headers->others['list-post']) || !preg_match('/-(bounces|request)@/', $v)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
646 $fvalue .= (!empty($fvalue) ? $separator : '') . $v;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
647 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
648 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
649
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
650 // When To: and Reply-To: are the same we add From: address to the list (#1489037)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
651 if ($v = $MESSAGE->headers->from) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
652 $from = rcube_mime::decode_address_list($v, null, false, $charset, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
653 $to = rcube_mime::decode_address_list($MESSAGE->headers->to, null, false, $charset, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
654 $replyto = rcube_mime::decode_address_list($MESSAGE->headers->replyto, null, false, $charset, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
655
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
656 if (count($replyto) && !count(array_diff($to, $replyto)) && count(array_diff($from, $to))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
657 $fvalue .= (!empty($fvalue) ? $separator : '') . $v;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
658 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
659 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
660 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
661 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
662 else if (in_array($COMPOSE['mode'], array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
663 // get drafted headers
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
664 if ($header == 'to' && !empty($MESSAGE->headers->to)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
665 $fvalue = $MESSAGE->get_header('to', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
666 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
667 else if ($header == 'cc' && !empty($MESSAGE->headers->cc)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
668 $fvalue = $MESSAGE->get_header('cc', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
669 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
670 else if ($header == 'bcc' && !empty($MESSAGE->headers->bcc)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
671 $fvalue = $MESSAGE->get_header('bcc', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
672 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
673 else if ($header == 'replyto' && !empty($MESSAGE->headers->others['mail-reply-to'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
674 $fvalue = $MESSAGE->get_header('mail-reply-to');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
675 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
676 else if ($header == 'replyto' && !empty($MESSAGE->headers->replyto)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
677 $fvalue = $MESSAGE->get_header('reply-to');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
678 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
679 else if ($header == 'followupto' && !empty($MESSAGE->headers->others['mail-followup-to'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
680 $fvalue = $MESSAGE->get_header('mail-followup-to');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
681 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
682 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
683
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
684 // split recipients and put them back together in a unique way
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
685 if (!empty($fvalue) && in_array($header, array('to', 'cc', 'bcc'))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
686 $from_email = @mb_strtolower($MESSAGE->compose['ident']['email']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
687 $to_addresses = rcube_mime::decode_address_list($fvalue, null, $decode_header, $charset);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
688 $fvalue = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
689
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
690 foreach ($to_addresses as $addr_part) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
691 if (empty($addr_part['mailto'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
692 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
693 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
694
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
695 // According to RFC5321 local part of email address is case-sensitive
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
696 // however, here it is better to compare addresses in case-insensitive manner
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
697 $mailto = format_email(rcube_utils::idn_to_utf8($addr_part['mailto']));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
698 $mailto_lc = mb_strtolower($addr_part['mailto']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
699
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
700 if (($header == 'to' || $COMPOSE['mode'] != RCUBE_COMPOSE_REPLY || $mailto_lc != $from_email)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
701 && !in_array($mailto_lc, (array) $MESSAGE->recipients)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
702 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
703 if ($addr_part['name'] && $mailto != $addr_part['name']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
704 $mailto = format_email_recipient($mailto, $addr_part['name']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
705 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
706
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
707 $fvalue[] = $mailto;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
708 $MESSAGE->recipients[] = $mailto_lc;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
709 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
710 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
711
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
712 $fvalue = implode($separator, $fvalue);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
713 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
714
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
715 return $fvalue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
716 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
717
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
718 function rcmail_compose_editor_mode()
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
719 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
720 global $RCMAIL, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
721 static $useHtml;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
722
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
723 if ($useHtml !== null) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
724 return $useHtml;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
725 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
726
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
727 $html_editor = intval($RCMAIL->config->get('htmleditor'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
728 $compose_mode = $COMPOSE['mode'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
729
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
730 if (is_bool($COMPOSE['param']['html'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
731 $useHtml = $COMPOSE['param']['html'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
732 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
733 else if (isset($_POST['_is_html'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
734 $useHtml = !empty($_POST['_is_html']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
735 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
736 else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
737 $useHtml = rcmail_message_is_html();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
738 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
739 else if ($compose_mode == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
740 $useHtml = $html_editor == 1 || ($html_editor >= 2 && rcmail_message_is_html());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
741 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
742 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
743 $useHtml = $html_editor == 1 || $html_editor == 4
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
744 || ($html_editor == 3 && rcmail_message_is_html());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
745 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
746 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
747 $useHtml = $html_editor == 1 || $html_editor == 4;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
748 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
749
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
750 return $useHtml;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
751 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
752
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
753 function rcmail_message_is_html()
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
754 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
755 global $RCMAIL, $MESSAGE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
756
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
757 return $RCMAIL->config->get('prefer_html') && ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
758 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
759
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
760 function rcmail_prepare_message_body()
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
761 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
762 global $RCMAIL, $MESSAGE, $COMPOSE, $HTML_MODE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
763
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
764 // use posted message body
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
765 if (!empty($_POST['_message'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
766 $body = rcube_utils::get_input_value('_message', rcube_utils::INPUT_POST, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
767 $isHtml = (bool) rcube_utils::get_input_value('_is_html', rcube_utils::INPUT_POST);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
768 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
769 else if ($COMPOSE['param']['body']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
770 $body = $COMPOSE['param']['body'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
771 $isHtml = (bool) $COMPOSE['param']['html'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
772 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
773 // forward as attachment
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
774 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD && $COMPOSE['as_attachment']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
775 $isHtml = rcmail_compose_editor_mode();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
776 $body = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
777
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
778 rcmail_write_forward_attachments();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
779 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
780 // reply/edit/draft/forward
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
781 else if ($COMPOSE['mode'] && ($COMPOSE['mode'] != RCUBE_COMPOSE_REPLY || intval($RCMAIL->config->get('reply_mode')) != -1)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
782 $isHtml = rcmail_compose_editor_mode();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
783 $messages = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
784
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
785 if (!empty($MESSAGE->parts)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
786 // collect IDs of message/rfc822 parts
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
787 foreach ($MESSAGE->mime_parts() as $part) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
788 if ($part->mimetype == 'message/rfc822') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
789 $messages[] = $part->mime_id;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
790 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
791 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
792
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
793 foreach ($MESSAGE->parts as $part) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
794 if ($part->realtype == 'multipart/encrypted') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
795 // find the encrypted message payload part
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
796 if ($pgp_mime_part = $MESSAGE->get_multipart_encrypted_part()) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
797 $RCMAIL->output->set_env('pgp_mime_message', array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
798 '_mbox' => $RCMAIL->storage->get_folder(),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
799 '_uid' => $MESSAGE->uid,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
800 '_part' => $pgp_mime_part->mime_id,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
801 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
802 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
803 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
804 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
805
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
806 // skip no-content and attachment parts (#1488557)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
807 if ($part->type != 'content' || !$part->size || $MESSAGE->is_attachment($part)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
808 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
809 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
810
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
811 // skip all content parts inside the message/rfc822 part
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
812 foreach ($messages as $mimeid) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
813 if (strpos($part->mime_id, $mimeid . '.') === 0) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
814 continue 2;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
815 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
816 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
817
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
818 if ($part_body = rcmail_compose_part_body($part, $isHtml)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
819 $body .= ($body ? ($isHtml ? '<br/>' : "\n") : '') . $part_body;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
820 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
821 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
822 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
823 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
824 $body = rcmail_compose_part_body($MESSAGE, $isHtml);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
825 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
826
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
827 // compose reply-body
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
828 if ($COMPOSE['mode'] == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
829 $body = rcmail_create_reply_body($body, $isHtml);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
830
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
831 if ($MESSAGE->pgp_mime) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
832 $RCMAIL->output->set_env('compose_reply_header', rcmail_get_reply_header($MESSAGE));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
833 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
834 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
835 // forward message body inline
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
836 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
837 $body = rcmail_create_forward_body($body, $isHtml);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
838 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
839 // load draft message body
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
840 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_DRAFT || $COMPOSE['mode'] == RCUBE_COMPOSE_EDIT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
841 $body = rcmail_create_draft_body($body, $isHtml);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
842 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
843 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
844 else { // new message
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
845 $isHtml = rcmail_compose_editor_mode();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
846 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
847
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
848 $plugin = $RCMAIL->plugins->exec_hook('message_compose_body',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
849 array('body' => $body, 'html' => $isHtml, 'mode' => $COMPOSE['mode']));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
850
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
851 $body = $plugin['body'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
852 unset($plugin);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
853
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
854 // add blocked.gif attachment (#1486516)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
855 $regexp = '# src="program/resources/blocked\.gif"#';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
856 if ($isHtml && preg_match($regexp, $body)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
857 $content = $RCMAIL->get_resource_content('blocked.gif');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
858
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
859 if ($content && ($attachment = rcmail_save_image('blocked.gif', 'image/gif', $content))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
860 $COMPOSE['attachments'][$attachment['id']] = $attachment;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
861 $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
862 $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
863 $body = preg_replace($regexp, ' src="' . $url . '"', $body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
864 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
865 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
866
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
867 $HTML_MODE = $isHtml;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
868
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
869 return $body;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
870 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
871
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
872 function rcmail_compose_part_body($part, $isHtml = false)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
873 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
874 global $RCMAIL, $COMPOSE, $MESSAGE, $LINE_LENGTH;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
875
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
876 // Check if we have enough memory to handle the message in it
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
877 // #1487424: we need up to 10x more memory than the body
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
878 if (!rcube_utils::mem_check($part->size * 10)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
879 return '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
880 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
881
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
882 // fetch part if not available
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
883 $body = $MESSAGE->get_part_body($part->mime_id, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
884
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
885 // message is cached but not exists (#1485443), or other error
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
886 if ($body === false) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
887 return '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
888 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
889
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
890 // register this part as pgp encrypted
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
891 if (strpos($body, '-----BEGIN PGP MESSAGE-----') !== false) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
892 $MESSAGE->pgp_mime = true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
893 $RCMAIL->output->set_env('pgp_mime_message', array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
894 '_mbox' => $RCMAIL->storage->get_folder(), '_uid' => $MESSAGE->uid, '_part' => $part->mime_id,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
895 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
896 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
897
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
898 if ($isHtml) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
899 if ($part->ctype_secondary == 'html') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
900 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
901 else if ($part->ctype_secondary == 'enriched') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
902 $body = rcube_enriched::to_html($body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
903 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
904 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
905 // try to remove the signature
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
906 if ($COMPOSE['mode'] != RCUBE_COMPOSE_DRAFT && $COMPOSE['mode'] != RCUBE_COMPOSE_EDIT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
907 if ($RCMAIL->config->get('strip_existing_sig', true)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
908 $body = rcmail_remove_signature($body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
909 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
910 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
911
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
912 // add HTML formatting
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
913 $body = rcmail_plain_body($body, $part->ctype_parameters['format'] == 'flowed', $part->ctype_parameters['delsp'] == 'yes');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
914 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
915 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
916 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
917 if ($part->ctype_secondary == 'enriched') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
918 $body = rcube_enriched::to_html($body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
919 $part->ctype_secondary = 'html';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
920 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
921
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
922 if ($part->ctype_secondary == 'html') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
923 // use html part if it has been used for message (pre)viewing
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
924 // decrease line length for quoting
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
925 $len = $COMPOSE['mode'] == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
926 $body = $RCMAIL->html2text($body, array('width' => $len));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
927 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
928 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
929 if ($part->ctype_secondary == 'plain' && $part->ctype_parameters['format'] == 'flowed') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
930 $body = rcube_mime::unfold_flowed($body, null, $part->ctype_parameters['delsp'] == 'yes');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
931 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
932
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
933 // try to remove the signature
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
934 if ($COMPOSE['mode'] != RCUBE_COMPOSE_DRAFT && $COMPOSE['mode'] != RCUBE_COMPOSE_EDIT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
935 if ($RCMAIL->config->get('strip_existing_sig', true)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
936 $body = rcmail_remove_signature($body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
937 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
938 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
939 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
940 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
941
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
942 return $body;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
943 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
944
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
945 function rcmail_compose_body($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
946 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
947 global $RCMAIL, $OUTPUT, $HTML_MODE, $MESSAGE_BODY;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
948
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
949 list($form_start, $form_end) = get_form_tags($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
950 unset($attrib['form']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
951
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
952 if (empty($attrib['id'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
953 $attrib['id'] = 'rcmComposeBody';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
954 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
955
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
956 // If desired, set this textarea to be editable by TinyMCE
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
957 if ($HTML_MODE) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
958 $attrib['class'] = 'mce_editor';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
959 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
960
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
961 $attrib['name'] = '_message';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
962
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
963 $textarea = new html_textarea($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
964 $hidden = new html_hiddenfield();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
965
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
966 $hidden->add(array('name' => '_draft_saveid', 'value' => $RCMAIL->output->get_env('draft_id')));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
967 $hidden->add(array('name' => '_draft', 'value' => ''));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
968 $hidden->add(array('name' => '_is_html', 'value' => $HTML_MODE ? "1" : "0"));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
969 $hidden->add(array('name' => '_framed', 'value' => '1'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
970
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
971 $OUTPUT->set_env('composebody', $attrib['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
972
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
973 // include HTML editor
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
974 $RCMAIL->html_editor();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
975
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
976 // Set language list
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
977 if ($RCMAIL->config->get('enable_spellcheck')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
978 $engine = new rcube_spellchecker();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
979 $dictionary = (bool) $RCMAIL->config->get('spellcheck_dictionary');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
980 $spellcheck_langs = $engine->languages();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
981 $lang = $_SESSION['language'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
982
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
983 // if not found in the list, try with two-letter code
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
984 if (!$spellcheck_langs[$lang]) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
985 $lang = strtolower(substr($lang, 0, 2));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
986 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
987
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
988 if (!$spellcheck_langs[$lang]) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
989 $lang = 'en';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
990 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
991
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
992 $editor_lang_set = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
993 foreach ($spellcheck_langs as $key => $name) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
994 $editor_lang_set[] = ($key == $lang ? '+' : '') . rcube::JQ($name).'='.rcube::JQ($key);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
995 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
996
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
997 // include GoogieSpell
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
998 $OUTPUT->include_script('googiespell.js');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
999 $OUTPUT->add_script(sprintf(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1000 "var googie = new GoogieSpell('%s/images/googiespell/','%s&lang=', %s);\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1001 "googie.lang_chck_spell = \"%s\";\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1002 "googie.lang_rsm_edt = \"%s\";\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1003 "googie.lang_close = \"%s\";\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1004 "googie.lang_revert = \"%s\";\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1005 "googie.lang_no_error_found = \"%s\";\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1006 "googie.lang_learn_word = \"%s\";\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1007 "googie.setLanguages(%s);\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1008 "googie.setCurrentLanguage('%s');\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1009 "googie.setDecoration(false);\n".
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1010 "googie.decorateTextarea('%s');\n",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1011 $RCMAIL->output->asset_url($RCMAIL->output->get_skin_path()),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1012 $RCMAIL->url(array('_task' => 'utils', '_action' => 'spell', '_remote' => 1)),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1013 !empty($dictionary) ? 'true' : 'false',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1014 rcube::JQ(rcube::Q($RCMAIL->gettext('checkspelling'))),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1015 rcube::JQ(rcube::Q($RCMAIL->gettext('resumeediting'))),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1016 rcube::JQ(rcube::Q($RCMAIL->gettext('close'))),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1017 rcube::JQ(rcube::Q($RCMAIL->gettext('revertto'))),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1018 rcube::JQ(rcube::Q($RCMAIL->gettext('nospellerrors'))),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1019 rcube::JQ(rcube::Q($RCMAIL->gettext('addtodict'))),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1020 rcube_output::json_serialize($spellcheck_langs),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1021 $lang,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1022 $attrib['id']), 'foot');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1023
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1024 $OUTPUT->add_label('checking');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1025 $OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1026 $OUTPUT->set_env('spell_langs', $spellcheck_langs);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1027 $OUTPUT->set_env('spell_lang', $lang);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1028 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1029
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1030 return ($form_start ? "$form_start\n" : '')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1031 . "\n" . $hidden->show() . "\n" . $textarea->show($MESSAGE_BODY)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1032 . ($form_end ? "\n$form_end\n" : '')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1033 . '<iframe name="savetarget" src="program/resources/blank.gif"'
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1034 . ' style="width:0;height:0;border:none;visibility:hidden;" aria-hidden="true"></iframe>';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1035 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1036
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1037
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1038 function rcmail_create_reply_body($body, $bodyIsHtml)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1039 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1040 global $RCMAIL, $MESSAGE, $LINE_LENGTH;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1041
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1042 $prefix = rcmail_get_reply_header($MESSAGE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1043 $reply_mode = intval($RCMAIL->config->get('reply_mode'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1044
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1045 if (!$bodyIsHtml) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1046 // soft-wrap and quote message text
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1047 $body = rcmail_wrap_and_quote($body, $LINE_LENGTH);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1048
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1049 $prefix .= "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1050
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1051 if ($reply_mode > 0) { // top-posting
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1052 $prefix = "\n\n\n" . $prefix;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1053 $suffix = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1054 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1055 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1056 $suffix = "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1057 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1058 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1059 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1060 // save inline images to files
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1061 $cid_map = rcmail_write_inline_attachments($MESSAGE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1062 // set is_safe flag (we need this for html body washing)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1063 rcmail_check_safe($MESSAGE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1064 // clean up html tags
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1065 $body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1066
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1067 // build reply (quote content)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1068 $prefix = '<p>' . rcube::Q($prefix) . "</p>\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1069 $prefix .= '<blockquote>';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1070
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1071 if ($reply_mode > 0) { // top-posting
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1072 $prefix = '<br>' . $prefix;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1073 $suffix = '</blockquote>';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1074 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1075 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1076 $suffix = '</blockquote><p><br/></p>';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1077 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1078 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1079
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1080 return $prefix . $body . $suffix;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1081 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1082
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1083 function rcmail_get_reply_header($message)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1084 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1085 global $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1086
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1087 $from = array_pop(rcube_mime::decode_address_list($message->get_header('from'), 1, false, $message->headers->charset));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1088 return $RCMAIL->gettext(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1089 'name' => 'mailreplyintro',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1090 'vars' => array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1091 'date' => $RCMAIL->format_date($message->headers->date, $RCMAIL->config->get('date_long')),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1092 'sender' => $from['name'] ?: rcube_utils::idn_to_utf8($from['mailto']),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1093 )
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1094 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1095 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1096
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1097 function rcmail_create_forward_body($body, $bodyIsHtml)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1098 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1099 global $RCMAIL, $MESSAGE, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1100
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1101 // add attachments
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1102 if (!isset($COMPOSE['forward_attachments']) && is_array($MESSAGE->mime_parts)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1103 $cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1104 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1105
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1106 $date = $RCMAIL->format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1107
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1108 if (!$bodyIsHtml) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1109 $prefix = "\n\n\n-------- " . $RCMAIL->gettext('originalmessage') . " --------\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1110 $prefix .= $RCMAIL->gettext('subject') . ': ' . $MESSAGE->subject . "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1111 $prefix .= $RCMAIL->gettext('date') . ': ' . $date . "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1112 $prefix .= $RCMAIL->gettext('from') . ': ' . $MESSAGE->get_header('from') . "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1113 $prefix .= $RCMAIL->gettext('to') . ': ' . $MESSAGE->get_header('to') . "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1114
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1115 if ($cc = $MESSAGE->headers->get('cc')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1116 $prefix .= $RCMAIL->gettext('cc') . ': ' . $cc . "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1117 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1118 if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1119 $prefix .= $RCMAIL->gettext('replyto') . ': ' . $replyto . "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1120 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1121
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1122 $prefix .= "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1123 $body = trim($body, "\r\n");
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1124 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1125 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1126 // set is_safe flag (we need this for html body washing)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1127 rcmail_check_safe($MESSAGE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1128
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1129 // clean up html tags
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1130 $body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1131
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1132 $prefix = sprintf(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1133 "<br /><p>-------- " . $RCMAIL->gettext('originalmessage') . " --------</p>" .
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1134 "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody>" .
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1135 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>" .
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1136 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>" .
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1137 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>" .
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1138 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1139 $RCMAIL->gettext('subject'), rcube::Q($MESSAGE->subject),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1140 $RCMAIL->gettext('date'), rcube::Q($date),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1141 $RCMAIL->gettext('from'), rcube::Q($MESSAGE->get_header('from'), 'replace'),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1142 $RCMAIL->gettext('to'), rcube::Q($MESSAGE->get_header('to'), 'replace'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1143
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1144 if ($cc = $MESSAGE->headers->get('cc'))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1145 $prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1146 $RCMAIL->gettext('cc'), rcube::Q($cc, 'replace'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1147
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1148 if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from'))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1149 $prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1150 $RCMAIL->gettext('replyto'), rcube::Q($replyto, 'replace'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1151
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1152 $prefix .= "</tbody></table><br>";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1153 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1154
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1155 return $prefix . $body;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1156 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1157
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1158
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1159 function rcmail_create_draft_body($body, $bodyIsHtml)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1160 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1161 global $MESSAGE, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1162
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1163 // add attachments
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1164 // count($MESSAGE->mime_parts) can be 1 - e.g. attachment, but no text!
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1165 if (empty($COMPOSE['forward_attachments'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1166 && is_array($MESSAGE->mime_parts)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1167 && count($MESSAGE->mime_parts) > 0
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1168 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1169 $cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1170 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1171
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1172 // clean up HTML tags - XSS prevention (#1489251)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1173 if ($bodyIsHtml) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1174 $body = rcmail_wash_html($body, array('safe' => 1), $cid_map);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1175
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1176 // cleanup
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1177 $body = preg_replace(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1178 // remove comments (produced by washtml)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1179 '/<!--[^>]+-->/',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1180 // remove <body> tags
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1181 '/<body([^>]*)>/i',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1182 '/<\/body>/i',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1183 // convert TinyMCE's empty-line sequence (#1490463)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1184 '/<p>\xC2\xA0<\/p>/',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1185 ),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1186 array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1187 '',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1188 '',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1189 '',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1190 '<p><br /></p>',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1191 ),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1192 $body
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1193 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1194
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1195 // replace cid with href in inline images links
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1196 if (!empty($cid_map)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1197 $body = str_replace(array_keys($cid_map), array_values($cid_map), $body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1198 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1199 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1200
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1201 return $body;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1202 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1203
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1204
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1205 function rcmail_remove_signature($body)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1206 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1207 global $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1208
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1209 $body = str_replace("\r\n", "\n", $body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1210 $len = strlen($body);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1211 $sig_max_lines = $RCMAIL->config->get('sig_max_lines', 15);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1212
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1213 while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1214 if ($sp == 0 || $body[$sp-1] == "\n") {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1215 // do not touch blocks with more that X lines
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1216 if (substr_count($body, "\n", $sp) < $sig_max_lines) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1217 $body = substr($body, 0, max(0, $sp-1));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1218 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1219 break;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1220 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1221 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1222
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1223 return $body;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1224 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1225
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1226
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1227 function rcmail_write_compose_attachments(&$message, $bodyIsHtml)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1228 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1229 global $RCMAIL, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1230
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1231 $loaded_attachments = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1232 foreach ((array)$COMPOSE['attachments'] as $attachment) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1233 $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1234 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1235
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1236 $cid_map = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1237 $messages = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1238
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1239 if ($message->pgp_mime) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1240 return $cid_map;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1241 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1242
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1243 foreach ((array) $message->mime_parts() as $pid => $part) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1244 if ($part->mimetype == 'message/rfc822') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1245 $messages[] = $part->mime_id;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1246 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1247
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1248 if ($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1249 // skip parts that aren't valid attachments
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1250 if ($part->ctype_primary == 'multipart' || $part->mimetype == 'application/ms-tnef') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1251 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1252 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1253
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1254 // skip message attachments in reply mode
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1255 if ($part->ctype_primary == 'message' && $COMPOSE['mode'] == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1256 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1257 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1258
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1259 // skip inline images when forwarding in text mode
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1260 if ($part->content_id && $part->disposition == 'inline' && !$bodyIsHtml && $COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1261 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1262 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1263
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1264 // skip version.txt parts of multipart/encrypted messages
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1265 if ($message->pgp_mime && $part->mimetype == 'application/pgp-encrypted' && $part->filename == 'version.txt') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1266 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1267 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1268
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1269 // skip attachments included in message/rfc822 attachment (#1486487, #1490607)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1270 foreach ($messages as $mimeid) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1271 if (strpos($part->mime_id, $mimeid . '.') === 0) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1272 continue 2;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1273 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1274 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1275
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1276 if (($attachment = $loaded_attachments[rcmail_attachment_name($part) . $part->mimetype])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1277 || ($attachment = rcmail_save_attachment($message, $pid, $COMPOSE['id']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1278 ) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1279 if ($bodyIsHtml && ($part->content_id || $part->content_location)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1280 $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1281 $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1282
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1283 if ($part->content_id)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1284 $cid_map['cid:'.$part->content_id] = $url;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1285 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1286 $cid_map[$part->content_location] = $url;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1287 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1288 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1289 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1290 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1291
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1292 $COMPOSE['forward_attachments'] = true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1293
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1294 return $cid_map;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1295 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1296
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1297
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1298 function rcmail_write_inline_attachments(&$message)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1299 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1300 global $RCMAIL, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1301
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1302 $cid_map = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1303 $messages = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1304
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1305 if ($message->pgp_mime) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1306 return $cid_map;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1307 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1308
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1309 foreach ((array) $message->mime_parts() as $pid => $part) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1310 if ($part->mimetype == 'message/rfc822') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1311 $messages[] = $part->mime_id;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1312 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1313
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1314 if (($part->content_id || $part->content_location) && $part->filename) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1315 // skip attachments included in message/rfc822 attachment (#1486487, #1490607)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1316 foreach ($messages as $mimeid) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1317 if (strpos($part->mime_id, $mimeid . '.') === 0) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1318 continue 2;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1319 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1320 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1321
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1322 if ($attachment = rcmail_save_attachment($message, $pid, $COMPOSE['id'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1323 $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1324 $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1325
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1326 if ($part->content_id)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1327 $cid_map['cid:'.$part->content_id] = $url;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1328 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1329 $cid_map[$part->content_location] = $url;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1330 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1331 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1332 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1333
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1334 return $cid_map;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1335 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1336
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1337 // Creates attachment(s) from the forwarded message(s)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1338 function rcmail_write_forward_attachments()
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1339 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1340 global $RCMAIL, $COMPOSE, $MESSAGE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1341
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1342 $storage = $RCMAIL->get_storage();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1343 $names = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1344 $refs = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1345
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1346 if ($MESSAGE->pgp_mime) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1347 return;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1348 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1349
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1350 $loaded_attachments = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1351 foreach ((array)$COMPOSE['attachments'] as $attachment) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1352 $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1353 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1354
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1355 if ($COMPOSE['forward_uid'] == '*') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1356 $index = $storage->index(null, rcmail_sort_column(), rcmail_sort_order());
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1357 $COMPOSE['forward_uid'] = $index->get();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1358 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1359 else if (!is_array($COMPOSE['forward_uid']) && strpos($COMPOSE['forward_uid'], ':')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1360 $COMPOSE['forward_uid'] = rcube_imap_generic::uncompressMessageSet($COMPOSE['forward_uid']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1361 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1362 else if (is_string($COMPOSE['forward_uid'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1363 $COMPOSE['forward_uid'] = explode(',', $COMPOSE['forward_uid']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1364 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1365
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1366 foreach ((array)$COMPOSE['forward_uid'] as $uid) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1367 $message = new rcube_message($uid);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1368
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1369 if (empty($message->headers)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1370 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1371 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1372
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1373 if (!empty($message->headers->charset)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1374 $storage->set_charset($message->headers->charset);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1375 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1376
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1377 if (empty($MESSAGE->subject)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1378 $MESSAGE->subject = $message->subject;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1379 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1380
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1381 // generate (unique) attachment name
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1382 $name = strlen($message->subject) ? mb_substr($message->subject, 0, 64) : 'message_rfc822';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1383 if (!empty($names[$name])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1384 $names[$name]++;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1385 $name .= '_' . $names[$name];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1386 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1387 $names[$name] = 1;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1388 $name .= '.eml';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1389
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1390 if (!empty($loaded_attachments[$name . 'message/rfc822'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1391 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1392 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1393
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1394 rcmail_save_attachment($message, null, $COMPOSE['id'], array('filename' => $name));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1395
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1396 if ($message->headers->messageID) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1397 $refs[] = $message->headers->messageID;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1398 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1399 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1400
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1401 // set In-Reply-To and References headers
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1402 if (count($refs) == 1) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1403 $COMPOSE['reply_msgid'] = $refs[0];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1404 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1405 if (!empty($refs)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1406 $COMPOSE['references'] = implode(' ', $refs);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1407 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1408 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1409
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1410 function rcmail_save_image($path, $mimetype = '', $data = null)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1411 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1412 global $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1413
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1414 // handle attachments in memory
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1415 if (empty($data)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1416 $data = file_get_contents($path);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1417 $is_file = true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1418 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1419
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1420 $name = rcmail_basename($path);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1421
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1422 if (empty($mimetype)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1423 if ($is_file) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1424 $mimetype = rcube_mime::file_content_type($path, $name);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1425 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1426 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1427 $mimetype = rcube_mime::file_content_type($data, $name, 'application/octet-stream', true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1428 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1429 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1430
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1431 $attachment = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1432 'group' => $COMPOSE['id'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1433 'name' => $name,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1434 'mimetype' => $mimetype,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1435 'data' => $data,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1436 'size' => strlen($data),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1437 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1438
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1439 $attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1440
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1441 if ($attachment['status']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1442 unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1443 return $attachment;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1444 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1445
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1446 return false;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1447 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1448
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1449 function rcmail_basename($filename)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1450 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1451 // basename() is not unicode safe and locale dependent
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1452 if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1453 return preg_replace('/^.*[\\\\\\/]/', '', $filename);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1454 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1455 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1456 return preg_replace('/^.*[\/]/', '', $filename);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1457 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1458 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1459
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1460 /**
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1461 * Creates reply subject by removing common subject
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1462 * prefixes/suffixes from the original message subject
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1463 */
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1464 function rcmail_reply_subject($subject)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1465 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1466 $subject = trim($subject);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1467
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1468 // replace Re:, Re[x]:, Re-x (#1490497)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1469 $prefix = '/^(re:|re\[\d\]:|re-\d:)\s*/i';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1470 do {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1471 $subject = preg_replace($prefix, '', $subject, -1, $count);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1472 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1473 while ($count);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1474
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1475 // replace (was: ...) (#1489375)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1476 $subject = preg_replace('/\s*\([wW]as:[^\)]+\)\s*$/', '', $subject);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1477
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1478 return 'Re: ' . $subject;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1479 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1480
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1481 function rcmail_compose_subject($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1482 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1483 global $MESSAGE, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1484
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1485 list($form_start, $form_end) = get_form_tags($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1486 unset($attrib['form']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1487
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1488 $attrib['name'] = '_subject';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1489 $attrib['spellcheck'] = 'true';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1490
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1491 $textfield = new html_inputfield($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1492 $subject = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1493
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1494 // use subject from post
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1495 if (isset($_POST['_subject'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1496 $subject = rcube_utils::get_input_value('_subject', rcube_utils::INPUT_POST, TRUE);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1497 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1498 else if (!empty($COMPOSE['param']['subject'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1499 $subject = $COMPOSE['param']['subject'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1500 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1501 // create a reply-subject
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1502 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_REPLY) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1503 $subject = rcmail_reply_subject($MESSAGE->subject);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1504 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1505 // create a forward-subject
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1506 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1507 if (preg_match('/^fwd:/i', $MESSAGE->subject))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1508 $subject = $MESSAGE->subject;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1509 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1510 $subject = 'Fwd: '.$MESSAGE->subject;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1511 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1512 // creeate a draft-subject
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1513 else if ($COMPOSE['mode'] == RCUBE_COMPOSE_DRAFT || $COMPOSE['mode'] == RCUBE_COMPOSE_EDIT) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1514 $subject = $MESSAGE->subject;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1515 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1516
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1517 $out = $form_start ? "$form_start\n" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1518 $out .= $textfield->show($subject);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1519 $out .= $form_end ? "\n$form_end" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1520
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1521 return $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1522 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1523
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1524 function rcmail_compose_attachment_list($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1525 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1526 global $RCMAIL, $OUTPUT, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1527
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1528 // add ID if not given
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1529 if (!$attrib['id'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1530 $attrib['id'] = 'rcmAttachmentList';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1531
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1532 $out = "\n";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1533 $jslist = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1534 $button = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1535
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1536 if ($attrib['icon_pos'] == 'left')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1537 $COMPOSE['icon_pos'] = 'left';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1538
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1539 if (is_array($COMPOSE['attachments'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1540 if ($attrib['deleteicon']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1541 $button = html::img(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1542 'src' => $RCMAIL->output->abs_url($attrib['deleteicon'], true),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1543 'alt' => $RCMAIL->gettext('delete')
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1544 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1545 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1546 else if (rcube_utils::get_boolean($attrib['textbuttons'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1547 $button = rcube::Q($RCMAIL->gettext('delete'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1548 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1549
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1550 foreach ($COMPOSE['attachments'] as $id => $a_prop) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1551 if (empty($a_prop)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1552 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1553 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1554
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1555 $link_content = sprintf('%s <span class="attachment-size"> (%s)</span>',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1556 rcube::Q($a_prop['name']), $RCMAIL->show_bytes($a_prop['size']));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1557
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1558 $content_link = html::a(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1559 'href' => "#load",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1560 'class' => 'filename',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1561 'onclick' => sprintf("return %s.command('load-attachment','rcmfile%s', this, event)", rcmail_output::JS_OBJECT_NAME, $id),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1562 ), $link_content);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1563
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1564 $delete_link = html::a(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1565 'href' => "#delete",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1566 'title' => $RCMAIL->gettext('delete'),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1567 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this, event)", rcmail_output::JS_OBJECT_NAME, $id),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1568 'class' => 'delete',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1569 'tabindex' => $attrib['tabindex'] ?: '0',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1570 'aria-label' => $RCMAIL->gettext('delete') . ' ' . $a_prop['name'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1571 ), $button);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1572
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1573 $out .= html::tag('li', array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1574 'id' => 'rcmfile'.$id,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1575 'class' => rcube_utils::file2class($a_prop['mimetype'], $a_prop['name']),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1576 'onmouseover' => "rcube_webmail.long_subject_title_ex(this, 0)",
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1577 ),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1578 $COMPOSE['icon_pos'] == 'left' ? $delete_link.$content_link : $content_link.$delete_link
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1579 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1580
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1581 $jslist['rcmfile'.$id] = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1582 'name' => $a_prop['name'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1583 'complete' => true,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1584 'mimetype' => $a_prop['mimetype']
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1585 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1586 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1587 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1588
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1589 if ($attrib['deleteicon'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1590 $COMPOSE['deleteicon'] = $RCMAIL->output->abs_url($attrib['deleteicon'], true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1591 else if (rcube_utils::get_boolean($attrib['textbuttons']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1592 $COMPOSE['textbuttons'] = true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1593 if ($attrib['cancelicon'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1594 $OUTPUT->set_env('cancelicon', $RCMAIL->output->abs_url($attrib['cancelicon'], true));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1595 if ($attrib['loadingicon'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1596 $OUTPUT->set_env('loadingicon', $RCMAIL->output->abs_url($attrib['loadingicon'], true));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1597
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1598 $OUTPUT->set_env('attachments', $jslist);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1599 $OUTPUT->add_gui_object('attachmentlist', $attrib['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1600
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1601 // put tabindex value into data-tabindex attribute
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1602 if (isset($attrib['tabindex'])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1603 $attrib['data-tabindex'] = $attrib['tabindex'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1604 unset($attrib['tabindex']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1605 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1606
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1607 return html::tag('ul', $attrib, $out, html::$common_attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1608 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1609
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1610
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1611 function rcmail_compose_attachment_form($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1612 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1613 global $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1614
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1615 return $RCMAIL->upload_form($attrib, 'uploadform', 'send-attachment', array('multiple' => true));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1616 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1617
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1618 function rcmail_priority_selector($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1619 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1620 global $RCMAIL, $MESSAGE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1621
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1622 list($form_start, $form_end) = get_form_tags($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1623 unset($attrib['form']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1624
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1625 $attrib['name'] = '_priority';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1626 $prio_list = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1627 $RCMAIL->gettext('lowest') => 5,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1628 $RCMAIL->gettext('low') => 4,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1629 $RCMAIL->gettext('normal') => 0,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1630 $RCMAIL->gettext('high') => 2,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1631 $RCMAIL->gettext('highest') => 1,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1632 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1633
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1634 $selector = new html_select($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1635 $selector->add(array_keys($prio_list), array_values($prio_list));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1636
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1637 if (isset($_POST['_priority']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1638 $sel = $_POST['_priority'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1639 else if (isset($MESSAGE->headers->priority) && intval($MESSAGE->headers->priority) != 3)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1640 $sel = $MESSAGE->headers->priority;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1641 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1642 $sel = 0;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1643
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1644 $out = $form_start ? "$form_start\n" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1645 $out .= $selector->show((int) $sel);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1646 $out .= $form_end ? "\n$form_end" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1647
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1648 return $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1649 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1650
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1651
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1652 function rcmail_mdn_checkbox($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1653 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1654 global $RCMAIL, $MESSAGE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1655
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1656 list($form_start, $form_end) = get_form_tags($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1657 unset($attrib['form']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1658
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1659 if (!isset($attrib['id']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1660 $attrib['id'] = 'receipt';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1661
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1662 $attrib['name'] = '_mdn';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1663 $attrib['value'] = '1';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1664
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1665 $checkbox = new html_checkbox($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1666
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1667 if (isset($_POST['_mdn']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1668 $mdn_default = $_POST['_mdn'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1669 else if (in_array($COMPOSE['mode'], array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT)))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1670 $mdn_default = (bool) $MESSAGE->headers->mdn_to;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1671 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1672 $mdn_default = $RCMAIL->config->get('mdn_default');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1673
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1674 $out = $form_start ? "$form_start\n" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1675 $out .= $checkbox->show($mdn_default);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1676 $out .= $form_end ? "\n$form_end" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1677
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1678 return $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1679 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1680
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1681
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1682 function rcmail_dsn_checkbox($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1683 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1684 global $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1685
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1686 list($form_start, $form_end) = get_form_tags($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1687 unset($attrib['form']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1688
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1689 if (!isset($attrib['id']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1690 $attrib['id'] = 'dsn';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1691
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1692 $attrib['name'] = '_dsn';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1693 $attrib['value'] = '1';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1694
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1695 $checkbox = new html_checkbox($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1696
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1697 if (isset($_POST['_dsn']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1698 $dsn_value = (int) $_POST['_dsn'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1699 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1700 $dsn_value = $RCMAIL->config->get('dsn_default');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1701
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1702 $out = $form_start ? "$form_start\n" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1703 $out .= $checkbox->show($dsn_value);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1704 $out .= $form_end ? "\n$form_end" : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1705
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1706 return $out;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1707 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1708
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1709
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1710 function rcmail_editor_selector($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1711 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1712 global $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1713
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1714 // determine whether HTML or plain text should be checked
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1715 $useHtml = rcmail_compose_editor_mode();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1716
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1717 if (empty($attrib['editorid']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1718 $attrib['editorid'] = 'rcmComposeBody';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1719
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1720 if (empty($attrib['name']))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1721 $attrib['name'] = 'editorSelect';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1722
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1723 $attrib['onchange'] = "return rcmail.command('toggle-editor', {id: '".$attrib['editorid']."', html: this.value == 'html'}, '', event)";
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1724
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1725 $select = new html_select($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1726
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1727 $select->add(rcube::Q($RCMAIL->gettext('htmltoggle')), 'html');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1728 $select->add(rcube::Q($RCMAIL->gettext('plaintoggle')), 'plain');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1729
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1730 return $select->show($useHtml ? 'html' : 'plain');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1731 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1732
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1733
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1734 function rcmail_store_target_selection($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1735 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1736 global $COMPOSE, $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1737
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1738 $attrib['name'] = '_store_target';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1739 $select = $RCMAIL->folder_selector(array_merge($attrib, array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1740 'noselection' => '- ' . $RCMAIL->gettext('dontsave') . ' -',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1741 'folder_filter' => 'mail',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1742 'folder_rights' => 'w',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1743 )));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1744
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1745 return $select->show(isset($_POST['_store_target']) ? $_POST['_store_target'] : $COMPOSE['param']['sent_mbox'], $attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1746 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1747
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1748
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1749 function rcmail_check_sent_folder($folder, $create=false)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1750 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1751 global $RCMAIL;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1752
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1753 // we'll not save the message, so it doesn't matter
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1754 if ($RCMAIL->config->get('no_save_sent_messages')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1755 return true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1756 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1757
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1758 if ($RCMAIL->storage->folder_exists($folder, true)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1759 return true;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1760 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1761
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1762 // folder may exist but isn't subscribed (#1485241)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1763 if ($create) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1764 if (!$RCMAIL->storage->folder_exists($folder))
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1765 return $RCMAIL->storage->create_folder($folder, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1766 else
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1767 return $RCMAIL->storage->subscribe($folder);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1768 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1769
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1770 return false;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1771 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1772
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1773
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1774 function get_form_tags($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1775 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1776 global $RCMAIL, $MESSAGE_FORM, $COMPOSE;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1777
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1778 $form_start = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1779 if (!$MESSAGE_FORM) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1780 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1781 $hiddenfields->add(array('name' => '_action', 'value' => 'send'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1782 $hiddenfields->add(array('name' => '_id', 'value' => $COMPOSE['id']));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1783 $hiddenfields->add(array('name' => '_attachments'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1784
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1785 $form_start = empty($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1786 $form_start .= $hiddenfields->show();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1787 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1788
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1789 $form_end = ($MESSAGE_FORM && !strlen($attrib['form'])) ? '</form>' : '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1790 $form_name = $attrib['form'] ?: 'form';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1791
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1792 if (!$MESSAGE_FORM)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1793 $RCMAIL->output->add_gui_object('messageform', $form_name);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1794
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1795 $MESSAGE_FORM = $form_name;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1796
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1797 return array($form_start, $form_end);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1798 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1799
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1800
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1801 function rcmail_addressbook_list($attrib = array())
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1802 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1803 global $RCMAIL, $OUTPUT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1804
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1805 $attrib += array('id' => 'rcmdirectorylist');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1806
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1807 $out = '';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1808 $line_templ = html::tag('li', array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1809 'id' => 'rcmli%s', 'class' => '%s'),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1810 html::a(array('href' => '#list',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1811 'rel' => '%s',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1812 'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".command('list-addresses','%s',this)"), '%s'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1813
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1814 foreach ($RCMAIL->get_address_sources(false, true) as $j => $source) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1815 $id = strval(strlen($source['id']) ? $source['id'] : $j);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1816 $js_id = rcube::JQ($id);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1817
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1818 // set class name(s)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1819 $class_name = 'addressbook';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1820 if ($source['class_name'])
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1821 $class_name .= ' ' . $source['class_name'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1822
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1823 $out .= sprintf($line_templ,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1824 rcube_utils::html_identifier($id,true),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1825 $class_name,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1826 $source['id'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1827 $js_id, ($source['name'] ?: $id));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1828 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1829
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1830 $OUTPUT->add_gui_object('addressbookslist', $attrib['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1831
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1832 return html::tag('ul', $attrib, $out, html::$common_attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1833 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1834
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1835 // return the contacts list as HTML table
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1836 function rcmail_contacts_list($attrib = array())
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1837 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1838 global $RCMAIL, $OUTPUT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1839
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1840 $attrib += array('id' => 'rcmAddressList');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1841
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1842 // set client env
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1843 $OUTPUT->add_gui_object('contactslist', $attrib['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1844 $OUTPUT->set_env('pagecount', 0);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1845 $OUTPUT->set_env('current_page', 0);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1846 $OUTPUT->include_script('list.js');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1847
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1848 return $RCMAIL->table_output($attrib, array(), array('name'), 'ID');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1849 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1850
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1851
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1852 /**
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1853 * Register a certain container as active area to drop files onto
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1854 */
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1855 function compose_file_drop_area($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1856 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1857 global $OUTPUT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1858
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1859 if ($attrib['id']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1860 $OUTPUT->add_gui_object('filedrop', $attrib['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1861 $OUTPUT->set_env('filedrop', array('action' => 'upload', 'fieldname' => '_attachments'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1862 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1863 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1864
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1865
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1866 /**
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1867 *
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1868 */
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1869 function rcmail_compose_responses_list($attrib)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1870 {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1871 global $RCMAIL, $OUTPUT;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1872
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1873 $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'ul', 'cols' => 1);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1874
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1875 $jsenv = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1876 $list = new html_table($attrib);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1877 foreach ($RCMAIL->get_compose_responses(true) as $response) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1878 $key = $response['key'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1879 $item = html::a(array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1880 'href' => '#'.urlencode($response['name']),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1881 'class' => rtrim('insertresponse ' . $attrib['itemclass']),
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1882 'unselectable' => 'on',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1883 'tabindex' => '0',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1884 'rel' => $key,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1885 ), rcube::Q($response['name']));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1886
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1887 $jsenv[$key] = $response;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1888 $list->add(array(), $item);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1889 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1890
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1891 // set client env
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1892 $OUTPUT->set_env('textresponses', $jsenv);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1893 $OUTPUT->add_gui_object('responseslist', $attrib['id']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1894
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1895 return $list->show();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1896 }