From cef76e5f9fecef74d15b64f488fb9878d5daa759 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 24 Apr 2017 17:59:04 +1200 Subject: [PATCH] Minor code tidy ups. Use getLoggedInContactID, remove unused vars. Don't precede function with & Note the function is only called from one place in the code so no issue with it being passed as a variable --- CRM/Contact/Page/Inline/Email.php | 2 +- CRM/Core/BAO/Email.php | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/Page/Inline/Email.php b/CRM/Contact/Page/Inline/Email.php index 7a417c9715..2e69d84469 100644 --- a/CRM/Contact/Page/Inline/Email.php +++ b/CRM/Contact/Page/Inline/Email.php @@ -50,7 +50,7 @@ class CRM_Contact_Page_Inline_Email extends CRM_Core_Page { $entityBlock = array('contact_id' => $contactId); $emails = CRM_Core_BAO_Email::getValues($entityBlock); if (!empty($emails)) { - foreach ($emails as $key => & $value) { + foreach ($emails as &$value) { $value['location_type'] = $locationTypes[$value['location_type_id']]; } } diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index a758dc19f5..3bfee2724e 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -117,9 +117,9 @@ WHERE contact_id = {$params['contact_id']} * @param array $entityBlock * Input parameters to find object. * - * @return bool + * @return array */ - public static function &getValues($entityBlock) { + public static function getValues($entityBlock) { return CRM_Core_BAO_Block::getValues('email', $entityBlock); } @@ -283,8 +283,7 @@ AND reset_date IS NULL * an array of email ids */ public static function getFromEmail() { - $session = CRM_Core_Session::singleton(); - $contactID = $session->get('userID'); + $contactID = CRM_Core_Session::singleton()->getLoggedInContactID(); $fromEmailValues = array(); // add all configured FROM email addresses @@ -299,7 +298,7 @@ AND reset_date IS NULL $contactEmails = self::allEmails($contactID); $fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name'); - foreach ($contactEmails as $emailId => $emailVal) { + foreach ($contactEmails as $emailVal) { $email = trim($emailVal['email']); if (!$email || $emailVal['on_hold']) { continue; -- 2.25.1