summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/export.inc25
-rw-r--r--program/steps/mail/autocomplete.inc54
-rw-r--r--program/steps/mail/compose.inc3
-rw-r--r--program/steps/mail/func.inc13
-rw-r--r--program/steps/mail/get.inc2
-rw-r--r--program/steps/mail/sendmail.inc59
-rw-r--r--program/steps/settings/folders.inc2
7 files changed, 94 insertions, 64 deletions
diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc
index c2f22cbe2..9fbdb9663 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -121,14 +121,11 @@ exit;
*/
function prepare_for_export(&$record, $source = null)
{
- $groups = $source && $source->groups && $source->export_groups ? $source->get_record_groups($record['ID']) : null;
+ $groups = $source && $source->groups && $source->export_groups ? $source->get_record_groups($record['ID']) : null;
+ $fieldmap = $source ? $source->vcard_map : null;
if (empty($record['vcard'])) {
- $vcard = new rcube_vcard();
- if ($source) {
- $vcard->extend_fieldmap($source->vcard_map);
- }
- $vcard->load($record['vcard']);
+ $vcard = new rcube_vcard($record['vcard'], RCUBE_CHARSET, false, $fieldmap);
$vcard->reset();
foreach ($record as $key => $values) {
@@ -151,11 +148,19 @@ function prepare_for_export(&$record, $source = null)
$vcard->set('groups', join(',', $groups), null);
}
- $record['vcard'] = $vcard->export(true);
+ $record['vcard'] = $vcard->export();
}
// patch categories to alread existing vcard block
- else if ($record['vcard'] && !empty($groups) && !strpos($record['vcard'], 'CATEGORIES:')) {
- $vgroups = 'CATEGORIES:' . rcube_vcard::vcard_quote(join(',', $groups));
- $record['vcard'] = str_replace('END:VCARD', $vgroups . rcube_vcard::$eol . 'END:VCARD', $record['vcard']);
+ else if ($record['vcard']) {
+ $vcard = new rcube_vcard($record['vcard'], RCUBE_CHARSET, false, $fieldmap);
+
+ // unset CATEGORIES entry, it might be not up-to-date (#1490277)
+ $vcard->set('groups', null);
+ $record['vcard'] = $vcard->export();
+
+ if (!empty($groups)) {
+ $vgroups = 'CATEGORIES:' . rcube_vcard::vcard_quote($groups, ',');
+ $record['vcard'] = str_replace('END:VCARD', $vgroups . rcube_vcard::$eol . 'END:VCARD', $record['vcard']);
+ }
}
}
diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc
index 30b8f2299..38501eb9d 100644
--- a/program/steps/mail/autocomplete.inc
+++ b/program/steps/mail/autocomplete.inc
@@ -88,16 +88,18 @@ if (!empty($book_types) && strlen($search)) {
continue;
}
+ $index = $contact;
+
// skip duplicates
- if (!in_array($contact, $contacts)) {
+ if (empty($contacts[$index])) {
$contact = array('name' => $contact, 'type' => $sql_arr['_type']);
if (($display = rcube_addressbook::compose_search_name($sql_arr, $email, $name)) && $display != $contact['name']) {
$contact['display'] = $display;
}
- $contacts[] = $contact;
- $sort_keys[] = sprintf('%s %03d', $contact['display'] ?: $name, $idx++);
+ $contacts[$index] = $contact;
+ $sort_keys[$index] = sprintf('%s %03d', $contact['display'] ?: $name, $idx++);
if (count($contacts) >= $MAXNUM) {
break 2;
@@ -124,34 +126,40 @@ if (!empty($book_types) && strlen($search)) {
if ($group_prop['email']) {
$idx = 0;
foreach ((array)$group_prop['email'] as $email) {
- $contacts[] = array(
- 'name' => format_email_recipient($email, $group['name']),
- 'email' => $email,
+ $index = format_email_recipient($email, $group['name']);
+
+ if (empty($contacts[$index])) {
+ $sort_keys[$index] = sprintf('%s %03d', $group['name'] , $idx++);
+ $contacts[$index] = array(
+ 'name' => $index,
+ 'email' => $email,
+ 'type' => 'group',
+ 'id' => $group['ID'],
+ 'source' => $id,
+ );
+
+ if (count($contacts) >= $MAXNUM) {
+ break 2;
+ }
+ }
+ }
+ }
+ // show group with count
+ else if (($result = $abook->count()) && $result->count) {
+ if (empty($contacts[$group['name']])) {
+ $sort_keys[$group['name']] = $group['name'];
+ $contacts[$group['name']] = array(
+ 'name' => $group['name'] . ' (' . intval($result->count) . ')',
'type' => 'group',
'id' => $group['ID'],
- 'source' => $id,
+ 'source' => $id
);
- $sort_keys[] = sprintf('%s %03d', $group['name'] , $idx++);
if (count($contacts) >= $MAXNUM) {
- break 2;
+ break;
}
}
}
- // show group with count
- else if (($result = $abook->count()) && $result->count) {
- $sort_keys[] = $group['name'];
- $contacts[] = array(
- 'name' => $group['name'] . ' (' . intval($result->count) . ')',
- 'type' => 'group',
- 'id' => $group['ID'],
- 'source' => $id
- );
-
- if (count($contacts) >= $MAXNUM) {
- break;
- }
- }
}
}
}
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index db4efc7ce..4c3ecfbc0 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -83,7 +83,7 @@ $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubj
'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany',
'fileuploaderror', 'sendmessage', 'newresponse', 'responsename', 'responsetext', 'save',
'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore',
- 'selectimportfile');
+ 'selectimportfile', 'messageissent');
$OUTPUT->set_pagetitle($RCMAIL->gettext('compose'));
@@ -93,6 +93,7 @@ $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
$OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage'));
+$OUTPUT->set_env('is_sent', false);
$drafts_mbox = $RCMAIL->config->get('drafts_mbox');
$config_show_sig = $RCMAIL->config->get('show_sig', 1);
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index c45fd2f97..341c14bc8 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -399,6 +399,7 @@ function rcmail_js_message_list($a_headers, $insert_top=false, $a_show_cols=null
$head_replace = true;
}
+ $delimiter = $RCMAIL->storage->get_hierarchy_delimiter();
$search_set = $RCMAIL->storage->get_search_set();
$multifolder = $search_set && $search_set[1]->multi;
@@ -489,8 +490,16 @@ function rcmail_js_message_list($a_headers, $insert_top=false, $a_show_cols=null
$cont = show_bytes($header->$col);
else if ($col == 'date')
$cont = $RCMAIL->format_date($header->date);
- else if ($col == 'folder')
- $cont = rcube::Q(rcube_charset::convert($header->folder, 'UTF7-IMAP'));
+ else if ($col == 'folder') {
+ if ($last_folder !== $header->folder) {
+ $last_folder = $header->folder;
+ $last_folder_name = rcube_charset::convert($last_folder, 'UTF7-IMAP');
+ $last_folder_name = $RCMAIL->localize_foldername($last_folder_name, true);
+ $last_folder_name = str_replace($delimiter, " \xC2\xBB ", $last_folder_name);
+ }
+
+ $cont = rcube::Q($last_folder_name);
+ }
else
$cont = rcube::Q($header->$col);
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 02ec5a4ac..5803e0c5a 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -164,7 +164,7 @@ else if (strlen($part_id)) {
else {
// get valid file extensions
$extensions = rcube_mime::get_mime_extensions($real_mimetype);
- $valid_extension = !$file_extension || in_array($file_extension, (array)$extensions);
+ $valid_extension = !$file_extension || empty($extensions) || in_array($file_extension, (array)$extensions);
}
// fix mimetype for images wrongly declared as octet-stream
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 5843de43f..5326d6452 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -24,7 +24,8 @@
$OUTPUT->reset();
$OUTPUT->framed = TRUE;
-$savedraft = !empty($_POST['_draft']) ? true : false;
+$saveonly = !empty($_GET['_saveonly']);
+$savedraft = !empty($_POST['_draft']) && !$saveonly;
$sendmail_delay = (int) $RCMAIL->config->get('sendmail_delay');
$drafts_mbox = $RCMAIL->config->get('drafts_mbox');
@@ -504,19 +505,11 @@ $MAIL_MIME->setParam('head_charset', $message_charset);
$MAIL_MIME->setParam('html_charset', $message_charset);
$MAIL_MIME->setParam('text_charset', $text_charset);
-// encoding subject header with mb_encode provides better results with asian characters
-if (function_exists('mb_encode_mimeheader')) {
- mb_internal_encoding($message_charset);
- $headers['Subject'] = mb_encode_mimeheader($headers['Subject'],
- $message_charset, 'Q', "\r\n", 8);
- mb_internal_encoding(RCUBE_CHARSET);
-}
-
// pass headers to message object
$MAIL_MIME->headers($headers);
// Begin SMTP Delivery Block
-if (!$savedraft) {
+if (!$savedraft && !$saveonly) {
// check 'From' address (identity may be incomplete)
if (empty($from)) {
$OUTPUT->show_message('nofromaddress', 'error');
@@ -600,8 +593,9 @@ if ($store_target) {
else {
$temp_dir = $RCMAIL->config->get('temp_dir');
$mailbody_file = tempnam($temp_dir, 'rcmMsg');
+ $msg = $MAIL_MIME->saveMessageBody($mailbody_file);
- if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) {
+ if (!is_a($msg, 'PEAR_Error')) {
$msg = $mailbody_file;
}
}
@@ -611,7 +605,7 @@ if ($store_target) {
$headers = '';
}
- if (PEAR::isError($msg)) {
+ if (is_a($msg, 'PEAR_Error')) {
rcube::raise_error(array('code' => 650, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not create message: ".$msg->getMessage()),
@@ -635,7 +629,8 @@ if ($store_target) {
'message' => "Could not save message in $store_target"), true, false);
if ($savedraft) {
- $OUTPUT->show_message('errorsaving', 'error');
+ $RCMAIL->display_server_error('errorsaving');
+
// start the auto-save timer again
$OUTPUT->command('auto_save_start');
$OUTPUT->send('iframe');
@@ -688,24 +683,36 @@ else {
// we'll refresh the list if currently opened folder is one of them (#1490238)
$folders = array();
- if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) {
- $folders[] = $COMPOSE['mailbox'];
- }
- if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) {
- $folders[] = $drafts_mbox;
+ if (!$saveonly) {
+ if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) {
+ $folders[] = $COMPOSE['mailbox'];
+ }
+ if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) {
+ $folders[] = $drafts_mbox;
+ }
}
- rcmail_compose_cleanup($COMPOSE_ID);
- $OUTPUT->command('remove_compose_data', $COMPOSE_ID);
-
if ($store_folder && !$saved) {
- $OUTPUT->command('sent_successfully', 'error', $RCMAIL->gettext('errorsavingsent'), $folders);
+ $params = $saveonly ? null : array('prefix' => true);
+ $RCMAIL->display_server_error('errorsavingsent', null, null, $params);
+ if ($saveonly) {
+ $OUTPUT->send('iframe');
+ }
+
+ $save_error = true;
}
- else if ($store_folder) {
- $folders[] = $store_target;
+ else {
+ rcmail_compose_cleanup($COMPOSE_ID);
+ $OUTPUT->command('remove_compose_data', $COMPOSE_ID);
+
+ if ($store_folder) {
+ $folders[] = $store_target;
+ }
}
- $OUTPUT->command('sent_successfully', 'confirmation', $RCMAIL->gettext('messagesent'), $folders);
+ $msg = $RCMAIL->gettext($saveonly ? 'successfullysaved' : 'messagesent');
+
+ $OUTPUT->command('sent_successfully', 'confirmation', $msg, $folders, $save_error);
}
$OUTPUT->send('iframe');
@@ -786,7 +793,7 @@ function rcmail_fix_emoticon_paths($mime_message)
if (!in_array($image_name, $included_images)) {
// add the image to the MIME message
$res = $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name);
- if (PEAR::isError($res)) {
+ if (is_a($res, 'PEAR_Error')) {
$RCMAIL->output->show_message("emoticonerror", 'error');
continue;
}
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index 6db0b17e8..443635fae 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -265,7 +265,7 @@ function rcmail_subscription_form($attrib)
$js_folders = array();
$folders = array();
- $collapsed = $RCMAIL->config->get('collapsed_folders');
+ $collapsed = (string) $RCMAIL->config->get('collapsed_folders');
// create list of available folders
foreach ($list_folders as $i => $folder) {