CRM-13274, search builder fixes
authorkurund <kurund@civicrm.org>
Thu, 1 May 2014 19:53:33 +0000 (12:53 -0700)
committerkurund <kurund@civicrm.org>
Thu, 1 May 2014 19:53:33 +0000 (12:53 -0700)
----------------------------------------
* CRM-13274: Sort by pseudo-constants is broken for search builder
  https://issues.civicrm.org/jira/browse/CRM-13274

CRM/Contact/BAO/Query.php

index 3bc84cdb6a8890535ca0da24d0bc98b139c6d31d..aed58c858359292f5266d02e626e85decedd777f 100644 (file)
@@ -4357,6 +4357,14 @@ civicrm_relationship.is_permission_a_b = 0
               $this->_whereTables["civicrm_email"] = 1;
               $order = str_replace($field, "civicrm_email.{$field}", $order);
               break;
+
+            default:
+              //CRM-12565 add "`" around $field if it is a pseudo constant
+              foreach ($this->_pseudoConstantsSelect as $key => $value) {
+                if (!empty($value['element']) && $value['element'] == $field) {
+                  $order = str_replace($field, "`{$field}`", $order);
+                }
+              }
           }
           $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
           $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);