Unverified Commit fd36ea78 authored by Monish Deb's avatar Monish Deb Committed by GitHub

Merge pull request #11905 from seamuslee001/CRM-21244-consistancy

CRM-21244 Ensure consistancy with previous behavior where user emails …
parents fbe777cf 669f45ef
......@@ -304,6 +304,7 @@ AND reset_date IS NULL
return $fromEmailValues;
}
$contactFromEmails = [];
// add logged in user's active email ids
$contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
if ($contactID) {
......@@ -321,10 +322,10 @@ AND reset_date IS NULL
if (!empty($emailVal['is_primary'])) {
$fromEmailHtml .= ' ' . ts('(preferred)');
}
$fromEmailValues[$emailId] = $fromEmailHtml;
$contactFromEmails[$fromEmail] = $fromEmailHtml;
}
}
return $fromEmailValues;
return CRM_Utils_Array::crmArrayMerge($contactFromEmails, $fromEmailValues);
}
/**
......
......@@ -149,4 +149,22 @@ class CRM_Core_BAO_EmailTest extends CiviUnitTestCase {
$this->contactDelete($contactId);
}
/**
* Test getting list of Emails for use in Receipts and Single Email sends
*/
public function testGetFromEmail() {
$this->createLoggedInUser();
$fromEmails = CRM_Core_BAO_Email::getFromEmail();
$emails = array_values($fromEmails);
$this->assertContains("(preferred)", $emails[0]);
Civi::settings()->set("allow_mail_from_logged_in_contact", 0);
$this->callAPISuccess('system', 'flush', []);
$fromEmails = CRM_Core_BAO_Email::getFromEmail();
$emails = array_values($fromEmails);
$this->assertNotContains("(preferred)", $emails[0]);
$this->assertContains("info@EXAMPLE.ORG", $emails[0]);
Civi::settings()->set("allow_mail_from_logged_in_contact", 1);
$this->callAPISuccess('system', 'flush', []);
}
}
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