Merge pull request #1300 from eileenmcnaughton/CRM-13142
[civicrm-core.git] / CRM / Contact / Selector / Custom.php
index 8fad5d71647efe038306f512b2b708159782798d..f868fdb42474acee3321ba2236d3a3bfd6bfaf70 100644 (file)
@@ -278,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);
 
@@ -307,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;