getLoggedInContactID() is a static function
[civicrm-core.git] / CRM / Core / BAO / Email.php
index c8bcb650cf88a2c32cf80f57d71473d0be288bf9..0dd1bca05a49d314cd910b8415f2e82aa4cba4ba 100644 (file)
@@ -305,7 +305,7 @@ AND    reset_date IS NULL
 
     $contactFromEmails = [];
     // add logged in user's active email ids
-    $contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
+    $contactID = CRM_Core_Session::getLoggedInContactID();
     if ($contactID) {
       $contactEmails = self::allEmails($contactID);
       $fromDisplayName  = CRM_Core_Session::singleton()->getLoggedInContactDisplayName();
@@ -345,4 +345,24 @@ AND    reset_date IS NULL
     return CRM_Contact_BAO_Contact::deleteObjectWithPrimary('Email', $id);
   }
 
+  /**
+   * Get filters for entity reference fields.
+   *
+   * @return array
+   */
+  public static function getEntityRefFilters() {
+    $contactFields = CRM_Contact_BAO_Contact::getEntityRefFilters();
+    foreach ($contactFields as $index => &$contactField) {
+      if (!empty($contactField['entity'])) {
+        // For now email_getlist can't parse state, country etc.
+        unset($contactFields[$index]);
+      }
+      elseif ($contactField['key'] !== 'contact_id') {
+        $contactField['entity'] = 'Contact';
+        $contactField['key'] = 'contact_id.' . $contactField['key'];
+      }
+    }
+    return $contactFields;
+  }
+
 }