fix several problems regarding compose; wrong addresses on nreply_all; failed opening of templates; not opening on importMessageFromVFS2DraftAndDisplay

This commit is contained in:
Klaus Leithoff 2014-01-24 10:30:45 +00:00
parent bc0f6950c5
commit 5b586c4687
3 changed files with 64 additions and 52 deletions

View File

@ -180,6 +180,7 @@ class mail_bo
{ {
self::$instances[$_profileID]->icServer = $_oldImapServerObject; self::$instances[$_profileID]->icServer = $_oldImapServerObject;
self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId; self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId;
self::$instances[$_profileID]->profileID= $_oldImapServerObject->ImapServerId;
self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
return self::$instances[$_profileID]; return self::$instances[$_profileID];
@ -499,10 +500,11 @@ class mail_bo
/** /**
* getUserEMailAddresses - function to gather the emailadresses connected to the current mail-account * getUserEMailAddresses - function to gather the emailadresses connected to the current mail-account
* @param string $_profileID the ID of the mailaccount to check for identities, if null current mail-account is used
* @return array - array(email=>realname) * @return array - array(email=>realname)
*/ */
function getUserEMailAddresses() { function getUserEMailAddresses($_profileID=null) {
$acc = emailadmin_account::read($this->profileID); $acc = emailadmin_account::read((!empty($_profileID)?$_profileID:$this->profileID));
$identities = $acc->identities(); $identities = $acc->identities();
$userEMailAdresses = array(); $userEMailAdresses = array();

View File

@ -1479,39 +1479,56 @@ class mail_compose
//error_log(__METHOD__.__LINE__.array2string($headers)); //error_log(__METHOD__.__LINE__.array2string($headers));
if (!empty($addHeadInfo['X-MAILFOLDER'])) { if (!empty($addHeadInfo['X-MAILFOLDER'])) {
foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
$this->sessionData['folder'][] = $val; if ($mail_bo->folderExists($val)) $this->sessionData['folder'][] = $val;
} }
} }
if (!empty($addHeadInfo['X-SIGNATURE'])) { if (!empty($addHeadInfo['X-SIGNATURE'])) {
// with the new system it would be the identity
try
{
$identity = emailadmin_account::read_identity($addHeadInfo['X-SIGNATURE']);
$this->sessionData['signatureid'] = $addHeadInfo['X-SIGNATURE']; $this->sessionData['signatureid'] = $addHeadInfo['X-SIGNATURE'];
} }
catch (Exception $e)
{
}
}
/* /*
if (!empty($addHeadInfo['X-STATIONERY'])) { if (!empty($addHeadInfo['X-STATIONERY'])) {
$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
} }
*/ */
if (!empty($addHeadInfo['X-IDENTITY'])) { if (!empty($addHeadInfo['X-IDENTITY'])) {
// with the new system it would the identity is the account id
try
{
$acc = emailadmin_account::read($addHeadInfo['X-IDENTITY']);
$this->sessionData['mailaccount'] = $addHeadInfo['X-IDENTITY']; $this->sessionData['mailaccount'] = $addHeadInfo['X-IDENTITY'];
} }
catch (Exception $e)
{
// fail silently
$this->sessionData['mailaccount'] = $mail_bo->profileID;
}
}
// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = array('uid'=>$_uid,'folder'=>$_folder); if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = array('uid'=>$_uid,'folder'=>$_folder);
$this->sessionData['uid'] = $_uid; $this->sessionData['uid'] = $_uid;
$this->sessionData['messageFolder'] = $_folder; $this->sessionData['messageFolder'] = $_folder;
$this->sessionData['isDraft'] = true; $this->sessionData['isDraft'] = true;
foreach((array)$headers['CC'] as $val) { foreach((array)$headers['CC'] as $val) {
if($val['MAILBOX_NAME'] == 'undisclosed-recipients' || (empty($val['MAILBOX_NAME']) && empty($val['HOST_NAME'])) ) { $rfcAddr=imap_rfc822_parse_adrlist($val);
$_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
//if($userEMailAddresses[$val['EMAIL']]) { if(!$foundAddresses[$keyemail]) {
// continue; $address = $val;
//}
if(!$foundAddresses[$val['EMAIL']]) {
$address = $val['PERSONAL_NAME'] != 'NIL' ? $val['RFC822_EMAIL'] : $val['EMAIL'];
$address = $this->mail_bo->decode_header($address,true); $address = $this->mail_bo->decode_header($address,true);
$this->sessionData['cc'][] = $address; $this->sessionData['cc'][] = $val;
$foundAddresses[$val['EMAIL']] = true; $foundAddresses[$keyemail] = true;
} }
} }
@ -1521,53 +1538,50 @@ class mail_compose
$this->sessionData['to'][] = $val; $this->sessionData['to'][] = $val;
continue; continue;
} }
if($val['MAILBOX_NAME'] == 'undisclosed-recipients' || (empty($val['MAILBOX_NAME']) && empty($val['HOST_NAME'])) ) { $rfcAddr=imap_rfc822_parse_adrlist($val);
$_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
//if($userEMailAddresses[$val['EMAIL']]) { if(!$foundAddresses[$keyemail]) {
// continue; $address = $val;
//}
if(!$foundAddresses[$val['EMAIL']]) {
$address = $val['PERSONAL_NAME'] != 'NIL' ? $val['RFC822_EMAIL'] : $val['EMAIL'];
$address = $this->mail_bo->decode_header($address,true); $address = $this->mail_bo->decode_header($address,true);
$this->sessionData['to'][] = $address; $this->sessionData['to'][] = $val;
$foundAddresses[$val['EMAIL']] = true; $foundAddresses[$keyemail] = true;
} }
} }
foreach((array)$headers['REPLY_TO'] as $val) { foreach((array)$headers['REPLY_TO'] as $val) {
if($val['MAILBOX_NAME'] == 'undisclosed-recipients' || (empty($val['MAILBOX_NAME']) && empty($val['HOST_NAME'])) ) { $rfcAddr=imap_rfc822_parse_adrlist($val);
$_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
//if($userEMailAddresses[$val['EMAIL']]) { if(!$foundAddresses[$keyemail]) {
// continue; $address = $val;
//}
if(!$foundAddresses[$val['EMAIL']]) {
$address = $val['PERSONAL_NAME'] != 'NIL' ? $val['RFC822_EMAIL'] : $val['EMAIL'];
$address = $this->mail_bo->decode_header($address,true); $address = $this->mail_bo->decode_header($address,true);
$this->sessionData['replyto'][] = $address; $this->sessionData['replyto'][] = $val;
$foundAddresses[$val['EMAIL']] = true; $foundAddresses[$keyemail] = true;
} }
} }
foreach((array)$headers['BCC'] as $val) { foreach((array)$headers['BCC'] as $val) {
if($val['MAILBOX_NAME'] == 'undisclosed-recipients' || (empty($val['MAILBOX_NAME']) && empty($val['HOST_NAME'])) ) { $rfcAddr=imap_rfc822_parse_adrlist($val);
$_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
//if($userEMailAddresses[$val['EMAIL']]) { if(!$foundAddresses[$keyemail]) {
// continue; $address = $val;
//}
if(!$foundAddresses[$val['EMAIL']]) {
$address = $val['PERSONAL_NAME'] != 'NIL' ? $val['RFC822_EMAIL'] : $val['EMAIL'];
$address = $this->mail_bo->decode_header($address,true); $address = $this->mail_bo->decode_header($address,true);
$this->sessionData['bcc'][] = $address; $this->sessionData['bcc'][] = $val;
$foundAddresses[$val['EMAIL']] = true; $foundAddresses[$keyemail] = true;
} }
} }
@ -1759,7 +1773,7 @@ class mail_compose
$this->sessionData['uid'] = $_uid; $this->sessionData['uid'] = $_uid;
$this->sessionData['messageFolder'] = $_folder; $this->sessionData['messageFolder'] = $_folder;
$this->sessionData['in-reply-to'] = $headers['MESSAGE_ID']; $this->sessionData['in-reply-to'] = $headers['MESSAGE_ID'];
//error_log(__METHOD__.__LINE__.array2string($headers)); //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
// check for Reply-To: header and use if available // check for Reply-To: header and use if available
if(!empty($headers['REPLY_TO']) && ($headers['REPLY_TO'] != $headers['FROM'])) { if(!empty($headers['REPLY_TO']) && ($headers['REPLY_TO'] != $headers['FROM'])) {
foreach($headers['REPLY_TO'] as $val) { foreach($headers['REPLY_TO'] as $val) {
@ -1776,7 +1790,7 @@ class mail_compose
$foundAddresses[$val] = true; $foundAddresses[$val] = true;
} }
} }
$oldToAddress = (is_array($headers['REPLY_TO'])?$headers['REPLY_TO'][0]:$headers['REPLY_TO']); $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
} }
//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
@ -1787,11 +1801,9 @@ class mail_compose
// reply to any address which is cc, but not to my self // reply to any address which is cc, but not to my self
#if($headers->cc) { #if($headers->cc) {
foreach($headers['CC'] as $val) { foreach($headers['CC'] as $val) {
if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
continue; continue;
} }
if(!$foundAddresses[$val]) { if(!$foundAddresses[$val]) {
$this->sessionData['cc'][] = $val; $this->sessionData['cc'][] = $val;
$foundAddresses[$val] = true; $foundAddresses[$val] = true;
@ -1802,11 +1814,9 @@ class mail_compose
// reply to any address which is to, but not to my self // reply to any address which is to, but not to my self
#if($headers->to) { #if($headers->to) {
foreach($headers['TO'] as $val) { foreach($headers['TO'] as $val) {
if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
continue; continue;
} }
if(!$foundAddresses[$val]) { if(!$foundAddresses[$val]) {
$this->sessionData['to'][] = $val; $this->sessionData['to'][] = $val;
$foundAddresses[$val] = true; $foundAddresses[$val] = true;
@ -1816,7 +1826,6 @@ class mail_compose
#if($headers->from) { #if($headers->from) {
foreach($headers['FROM'] as $val) { foreach($headers['FROM'] as $val) {
if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
continue; continue;
} }

View File

@ -34,6 +34,7 @@ class mail_ui
'vfsSaveMessage' => True, 'vfsSaveMessage' => True,
'loadEmailBody' => True, 'loadEmailBody' => True,
'importMessage' => True, 'importMessage' => True,
'importMessageFromVFS2DraftAndDisplay'=>True,
'TestConnection' => True, 'TestConnection' => True,
); );