summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/addcontact.inc13
-rw-r--r--program/steps/mail/autocomplete.inc4
-rw-r--r--program/steps/mail/compose.inc22
-rw-r--r--program/steps/mail/func.inc33
-rw-r--r--program/steps/mail/list_contacts.inc3
-rw-r--r--program/steps/mail/sendmail.inc13
-rw-r--r--program/steps/mail/show.inc16
7 files changed, 65 insertions, 39 deletions
diff --git a/program/steps/mail/addcontact.inc b/program/steps/mail/addcontact.inc
index 2dc406f84..380557766 100644
--- a/program/steps/mail/addcontact.inc
+++ b/program/steps/mail/addcontact.inc
@@ -23,17 +23,8 @@
if (!$OUTPUT->ajax_call)
return;
-$abook = $RCMAIL->config->get('default_addressbook');
-
-// Get configured addressbook
-$CONTACTS = $RCMAIL->get_address_book($abook, true);
-
-// Get first writeable addressbook if the configured doesn't exist
-// This can happen when user deleted the addressbook (e.g. Kolab folder)
-if ($abook == null || !is_object($CONTACTS)) {
- $source = reset($RCMAIL->get_address_sources(true));
- $CONTACTS = $RCMAIL->get_address_book($source['id'], true);
-}
+// Get default addressbook
+$CONTACTS = $RCMAIL->get_address_book(-1, true);
if (!empty($_POST['_address']) && is_object($CONTACTS))
{
diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc
index ba34fa5aa..55579814c 100644
--- a/program/steps/mail/autocomplete.inc
+++ b/program/steps/mail/autocomplete.inc
@@ -26,7 +26,7 @@ if ($RCMAIL->action == 'group-expand') {
$members = array();
$abook->set_group($gid);
$abook->set_pagesize(1000); // TODO: limit number of group members by config
- $result = $abook->list_records(array('name', 'firstname', 'surname', 'email'));
+ $result = $abook->list_records($RCMAIL->config->get('contactlist_fields'));
while ($result && ($sql_arr = $result->iterate())) {
foreach ((array)$sql_arr['email'] as $email) {
$members[] = format_email_recipient($email, rcube_addressbook::compose_list_name($sql_arr));
@@ -64,7 +64,7 @@ if (!empty($book_types) && strlen($search)) {
$abook = $RCMAIL->get_address_book($id);
$abook->set_pagesize($MAXNUM);
- if ($result = $abook->search(array('name', 'firstname', 'surname', 'email'), $search, $mode, true, true, 'email')) {
+ if ($result = $abook->search($RCMAIL->config->get('contactlist_fields'), $search, $mode, true, true, 'email')) {
while ($sql_arr = $result->iterate()) {
// Contact can have more than one e-mail address
$email_arr = (array)$abook->get_col_values('email', $sql_arr, true);
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 70f657d8d..57869d1f7 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -629,7 +629,8 @@ function rcmail_prepare_message_body()
if (!empty($MESSAGE->parts)) {
foreach ($MESSAGE->parts as $part) {
- if ($part->type != 'content' || !$part->size) {
+ // skip no-content and attachment parts (#1488557)
+ if ($part->type != 'content' || !$part->size || $MESSAGE->is_attachment($part)) {
continue;
}
@@ -662,10 +663,10 @@ function rcmail_prepare_message_body()
unset($plugin);
// add blocked.gif attachment (#1486516)
- if ($isHtml && preg_match('#<img src="\./program/blocked\.gif"#', $body)) {
- if ($attachment = rcmail_save_image('program/blocked.gif', 'image/gif')) {
+ if ($isHtml && preg_match('#<img src="\./program/resources/blocked\.gif"#', $body)) {
+ if ($attachment = rcmail_save_image('program/resources/blocked.gif', 'image/gif')) {
$COMPOSE['attachments'][$attachment['id']] = $attachment;
- $body = preg_replace('#\./program/blocked\.gif#',
+ $body = preg_replace('#\./program/resources/blocked\.gif#',
$RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id'].'&_id='.$COMPOSE['id'],
$body);
}
@@ -842,7 +843,7 @@ function rcmail_compose_body($attrib)
"googie.decorateTextarea('%s');\n".
"%s.set_env('spellcheck', googie);",
$RCMAIL->output->get_skin_path(),
- $RCMAIL->url(array('_task' => 'utils', '_action' => 'spell')),
+ $RCMAIL->url(array('_task' => 'utils', '_action' => 'spell', '_remote' => 1)),
!empty($dictionary) ? 'true' : 'false',
JQ(Q(rcube_label('checkspelling'))),
JQ(Q(rcube_label('resumeediting'))),
@@ -859,7 +860,7 @@ function rcmail_compose_body($attrib)
$OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set));
}
- $out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>';
+ $out .= "\n".'<iframe name="savetarget" src="program/resources/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>';
return $out;
}
@@ -958,18 +959,18 @@ function rcmail_create_forward_body($body, $bodyIsHtml)
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
rcube_label('subject'), Q($MESSAGE->subject),
rcube_label('date'), Q($date),
- rcube_label('from'), htmlspecialchars(Q($MESSAGE->get_header('from'), 'replace'), ENT_COMPAT, $charset),
- rcube_label('to'), htmlspecialchars(Q($MESSAGE->get_header('to'), 'replace'), ENT_COMPAT, $charset));
+ rcube_label('from'), Q($MESSAGE->get_header('from'), 'replace'),
+ rcube_label('to'), Q($MESSAGE->get_header('to'), 'replace'));
if ($MESSAGE->headers->cc)
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
rcube_label('cc'),
- htmlspecialchars(Q($MESSAGE->get_header('cc'), 'replace'), ENT_COMPAT, $charset));
+ Q($MESSAGE->get_header('cc'), 'replace'));
if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from)
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
rcube_label('replyto'),
- htmlspecialchars(Q($MESSAGE->get_header('replyto'), 'replace'), ENT_COMPAT, $charset));
+ Q($MESSAGE->get_header('replyto'), 'replace'));
$prefix .= "</tbody></table><br>";
}
@@ -1522,6 +1523,7 @@ function get_form_tags($attrib)
$hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task));
$hiddenfields->add(array('name' => '_action', 'value' => 'send'));
$hiddenfields->add(array('name' => '_id', 'value' => $COMPOSE['id']));
+ $hiddenfields->add(array('name' => '_attachments'));
$form_start = empty($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : '';
$form_start .= $hiddenfields->show();
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 5a18ded6b..ddd34315a 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -398,7 +398,7 @@ function rcmail_messagecontent_frame($attrib)
if ($RCMAIL->config->get('preview_pane'))
$OUTPUT->set_env('contentframe', $attrib['id']);
- $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
+ $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/resources/blank.gif');
return html::iframe($attrib);
}
@@ -518,21 +518,26 @@ function rcmail_check_safe(&$message)
{
global $RCMAIL;
- $show_images = $RCMAIL->config->get('show_images');
if (!$message->is_safe
- && !empty($show_images)
- && $message->has_html_part())
- {
- switch($show_images) {
- case '1': // known senders only
- $CONTACTS = new rcube_contacts($RCMAIL->db, $_SESSION['user_id']);
- if ($CONTACTS->search('email', $message->sender['mailto'], true, false)->count) {
- $message->set_safe(true);
+ && ($show_images = $RCMAIL->config->get('show_images'))
+ && $message->has_html_part()
+ ) {
+ switch ($show_images) {
+ case 1: // known senders only
+ // get default addressbook, like in addcontact.inc
+ $CONTACTS = $RCMAIL->get_address_book(-1, true);
+
+ if ($CONTACTS) {
+ $result = $CONTACTS->search('email', $message->sender['mailto'], 1, false);
+ if ($result->count) {
+ $message->set_safe(true);
+ }
}
- break;
- case '2': // always
+ break;
+
+ case 2: // always
$message->set_safe(true);
- break;
+ break;
}
}
}
@@ -605,7 +610,7 @@ function rcmail_wash_html($html, $p, $cid_replaces)
$wash_opts = array(
'show_washed' => false,
'allow_remote' => $p['safe'],
- 'blocked_src' => "./program/blocked.gif",
+ 'blocked_src' => "./program/resources/blocked.gif",
'charset' => RCMAIL_CHARSET,
'cid_map' => $cid_replaces,
'html_elements' => array('body'),
diff --git a/program/steps/mail/list_contacts.inc b/program/steps/mail/list_contacts.inc
index 1a6480339..7c99a1309 100644
--- a/program/steps/mail/list_contacts.inc
+++ b/program/steps/mail/list_contacts.inc
@@ -57,7 +57,8 @@ if ($CONTACTS && $CONTACTS->ready) {
// get contacts for this user
$CONTACTS->set_group(0);
- $result = $CONTACTS->list_records(array('name', 'firstname', 'surname', 'email'));
+ $afields = $RCMAIL->config->get('contactlist_fields');
+ $result = $CONTACTS->list_records($afields);
if (!$result->count && $result->searchonly) {
$OUTPUT->show_message('contactsearchonly', 'notice');
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 4790d35e2..70f1af714 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -458,6 +458,19 @@ if ($isHtml) {
$message_body .= "\r\n</body></html>\r\n";
}
+// sort attachments to make sure the order is the same as in the UI (#1488423)
+$files = get_input_value('_attachments', RCUBE_INPUT_POST);
+if ($files) {
+ $files = explode(',', $files);
+ $files = array_flip($files);
+ foreach ($files as $idx => $val) {
+ $files[$idx] = $COMPOSE['attachments'][$idx];
+ unset($COMPOSE['attachments'][$idx]);
+ }
+
+ $COMPOSE['attachments'] = array_merge(array_filter($files), $COMPOSE['attachments']);
+}
+
// set line length for body wrapping
$LINE_LENGTH = $RCMAIL->config->get('line_length', 72);
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 5fa72d77f..82c826108 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -257,7 +257,7 @@ function rcmail_contact_exists($email)
if ($email) {
// @TODO: search in all address books?
- $CONTACTS = $RCMAIL->get_address_book(null, true);
+ $CONTACTS = $RCMAIL->get_address_book(-1, true);
$existing = $CONTACTS->search('email', $email, true, false);
if ($existing->count)
return true;
@@ -266,11 +266,25 @@ function rcmail_contact_exists($email)
return false;
}
+function rcmail_message_contactphoto($attrib)
+{
+ global $RCMAIL, $MESSAGE;
+
+ $placeholder = $attrib['placeholder'] ? $RCMAIL->config->get('skin_path') . $attrib['placeholder'] : null;
+ if ($MESSAGE->sender)
+ $photo_img = $RCMAIL->url(array('_task' => 'addressbook', '_action' => 'photo', '_email' => $MESSAGE->sender['mailto'], '_alt' => $placeholder));
+ else
+ $photo_img = $placeholder ? $placeholder : 'program/resources/blank.gif';
+
+ return html::img(array('src' => $photo_img) + $attrib);
+}
+
$OUTPUT->add_handlers(array(
'messageattachments' => 'rcmail_message_attachments',
'mailboxname' => 'rcmail_mailbox_name_display',
'messageobjects' => 'rcmail_message_objects',
+ 'contactphoto' => 'rcmail_message_contactphoto',
));