Merge pull request #3923 from eileenmcnaughton/CRM-15168
[civicrm-core.git] / CRM / Contact / BAO / SavedSearch.php
index d9aa603cb3520fa3ad3eccf917ae6feeff9708ec..b13a2f35fde3e0c46039c5e5a3d71470b39922eb 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -42,7 +42,7 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
   /**
    * class constructor
    *
-   * @return object CRM_Contact_BAO_SavedSearch
+   * @return \CRM_Contact_BAO_SavedSearch CRM_Contact_BAO_SavedSearch
    */
   function __construct() {
     parent::__construct();
@@ -130,13 +130,18 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
     return $result;
   }
 
+  /**
+   * @param $id
+   *
+   * @return array
+   */
   static function getSearchParams($id) {
     $fv = self::getFormValues($id);
-    //check if the saved seach has mapping id
+    //check if the saved search has mapping id
     if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'mapping_id')) {
       return CRM_Core_BAO_Mapping::formattedFields($fv);
     }
-    elseif (CRM_Utils_Array::value('customSearchID', $fv)) {
+    elseif (!empty($fv['customSearchID'])) {
       return $fv;
     }
     else {
@@ -158,7 +163,7 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
   static function whereClause($id, &$tables, &$whereTables) {
     $params = self::getSearchParams($id);
     if ($params) {
-      if (CRM_Utils_Array::value('customSearchID', $params)) {
+      if (!empty($params['customSearchID'])) {
         // this has not yet been implemented
       } else {
       return CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables);
@@ -167,11 +172,14 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
     return NULL;
   }
 
+  /**
+   * @param $id
+   *
+   * @return string
+   */
   static function contactIDsSQL($id) {
     $params = self::getSearchParams($id);
-    if ($params &&
-      CRM_Utils_Array::value('customSearchID', $params)
-    ) {
+    if ($params && !empty($params['customSearchID'])) {
       return CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $id);
     }
     else {
@@ -188,11 +196,16 @@ WHERE  $where";
     }
   }
 
+  /**
+   * @param $id
+   *
+   * @return array
+   */
   static function fromWhereEmail($id) {
     $params = self::getSearchParams($id);
 
     if ($params) {
-      if (CRM_Utils_Array::value('customSearchID', $params)) {
+      if (!empty($params['customSearchID'])) {
         return CRM_Contact_BAO_SearchCustom::fromWhereEmail(NULL, $id);
       }
       else {
@@ -255,6 +268,8 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_
    *
    * @param int $id the id of the saved search
    *
+   * @param string $value
+   *
    * @return string the name of the saved search
    * @access public
    * @static