summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/export.inc2
-rw-r--r--program/steps/addressbook/search.inc7
-rw-r--r--program/steps/mail/compose.inc83
-rw-r--r--program/steps/mail/func.inc17
-rw-r--r--program/steps/mail/headers.inc3
-rw-r--r--program/steps/mail/sendmail.inc15
-rw-r--r--program/steps/mail/viewsource.inc2
-rw-r--r--program/steps/settings/folders.inc12
-rw-r--r--program/steps/settings/func.inc16
-rw-r--r--program/steps/settings/save_folder.inc5
-rw-r--r--program/steps/settings/save_prefs.inc4
11 files changed, 99 insertions, 67 deletions
diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc
index 84a63aebc..850795c85 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -86,7 +86,7 @@ while ($result && ($row = $result->next())) {
foreach ($row as $key => $values) {
list($field, $section) = explode(':', $key);
foreach ((array)$values as $value) {
- if (is_array($value) || strlen($value))
+ if (is_array($value) || @strlen($value))
$vcard->set($field, $value, strtoupper($section));
}
}
diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc
index d31e54b1a..851325070 100644
--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -237,9 +237,12 @@ function rcmail_contact_search()
$OUTPUT->command('set_env', 'source', '');
$OUTPUT->command('set_env', 'group', '');
- // unselect currently selected directory/group
- if (!$sid)
+ if (!$sid) {
+ // unselect currently selected directory/group
$OUTPUT->command('unselect_directory');
+ // enable "Save search" command
+ $OUTPUT->command('enable_command', 'search-create', true);
+ }
$OUTPUT->command('update_group_commands');
// send response
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 71a1c0f21..29e12675e 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -139,7 +139,7 @@ if (!empty($CONFIG['drafts_mbox'])) {
// set current mailbox in client environment
$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false));
-$OUTPUT->set_env('top_posting', $RCMAIL->config->get('top_posting', false));
+$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
// default font for HTML editor
@@ -252,7 +252,8 @@ $MESSAGE->identities = $RCMAIL->user->list_identities();
if (count($MESSAGE->identities))
{
foreach ($MESSAGE->identities as $idx => $ident) {
- $email = mb_strtolower(rcube_idn_to_utf8($ident['email']));
+ $ident['email'] = format_email($ident['email']);
+ $email = format_email(rcube_idn_to_utf8($ident['email']));
$MESSAGE->identities[$idx]['email_ascii'] = $ident['email'];
$MESSAGE->identities[$idx]['ident'] = format_email_recipient($ident['email'], $ident['name']);
@@ -277,7 +278,7 @@ else if (count($MESSAGE->identities)) {
$a_to = rcube_mime::decode_address_list($MESSAGE->headers->to, null, true, $MESSAGE->headers->charset);
foreach ($a_to as $addr) {
if (!empty($addr['mailto'])) {
- $a_recipients[] = strtolower($addr['mailto']);
+ $a_recipients[] = format_email($addr['mailto']);
$a_names[] = $addr['name'];
}
}
@@ -286,7 +287,7 @@ else if (count($MESSAGE->identities)) {
$a_cc = rcube_mime::decode_address_list($MESSAGE->headers->cc, null, true, $MESSAGE->headers->charset);
foreach ($a_cc as $addr) {
if (!empty($addr['mailto'])) {
- $a_recipients[] = strtolower($addr['mailto']);
+ $a_recipients[] = format_email($addr['mailto']);
$a_names[] = $addr['name'];
}
}
@@ -294,16 +295,12 @@ else if (count($MESSAGE->identities)) {
}
$from_idx = null;
- $default_identity = null;
+ $found_idx = null;
+ $default_identity = 0; // default identity is always first on the list
$return_path = $MESSAGE->headers->others['return-path'];
// Select identity
foreach ($MESSAGE->identities as $idx => $ident) {
- // save default identity ID
- if ($ident['standard']) {
- $default_identity = $idx;
- }
-
// use From header
if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) {
if ($MESSAGE->headers->from == $ident['ident']) {
@@ -318,13 +315,22 @@ else if (count($MESSAGE->identities)) {
}
// use replied message recipients
else if (($found = array_search($ident['email_ascii'], $a_recipients)) !== false) {
- // match identity name, prefer default identity
- if ($from_idx === null || ($a_names[$found] && $ident['name'] && $a_names[$found] == $ident['name'])) {
+ if ($found_idx === null) {
+ $found_idx = $idx;
+ }
+ // match identity name
+ if ($a_names[$found] && $ident['name'] && $a_names[$found] == $ident['name']) {
$from_idx = $idx;
+ break;
}
}
}
+ // If matching by name+address doesn't found any amtches, get first found address (identity)
+ if ($from_idx === null) {
+ $from_idx = $found_idx;
+ }
+
// Fallback using Return-Path
if ($from_idx === null && $return_path) {
foreach ($MESSAGE->identities as $idx => $ident) {
@@ -335,12 +341,7 @@ else if (count($MESSAGE->identities)) {
}
}
- // Still no ID, use default/first identity
- if ($from_idx === null) {
- $from_idx = $default_identity !== null ? $default_identity : key(reset($MESSAGE->identities));
- }
-
- $ident = $MESSAGE->identities[$from_idx];
+ $ident = $MESSAGE->identities[$from_idx !== null ? $from_idx : $default_identity];
$from_id = $ident['identity_id'];
$MESSAGE->compose['from_email'] = $ident['email'];
@@ -433,7 +434,7 @@ foreach ($parts as $header) {
if (empty($addr_part['mailto']))
continue;
- $mailto = mb_strtolower(rcube_idn_to_utf8($addr_part['mailto']));
+ $mailto = format_email(rcube_idn_to_utf8($addr_part['mailto']));
if (!in_array($mailto, $a_recipients)
&& ($header == 'to' || empty($MESSAGE->compose['from_email']) || $mailto != $MESSAGE->compose['from_email'])
@@ -529,7 +530,7 @@ function rcmail_compose_headers($attrib)
function rcmail_compose_header_from($attrib)
{
- global $MESSAGE, $OUTPUT;
+ global $MESSAGE, $OUTPUT, $RCMAIL, $compose_mode;
// pass the following attributes to the form class
$field_attrib = array('name' => '_from');
@@ -540,6 +541,8 @@ function rcmail_compose_header_from($attrib)
if (count($MESSAGE->identities))
{
$a_signatures = array();
+ $separator = $RCMAIL->config->get('sig_above')
+ && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD) ? '---' : '-- ';
$field_attrib['onchange'] = JS_OBJECT_NAME.".change_identity(this)";
$select_from = new html_select($field_attrib);
@@ -553,13 +556,27 @@ function rcmail_compose_header_from($attrib)
// add signature to array
if (!empty($sql_arr['signature']) && empty($COMPOSE['param']['nosig']))
{
- $a_signatures[$identity_id]['text'] = $sql_arr['signature'];
- $a_signatures[$identity_id]['is_html'] = ($sql_arr['html_signature'] == 1) ? true : false;
- if ($a_signatures[$identity_id]['is_html'])
- {
- $h2t = new html2text($a_signatures[$identity_id]['text'], false, false);
- $a_signatures[$identity_id]['plain_text'] = trim($h2t->get_text());
+ $text = $html = $sql_arr['signature'];
+
+ if ($sql_arr['html_signature']) {
+ $h2t = new html2text($sql_arr['signature'], false, false);
+ $text = trim($h2t->get_text());
}
+ else {
+ $html = htmlentities($html, ENT_NOQUOTES, RCMAIL_CHARSET);
+ }
+
+ if (!preg_match('/^--[ -]\r?\n/m', $text)) {
+ $text = $separator . "\n" . $text;
+ $html = $separator . "<br>" . $html;
+ }
+
+ if (!$sql_arr['html_signature']) {
+ $html = "<pre>" . $html . "</pre>";
+ }
+
+ $a_signatures[$identity_id]['text'] = $text;
+ $a_signatures[$identity_id]['html'] = $html;
}
}
@@ -593,9 +610,12 @@ function rcmail_compose_editor_mode()
$useHtml = $MESSAGE->has_html_part(false);
}
else if ($compose_mode == RCUBE_COMPOSE_REPLY) {
- $useHtml = ($html_editor == 1 || ($html_editor == 2 && $MESSAGE->has_html_part(false)));
+ $useHtml = ($html_editor == 1 || ($html_editor >= 2 && $MESSAGE->has_html_part(false)));
+ }
+ else if ($compose_mode == RCUBE_COMPOSE_FORWARD) {
+ $useHtml = ($html_editor == 1 || ($html_editor == 3 && $MESSAGE->has_html_part(false)));
}
- else { // RCUBE_COMPOSE_FORWARD or NEW
+ else {
$useHtml = ($html_editor == 1);
}
@@ -624,7 +644,7 @@ function rcmail_prepare_message_body()
rcmail_write_forward_attachment($MESSAGE);
}
// reply/edit/draft/forward
- else if ($compose_mode) {
+ else if ($compose_mode && ($compose_mode != RCUBE_COMPOSE_REPLY || $RCMAIL->config->get('reply_mode') != -1)) {
$isHtml = rcmail_compose_editor_mode();
if (!empty($MESSAGE->parts)) {
@@ -889,8 +909,9 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
$prefix .= "\n";
$suffix = '';
- if ($RCMAIL->config->get('top_posting'))
+ if (intval($RCMAIL->config->get('reply_mode')) > 0) { // top-posting
$prefix = "\n\n\n" . $prefix;
+ }
}
else {
// save inline images to files
@@ -904,7 +925,7 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
$prefix = '<p>' . Q($prefix) . "</p>\n";
$prefix .= '<blockquote>';
- if ($RCMAIL->config->get('top_posting')) {
+ if (intval($RCMAIL->config->get('reply_mode')) > 0) { // top-posting
$prefix = '<br>' . $prefix;
$suffix = '</blockquote>';
}
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 3d65eacb1..8bf80a6ee 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -90,11 +90,13 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
// set current mailbox and some other vars in client environment
$OUTPUT->set_env('mailbox', $mbox_name);
$OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize());
- $OUTPUT->set_env('quota', $RCMAIL->storage->get_capability('QUOTA'));
$OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter());
$OUTPUT->set_env('threading', $threading);
$OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD'));
$OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0));
+ if ($RCMAIL->storage->get_capability('QUOTA')) {
+ $OUTPUT->set_env('quota', true);
+ }
if ($CONFIG['delete_junk'])
$OUTPUT->set_env('delete_junk', true);
@@ -1053,12 +1055,17 @@ function rcmail_message_full_headers($attrib, $headers=NULL)
global $OUTPUT;
$html = html::div(array('id' => "all-headers", 'class' => "all", 'style' => 'display:none'), html::div(array('id' => 'headers-source'), ''));
- $html .= html::div(array('class' => "more-headers show-headers", 'onclick' => "return ".JS_OBJECT_NAME.".command('show-headers','',this)"), '');
+
+ if (!get_boolean($attrib['no-switch'])) {
+ $html .= html::div(array('class' => "more-headers show-headers", 'onclick' => "return ".JS_OBJECT_NAME.".command('show-headers','',this)"), '');
+ }
+
+ unset($attrib['no-switch']);
$OUTPUT->add_gui_object('all_headers_row', 'all-headers');
$OUTPUT->add_gui_object('all_headers_box', 'headers-source');
- return html::div($attrib, $html);
+ return count($attrib) > 1 ? html::div($attrib, $html) : $html;
}
@@ -1712,8 +1719,10 @@ function rcmail_search_filter($attrib)
$select_filter->add(rcube_label('unread'), 'UNSEEN');
$select_filter->add(rcube_label('flagged'), 'FLAGGED');
$select_filter->add(rcube_label('unanswered'), 'UNANSWERED');
- if (!$CONFIG['skip_deleted'])
+ if (!$CONFIG['skip_deleted']) {
$select_filter->add(rcube_label('deleted'), 'DELETED');
+ $select_filter->add(rcube_label('undeleted'), 'UNDELETED');
+ }
$select_filter->add(rcube_label('priority').': '.rcube_label('highest'), 'HEADER X-PRIORITY 1');
$select_filter->add(rcube_label('priority').': '.rcube_label('high'), 'HEADER X-PRIORITY 2');
$select_filter->add(rcube_label('priority').': '.rcube_label('normal'), 'NOT HEADER X-PRIORITY 1 NOT HEADER X-PRIORITY 2 NOT HEADER X-PRIORITY 4 NOT HEADER X-PRIORITY 5');
diff --git a/program/steps/mail/headers.inc b/program/steps/mail/headers.inc
index 4d6627393..cad113f68 100644
--- a/program/steps/mail/headers.inc
+++ b/program/steps/mail/headers.inc
@@ -24,7 +24,8 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_POST))
$source = $RCMAIL->storage->get_raw_headers($uid);
if ($source !== false) {
- $source = htmlspecialchars(trim($source));
+ $source = trim(rcube_charset::clean($source));
+ $source = htmlspecialchars($source);
$source = preg_replace(
array(
'/\n[\t\s]+/',
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 70f1af714..577751742 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -511,14 +511,9 @@ if ($isHtml) {
$h2t = new html2text($plugin['body'], false, true, 0);
$plainTextPart = rc_wordwrap($h2t->get_text(), $LINE_LENGTH, "\r\n");
$plainTextPart = wordwrap($plainTextPart, 998, "\r\n", true);
- if (!$plainTextPart) {
- // empty message body breaks attachment handling in drafts
- $plainTextPart = "\r\n";
- }
- else {
- // make sure all line endings are CRLF (#1486712)
- $plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
- }
+
+ // make sure all line endings are CRLF (#1486712)
+ $plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
$plugin = $RCMAIL->plugins->exec_hook('message_outgoing_body',
array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME));
@@ -542,10 +537,6 @@ else {
$message_body = rc_wordwrap($message_body, $LINE_LENGTH, "\r\n");
$message_body = wordwrap($message_body, 998, "\r\n", true);
- if (!strlen($message_body)) {
- // empty message body breaks attachment handling in drafts
- $message_body = "\r\n";
- }
$MAIL_MIME->setTXTBody($message_body, false, true);
}
diff --git a/program/steps/mail/viewsource.inc b/program/steps/mail/viewsource.inc
index 59ccb386e..c560d7d41 100644
--- a/program/steps/mail/viewsource.inc
+++ b/program/steps/mail/viewsource.inc
@@ -44,7 +44,7 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET))
header("Content-Disposition: attachment; filename=\"$filename\"");
}
- $RCMAIL->storage->print_raw_body($uid);
+ $RCMAIL->storage->print_raw_body($uid, empty($_GET['_save']));
}
else
{
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index 2691a6e26..6ca704998 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -44,8 +44,8 @@ if ($RCMAIL->action == 'subscribe')
if ($result) {
// Handle subscription of protected folder (#1487656)
- if ($CONFIG['protect_default_folders'] == true
- && in_array($mbox, $CONFIG['default_folders'])
+ if ($RCMAIL->config->get('protect_default_folders')
+ && in_array($mbox, (array)$RCMAIL->config->get('default_folders'))
) {
$OUTPUT->command('disable_subscription', $mbox);
}
@@ -321,8 +321,8 @@ function rcube_subscription_form($attrib)
}
}
}
- // check if the folder is shared, then disable subscription option on it
- if (!$disabled && $folder['virtual'] && !empty($namespace)) {
+ // check if the folder is shared, then disable subscription option on it (if not subscribed already)
+ if (!$disabled && !$subscribed && $folder['virtual'] && !empty($namespace)) {
$tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
foreach ($tmp_ns as $item) {
if (strpos($folder['id'], $item[0]) === 0) {
@@ -411,8 +411,10 @@ function rcmail_rename_folder($oldname, $newname)
$OUTPUT->set_pagetitle(rcube_label('folders'));
$OUTPUT->include_script('list.js');
-$OUTPUT->set_env('quota', $STORAGE->get_capability('QUOTA'));
$OUTPUT->set_env('prefix_ns', $STORAGE->get_namespace('prefix'));
+if ($STORAGE->get_capability('QUOTA')) {
+ $OUTPUT->set_env('quota', true);
+}
// add some labels to client
$OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting',
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 3f5ef5390..59b4e3735 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -470,6 +470,7 @@ function rcmail_user_prefs($current=null)
$select_htmleditor->add(rcube_label('never'), 0);
$select_htmleditor->add(rcube_label('always'), 1);
$select_htmleditor->add(rcube_label('htmlonreply'), 2);
+ $select_htmleditor->add(rcube_label('htmlonreplyandforward'), 3);
$blocks['main']['options']['htmleditor'] = array(
'title' => html::label($field_id, Q(rcube_label('htmleditor'))),
@@ -544,16 +545,17 @@ function rcmail_user_prefs($current=null)
);
}
- if (!isset($no_override['top_posting'])) {
- $field_id = 'rcmfd_top_posting';
- $select_replymode = new html_select(array('name' => '_top_posting', 'id' => $field_id,
- 'onchange' => "\$('#rcmfd_sig_above').attr('disabled',this.selectedIndex==0)"));
+ if (!isset($no_override['reply_mode'])) {
+ $field_id = 'rcmfd_reply_mode';
+ $select_replymode = new html_select(array('name' => '_reply_mode', 'id' => $field_id,
+ 'onchange' => "\$('#rcmfd_sig_above').attr('disabled',this.selectedIndex<2)"));
+ $select_replymode->add(rcube_label('replyempty'), -1);
$select_replymode->add(rcube_label('replybottomposting'), 0);
$select_replymode->add(rcube_label('replytopposting'), 1);
- $blocks['main']['options']['top_posting'] = array(
+ $blocks['main']['options']['reply_mode'] = array(
'title' => html::label($field_id, Q(rcube_label('whenreplying'))),
- 'content' => $select_replymode->show($config['top_posting']?1:0),
+ 'content' => $select_replymode->show(intval($config['reply_mode'])),
);
}
@@ -597,7 +599,7 @@ function rcmail_user_prefs($current=null)
if (!isset($no_override['sig_above'])) {
$field_id = 'rcmfd_sig_above';
- $select_sigabove = new html_select(array('name' => '_sig_above', 'id' => $field_id, 'disabled' => !$config['top_posting']));
+ $select_sigabove = new html_select(array('name' => '_sig_above', 'id' => $field_id, 'disabled' => $config['reply_mode'] < 1));
$select_sigabove->add(rcube_label('belowquote'), 0);
$select_sigabove->add(rcube_label('abovequote'), 1);
diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc
index 09f76ac27..73cc5e4bf 100644
--- a/program/steps/settings/save_folder.inc
+++ b/program/steps/settings/save_folder.inc
@@ -80,7 +80,10 @@ if (!$error && strlen($path) && (!strlen($old_imap) || $old_imap != $name_imap))
}
}
-if (!$error) {
+if ($error) {
+ $OUTPUT->command('display_message', $error, 'error');
+}
+else {
$folder['name'] = $name_imap;
$folder['oldname'] = $old_imap;
$folder['class'] = '';
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 88fa5298a..dc149929e 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -82,9 +82,9 @@ switch ($CURR_SECTION)
'spellcheck_ignore_nums' => isset($_POST['_spellcheck_ignore_nums']) ? TRUE : FALSE,
'spellcheck_ignore_caps' => isset($_POST['_spellcheck_ignore_caps']) ? TRUE : FALSE,
'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1,
- 'top_posting' => !empty($_POST['_top_posting']),
+ 'reply_mode' => isset($_POST['_reply_mode']) ? intval($_POST['_reply_mode']) : 0,
'strip_existing_sig' => isset($_POST['_strip_existing_sig']),
- 'sig_above' => !empty($_POST['_sig_above']) && !empty($_POST['_top_posting']),
+ 'sig_above' => !empty($_POST['_sig_above']) && $_POST['_reply_mode'] < 1,
'default_font' => get_input_value('_default_font', RCUBE_INPUT_POST),
'forward_attachment' => !empty($_POST['_forward_attachment']),
);