From 9df8a11d88e35ac68a25a48a65467efdd1464747 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Tue, 30 Apr 2013 18:50:04 -0700 Subject: [PATCH] CRM-14264 : start using xml for gender / suffix / prefix ---------------------------------------- * CRM-14264: http://issues.civicrm.org/jira/browse/CRM-14264 --- CRM/Contact/BAO/Query.php | 14 +++++++++++--- CRM/Contact/Form/Search/Advanced.php | 2 +- CRM/Contact/Form/Search/Criteria.php | 2 +- CRM/Contact/Selector.php | 18 ++++++++++-------- .../Form/Search/Criteria/Demographics.tpl | 4 ++-- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 03c72a933f..b6a222050f 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -1726,13 +1726,13 @@ class CRM_Contact_BAO_Query { elseif ($field['pseudoconstant']) { $this->optionValueQuery( $name, $op, $value, $grouping, - CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $field['dbName']), + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $field['name']), $field, $field['title'], 'String', TRUE ); - if ($name == 'gender') { + if ($name == 'gender_id') { self::$_openedPanes[ts('Demographics')] = TRUE; } } @@ -4866,7 +4866,15 @@ AND displayRelType.is_active = 1 // its a string, lets get the int value $value = array_search($value, $selectValues); } - $wc = self::caseImportant($op) && ! $useIDsOnly ? "LOWER({$field['where']})" : "{$field['where']}"; + if ($useIDsOnly) { + list($tableName, $fieldName) = explode('.', $field['where'], 2); + if ($tableName == 'civicrm_contact') { + $wc = "contact_a.$fieldName"; + } + } + else { + $wc = self::caseImportant($op) ? "LOWER({$field['where']})" : "{$field['where']}"; + } $this->_where[$grouping][] = self::buildClause($wc, $op, $value, $dataType); $this->_qill[$grouping][] = $label . " $op '$qill'"; } diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index a3892ba35a..e6fcc3f775 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -8,7 +8,7 @@ | This file is a part of CiviCRM. | | | | CiviCRM is free software; you can copy, modify, and distribute it | - | under the terms of the GNU Affero General Public License | +s | under the terms of the GNU Affero General Public License | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | | | CiviCRM is distributed in the hope that it will be useful, but | diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 47ea794b32..6c0ac1aaee 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -477,7 +477,7 @@ class CRM_Contact_Form_Search_Criteria { array('id' => "civicrm_gender_{$var}_{$key}") ); } - $form->addGroup($genderOptions, 'gender', ts('Gender')); + $form->addGroup($genderOptions, 'gender_id', ts('Gender')); CRM_Core_Form_Date::buildDateRange($form, 'birth_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth'); diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 06c9a7ad56..78c891e1e5 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -576,14 +576,16 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $groupID = CRM_Utils_Array::key('1', $this->_formValues['group']); $pseudoconstants = array(); - // get all the pseudoconstant values - foreach ($this->_fields as $name => $values) { - if (isset($this->_fields[$name]['pseudoconstant'])) { - $pseudoconstants[$name] = - array( - 'dbName' => $this->_fields[$name]['name'], - 'values' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name), - ); + if (!empty($this->_fields)) { + // get all the pseudoconstant values + foreach ($this->_fields as $name => $values) { + if (isset($this->_fields[$name]['pseudoconstant'])) { + $pseudoconstants[$name] = + array( + 'dbName' => $this->_fields[$name]['name'], + 'values' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name), + ); + } } } diff --git a/templates/CRM/Contact/Form/Search/Criteria/Demographics.tpl b/templates/CRM/Contact/Form/Search/Criteria/Demographics.tpl index 957a46374e..38bd053f68 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/Demographics.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/Demographics.tpl @@ -42,8 +42,8 @@ - {$form.gender.label}
- {$form.gender.html}({ts}clear{/ts}) + {$form.gender_id.label}
+ {$form.gender_id.html}({ts}clear{/ts}) -- 2.25.1