From 836f1f3fb0ace7318b1728e8e9eb42b12f075290 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 7 Aug 2015 14:15:27 +0530 Subject: [PATCH] CRM-16288 --- CRM/Contact/BAO/ProximityQuery.php | 2 +- CRM/Contact/BAO/Query.php | 45 ++++-------------------------- CRM/Event/BAO/Event.php | 9 ++---- 3 files changed, 10 insertions(+), 46 deletions(-) diff --git a/CRM/Contact/BAO/ProximityQuery.php b/CRM/Contact/BAO/ProximityQuery.php index 422294b5b0..e4d56c47a7 100644 --- a/CRM/Contact/BAO/ProximityQuery.php +++ b/CRM/Contact/BAO/ProximityQuery.php @@ -309,7 +309,7 @@ ACOS( } } - if (isset($proximityAddress['country_id'])) { + if (!empty($proximityAddress['country_id'])) { $proximityAddress['country'] = CRM_Core_PseudoConstant::country($proximityAddress['country_id']); $qill[] = $proximityAddress['country']; } diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index a785c2e5f6..14222c2a60 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3582,45 +3582,9 @@ WHERE $smartGroupClause $this->_tables['civicrm_address'] = 1; $this->_whereTables['civicrm_address'] = 1; - $countries = CRM_Core_PseudoConstant::country(); - if (is_numeric($value)) { - $countryClause = self::buildClause( - 'civicrm_address.country_id', - $op, - $value, - 'Positive' - ); - $countryName = $countries[(int ) $value]; - } - - else { - $intValues = self::parseSearchBuilderString($value); - if ($intValues && ($op == 'IN' || $op == 'NOT IN')) { - $countryClause = self::buildClause( - 'civicrm_address.country_id', - $op, - $intValues, - 'Positive' - ); - $countryNames = array(); - foreach ($intValues as $v) { - $countryNames[] = $countries[$v]; - } - $countryName = implode(',', $countryNames); - } - else { - $countries = CRM_Core_PseudoConstant::country(); - $intVal = CRM_Utils_Array::key($value, $countries); - $countryClause = self::buildClause( - 'civicrm_address.country_id', - $op, - $intVal, - 'Integer' - ); - $countryName = $value; - } - } - $countryQill = ts('Country') . " {$op} '$countryName'"; + $countryClause = self::buildClause('civicrm_address.country_id', $op, $value, 'Positive'); + list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, 'country_id', $value, $op); + $countryQill = ts("%1 %2 %3", array(1 => 'Country', 2 => $qillop, 3 => $qillVal)); if (!$fromStateProvince) { $this->_where[$grouping][] = $countryClause; @@ -5675,6 +5639,9 @@ AND displayRelType.is_active = 1 elseif ($daoName == 'CRM_Contact_DAO_Group' && $fieldName == 'id') { $pseduoOptions = CRM_Core_PseudoConstant::group(); } + elseif ($fieldName == 'country_id') { + $pseduoOptions = CRM_Core_PseudoConstant::country(); + } elseif ($daoName) { $pseduoOptions = CRM_Core_PseudoConstant::get($daoName, $fieldName, $pseduoExtraParam = array()); } diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 998e1e8392..7643e90c4d 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -275,12 +275,9 @@ FROM `civicrm_event` WHERE ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )"; if (!empty($id)) { - if (is_array($id)) { - $query .= " AND `id` IN (" . implode(',', $id) . ")"; - } - else { - $query .= " AND `id` = {$id}"; - } + $op = is_array($id) ? 'IN' : '='; + $where = CRM_Contact_BAO_Query::buildClause('id', $op, $id); + $query .= " AND {$where}"; } elseif ($all == 0) { // find only events ending in the future -- 2.25.1