summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/save.inc6
-rw-r--r--program/steps/addressbook/upload_photo.inc10
-rw-r--r--program/steps/mail/compose.inc48
3 files changed, 40 insertions, 24 deletions
diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc
index c463bf7fe..ddbd630ef 100644
--- a/program/steps/addressbook/save.inc
+++ b/program/steps/addressbook/save.inc
@@ -104,12 +104,13 @@ if (isset($a_record['photo'])) {
$RCMAIL->session->remove('contacts');
}
+$source = get_input_value('_source', RCUBE_INPUT_GPC);
// update an existing contact
if (!empty($cid))
{
$plugin = $RCMAIL->plugins->exec_hook('contact_update',
- array('id' => $cid, 'record' => $a_record, 'source' => get_input_value('_source', RCUBE_INPUT_GPC)));
+ array('id' => $cid, 'record' => $a_record, 'source' => $source));
$a_record = $plugin['record'];
if (!$plugin['abort'])
@@ -136,7 +137,7 @@ if (!empty($cid))
$a_js_cols[] = Q((string)$record[$col]);
// update the changed col in list
- $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols, $newcid);
+ $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols, $newcid, $source);
// show confirmation
$OUTPUT->show_message('successfullysaved', 'confirmation', null, false);
@@ -152,7 +153,6 @@ if (!empty($cid))
// insert a new contact
else {
- $source = get_input_value('_source', RCUBE_INPUT_GPC);
// Name of the addressbook already selected on the list
$orig_source = get_input_value('_orig_source', RCUBE_INPUT_GPC);
diff --git a/program/steps/addressbook/upload_photo.inc b/program/steps/addressbook/upload_photo.inc
index 1ed71f8cb..f0430ae80 100644
--- a/program/steps/addressbook/upload_photo.inc
+++ b/program/steps/addressbook/upload_photo.inc
@@ -19,14 +19,20 @@
*/
+// Supported image format types
+// ImageMagick works with other non-image types (e.g.pdf) we don't want here
+$IMAGE_TYPES = explode(',', 'jpeg,jpg,jp2,tiff,tif,bmp,eps,gif,png,png8,png24,png32,svg,ico');
+
// clear all stored output properties (like scripts and env vars)
$OUTPUT->reset();
-console($_FILES);
+
if ($filepath = $_FILES['_photo']['tmp_name']) {
// check file type and resize image
$imageprop = rcmail::imageprops($_FILES['_photo']['tmp_name']);
- if ($imageprop['width'] && $imageprop['height']) {
+ if (in_array(strtolower($imageprop['type']), $IMAGE_TYPES)
+ && $imageprop['width'] && $imageprop['height']
+ ) {
$maxsize = intval($RCMAIL->config->get('contact_photo_size', 160));
$tmpfname = tempnam($RCMAIL->config->get('temp_dir'), 'rcmImgConvert');
$save_hook = 'attachment_upload';
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 9a94ff742..4449ea0b2 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -225,9 +225,11 @@ $MESSAGE->compose = array();
$MESSAGE->identities = $USER->list_identities();
if (count($MESSAGE->identities))
{
- foreach ($MESSAGE->identities as $idx => $sql_arr) {
- $email = mb_strtolower(rcube_idn_to_utf8($sql_arr['email']));
- $MESSAGE->identities[$idx]['email_ascii'] = $sql_arr['email'];
+ foreach ($MESSAGE->identities as $idx => $ident) {
+ $email = mb_strtolower(rcube_idn_to_utf8($ident['email']));
+
+ $MESSAGE->identities[$idx]['email_ascii'] = $ident['email'];
+ $MESSAGE->identities[$idx]['ident'] = format_email_recipient($ident['email'], $ident['name']);
$MESSAGE->identities[$idx]['email'] = $email;
}
}
@@ -242,7 +244,7 @@ else if (!empty($_SESSION['compose']['param']['from'])) {
else if (count($MESSAGE->identities)) {
// extract all recipients of the reply-message
$a_recipients = array();
- if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers))
+ if (is_object($MESSAGE->headers) && in_array($compose_mode, array(RCUBE_COMPOSE_REPLY, RCUBE_COMPOSE_FORWARD)))
{
$a_to = $IMAP->decode_address_list($MESSAGE->headers->to);
foreach ($a_to as $addr) {
@@ -260,39 +262,47 @@ else if (count($MESSAGE->identities)) {
}
$from_idx = null;
- $default_identity = 0;
+ $default_identity = null;
$return_path = $MESSAGE->headers->others['return-path'];
// Select identity
- foreach ($MESSAGE->identities as $idx => $sql_arr) {
+ foreach ($MESSAGE->identities as $idx => $ident) {
// save default identity ID
- if ($sql_arr['standard']) {
+ if ($ident['standard']) {
$default_identity = $idx;
}
- // we need ascii here
- $email = $sql_arr['email_ascii'];
- $ident = format_email_recipient($email, $sql_arr['name']);
- // select identity
- if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT, RCUBE_COMPOSE_REPLY))) {
- if ($MESSAGE->headers->from == $ident) {
+ // use From header
+ if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) {
+ if ($MESSAGE->headers->from == $ident['ident']) {
$from_idx = $idx;
break;
}
}
- // set identity if it's one of the reply-message recipients
- else if (in_array($email, $a_recipients) && ($from_idx === null || $sql_arr['standard'])) {
+ // reply to yourself
+ else if ($compose_mode == RCUBE_COMPOSE_REPLY && $MESSAGE->headers->from == $ident['ident']) {
$from_idx = $idx;
+ break;
}
- // set identity when replying to mailing list
- else if (strpos($return_path, str_replace('@', '=', $email).'@') !== false) {
+ // use replied message recipients
+ else if (in_array($ident['email_ascii'], $a_recipients)) {
$from_idx = $idx;
}
}
- // Still no ID, use first identity
+ // Fallback using Return-Path
+ if ($from_idx === null && $return_path) {
+ foreach ($MESSAGE->identities as $idx => $ident) {
+ if (strpos($return_path, str_replace('@', '=', $ident['email_ascii']).'@') !== false) {
+ $from_idx = $idx;
+ break;
+ }
+ }
+ }
+
+ // Still no ID, use default/first identity
if ($from_idx === null) {
- $from_idx = $default_identity;
+ $from_idx = $default_identity !== null ? $default_identity : key(reset($MESSAGE->identities));
}
$ident = $MESSAGE->identities[$from_idx];