Merge pull request #4295 from eileenmcnaughton/CRM-15408
[civicrm-core.git] / CRM / Contact / Selector / Custom.php
index fd10d7f42aad17ae9cb3bc80aabe5e1652b3cc0e..df509f02df5447ef6a2649d43b1e2afb10d76251 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -144,8 +144,10 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
       $this->_search = new $customSearchClass( $formValues );
     }
     else {
-      $customSearchFile = $ext->keyToPath($customSearchClass, 'search');
-      $this->_search = new $ext->keyToClass($customSearchClass, 'search')( $formValues );
+      $fnName = $ext->keyToPath;
+      $customSearchFile = $fnName($customSearchClass, 'search');
+      $className = $ext->keyToClass($customSearchClass, 'search');
+      $this->_search = new $className($formValues);
     }
   }
   //end of constructor
@@ -276,6 +278,12 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
     }
 
     $sql = $this->_search->all($offset, $rowCount, $sort, $includeContactIDs);
+    // contact query object used for creating $sql
+    $contactQueryObj = NULL;
+    if (method_exists($this->_search, 'getQueryObj') &&
+      is_a($this->_search->getQueryObj(), 'CRM_Contact_BAO_Query')) {
+      $contactQueryObj = $this->_search->getQueryObj();
+    }
 
     $dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
 
@@ -305,6 +313,12 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
       $row = array();
       $empty = TRUE;
 
+      // if contact query object present
+      // process pseudo constants
+      if ($contactQueryObj) {
+        $contactQueryObj->convertToPseudoNames($dao);
+      }
+
       // the columns we are interested in
       foreach ($columnNames as $property) {
         $row[$property] = $dao->$property;