Minor code tidy ups.
authoreileen <emcnaughton@wikimedia.org>
Mon, 24 Apr 2017 05:59:04 +0000 (17:59 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 24 Apr 2017 05:59:04 +0000 (17:59 +1200)
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
CRM/Core/BAO/Email.php

index 7a417c9715375efa0ac03f062d36e85e5e9db187..2e69d844699592eea827f261ef197a1f15348ffb 100644 (file)
@@ -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']];
       }
     }
index a758dc19f556cfcb74578793aedd6cb72be27716..3bfee2724e890e90cac08dc532e517cc72760b07 100644 (file)
@@ -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;