Commit e50f844f authored by Manfred Kutas's avatar Manfred Kutas

ZP-1280 Email from a deleted user doesn't show from field.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 09493d72
...@@ -186,6 +186,7 @@ class MAPIMapping { ...@@ -186,6 +186,7 @@ class MAPIMapping {
// Override 'From' to show "Full Name <user@domain.com>" // Override 'From' to show "Full Name <user@domain.com>"
"representingname" => PR_SENT_REPRESENTING_NAME, "representingname" => PR_SENT_REPRESENTING_NAME,
"representingentryid" => PR_SENT_REPRESENTING_ENTRYID, "representingentryid" => PR_SENT_REPRESENTING_ENTRYID,
"representingsearchkey" => PR_SENT_REPRESENTING_SEARCH_KEY,
"sourcekey" => PR_SOURCE_KEY, "sourcekey" => PR_SOURCE_KEY,
"entryid" => PR_ENTRYID, "entryid" => PR_ENTRYID,
"parentsourcekey" => PR_PARENT_SOURCE_KEY, "parentsourcekey" => PR_PARENT_SOURCE_KEY,
......
...@@ -208,6 +208,10 @@ class MAPIProvider { ...@@ -208,6 +208,10 @@ class MAPIProvider {
isset($messageprops[$appointmentprops["representingname"]])) { isset($messageprops[$appointmentprops["representingname"]])) {
$message->organizeremail = w2u($this->getSMTPAddressFromEntryID($messageprops[$appointmentprops["representingentryid"]])); $message->organizeremail = w2u($this->getSMTPAddressFromEntryID($messageprops[$appointmentprops["representingentryid"]]));
// if the email address can't be resolved, fall back to PR_SENT_REPRESENTING_SEARCH_KEY
if ($message->organizeremail == "" && isset($messageprops[$appointmentprops["sentrepresentinsrchk"]])) {
$message->organizeremail = $this->getEmailAddressFromSearchKey($messageprops[$appointmentprops["sentrepresentinsrchk"]]);
}
$message->organizername = w2u($messageprops[$appointmentprops["representingname"]]); $message->organizername = w2u($messageprops[$appointmentprops["representingname"]]);
} }
...@@ -564,6 +568,11 @@ class MAPIProvider { ...@@ -564,6 +568,11 @@ class MAPIProvider {
if(isset($messageprops[$emailproperties["representingentryid"]])) if(isset($messageprops[$emailproperties["representingentryid"]]))
$fromaddr = $this->getSMTPAddressFromEntryID($messageprops[$emailproperties["representingentryid"]]); $fromaddr = $this->getSMTPAddressFromEntryID($messageprops[$emailproperties["representingentryid"]]);
// if the email address can't be resolved, fall back to PR_SENT_REPRESENTING_SEARCH_KEY
if ($fromaddr == "" && isset($messageprops[$emailproperties["representingsearchkey"]])) {
$fromaddr = $this->getEmailAddressFromSearchKey($messageprops[$emailproperties["representingsearchkey"]]);
}
if($fromname == $fromaddr) if($fromname == $fromaddr)
$fromname = ""; $fromname = "";
...@@ -2833,7 +2842,7 @@ class MAPIProvider { ...@@ -2833,7 +2842,7 @@ class MAPIProvider {
*/ */
private function getEmailAddressFromSearchKey($searchKey) { private function getEmailAddressFromSearchKey($searchKey) {
if (strpos($searchKey, ':') !== false && strpos($searchKey, '@') !== false) { if (strpos($searchKey, ':') !== false && strpos($searchKey, '@') !== false) {
ZLog::Write(LOGLEVEL_INFO, "MAPIProvider->getEmailAddressFromSearchKey(): fall back to PR_SEARCH_KEY to resolve user and get email address"); ZLog::Write(LOGLEVEL_INFO, "MAPIProvider->getEmailAddressFromSearchKey(): fall back to PR_SEARCH_KEY or PR_SENT_REPRESENTING_SEARCH_KEY to resolve user and get email address");
return trim(strtolower(explode(':', $searchKey)[1])); return trim(strtolower(explode(':', $searchKey)[1]));
} }
return ""; return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment