Merge pull request #1290 from pratik-joshi/CRM_12639-fix
authorKurund Jalmi <kurund@civicrm.org>
Thu, 1 Aug 2013 15:47:52 +0000 (08:47 -0700)
committerKurund Jalmi <kurund@civicrm.org>
Thu, 1 Aug 2013 15:47:52 +0000 (08:47 -0700)
Crm 12639 fix

1  2 
CRM/Contact/BAO/Query.php
CRM/Core/BAO/UFGroup.php
CRM/Export/BAO/Export.php

index c7c2dbf84a81aa2d7f9b07f98fc52a632d765900,6725a32aade2b49e07aab208acb8177669b45e60..4c7d9596064425224f92be50e6991a1367580386
@@@ -4936,5 -5028,91 +5028,91 @@@ AND   displayRelType.is_active = 
  
      return $returnValues;
    }
- }
  
 -}
+   /**
+    * convert the pseudo constants id's to their names
+    * @param  reference parameter $dao
+    */
+   function convertToPseudoNames(&$dao) {
+     if (empty($this->_pseudoConstantsSelect)) {
+       return;
+     }
+     $values = array();
+     foreach ($this->_pseudoConstantsSelect as $key => $value) {
+       if (CRM_Utils_Array::value('sorting', $this->_pseudoConstantsSelect[$key])) {
+         continue;
+       }
+       if (property_exists($dao, $value['idCol'])) {
+         $val = $dao->$value['idCol'];
+         if (CRM_Utils_System::isNull($val)) {
+           $dao->$key = NULL;
+           continue;
+         }
+         if ($baoName = CRM_Utils_Array::value('bao', $value, NULL)) {
+           $dao->$key = CRM_Core_PseudoConstant::getLabel($baoName, $value['pseudoField'], $val);
+         }
+         elseif ($value['pseudoField'] == 'state_province_abbreviation') {
+           $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val);
+         }
+         else {
+           $labels = CRM_Core_OptionGroup::values($value['pseudoField']);
+           $dao->$key = $labels[$val];
+         }
+         $values[$key] = $dao->$key;
+       }
+     }
+     return $values;
+   }
+   /*
+    * include pseudo fields LEFT JOIN
+    * @param  $sort  can be a object or string
+    *
+    */
+   function includePseudoFieldsJoin($sort) {
+     if (!$sort || empty($this->_pseudoConstantsSelect)) {
+       return;
+     }
+     $sort = is_string($sort) ? $sort : $sort->orderBy();
+     $present = array();
+     foreach ($this->_pseudoConstantsSelect as $name => $value) {
+       if (CRM_Utils_Array::value('table', $value)) {
+         $regex = "/({$value['table']}\.|{$name})/";
+         if (preg_match($regex, $sort)) {
+           $this->_elemnt[$value['element']] = 1;
+           $this->_select[$value['element']] = $value['select'];
+           $this->_pseudoConstantsSelect[$name]['sorting'] = 1;
+           $present[$value['table']] = $value['join'];
+         }
+       }
+     }
+     $presentSimpleFrom = $present;
+     if (array_key_exists('civicrm_worldregion', $this->_whereTables) &&
+       array_key_exists('civicrm_country', $presentSimpleFrom)) {
+       unset($presentSimpleFrom['civicrm_country']);
+     }
+     if (array_key_exists('civicrm_worldregion', $this->_tables) &&
+       array_key_exists('civicrm_country', $present)) {
+       unset($present['civicrm_country']);
+     }
+     $presentClause = $presentSimpleFromClause = NULL;
+     if (!empty($present)) {
+       $presentClause = implode(' ', $present);
+     }
+     if (!empty($presentSimpleFrom)) {
+       $presentSimpleFromClause = implode(' ', $presentSimpleFrom);
+     }
+     $this->_fromClause = $this->_fromClause . $presentClause;
+     $this->_simpleFromClause = $this->_simpleFromClause . $presentSimpleFromClause;
+     return array($presentClause, $presentSimpleFromClause);
+   }
++}
Simple merge
Simple merge