From 67744c4e70c774f83f18f512db83fdb45cb4bce7 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 30 Sep 2013 17:27:52 -0700 Subject: [PATCH] CRM-13344 - Update search builder and other code for pseudoconstant fields ---------------------------------------- * CRM-13344: Resolve test / schema issues around prefix_id, suffix_id, gender http://issues.civicrm.org/jira/browse/CRM-13344 --- CRM/Contact/BAO/Query.php | 6 +++--- CRM/Contact/Form/Search/Builder.php | 20 +++++--------------- CRM/Contact/Import/Parser/Contact.php | 3 +++ CRM/Core/BAO/OptionValue.php | 1 + CRM/Core/BAO/UFGroup.php | 1 + api/api.php | 2 +- api/v3/Activity.php | 2 ++ 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index de3ac1fdd8..d4c2dad662 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -4536,13 +4536,13 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count, 'first_name' => 1, 'middle_name' => 1, 'last_name' => 1, - 'individual_prefix' => 1, - 'individual_suffix' => 1, + 'prefix_id' => 1, + 'suffix_id' => 1, 'email_greeting' => 1, 'postal_greeting' => 1, 'addressee' => 1, 'birth_date' => 1, - 'gender' => 1, + 'gender_id' => 1, 'preferred_communication_method' => 1, 'do_not_phone' => 1, 'do_not_email' => 1, diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 0699dfb1d8..bb639f6125 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -413,29 +413,19 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { $options = array( 'group' => 'group_contact', 'tag' => 'entity_tag', - 'country' => 'address', - 'state_province' => 'address', - 'gender' => 'contact', - 'world_region' => 'contact', - 'individual_prefix' => 'contact', - 'individual_suffix' => 'contact', - 'preferred_communication_method' => 'contact', - 'preferred_language' => 'contact', 'on_hold' => 'yesno', 'is_bulkmail' => 'yesno', - 'activity_type' => 'activity', - 'activity_status' => 'activity', - 'financial_type' => 'contribution', - 'contribution_page_id' => 'contribution', - 'contribution_status' => 'contribution', 'payment_instrument' => 'contribution', 'membership_status' => 'membership', 'membership_type' => 'membership', + 'member_is_test' => 'yesno', + 'member_is_pay_later' => 'yesno', + 'is_override' => 'yesno', ); - $entities = array('contact', 'activity', 'participant', 'pledge', 'member', 'contribution'); + $entities = array('contact', 'address', 'activity', 'participant', 'pledge', 'member', 'contribution'); CRM_Contact_BAO_Query_Hook::singleton()->alterSearchBuilderOptions($entities, $options); foreach ($entities as $entity) { - $fields = civicrm_api($entity, 'getfields', array('version' => 3)); + $fields = civicrm_api3($entity, 'getfields'); foreach ($fields['values'] as $field => $info) { if (!empty($info['options']) || !empty($info['pseudoconstant']) || !empty($info['option_group_id']) || !empty($info['enumValues'])) { $options[$field] = $entity; diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index b8220044b0..2ea3e6232e 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -1365,6 +1365,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { break; case 'gender': + case 'gender_id': if (!self::checkGender($value)) { self::addToErrorMsg(ts('Gender'), $errorMessage); } @@ -1387,12 +1388,14 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { break; case 'individual_prefix': + case 'prefix_id': if (!self::in_value($value, CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'))) { self::addToErrorMsg(ts('Individual Prefix'), $errorMessage); } break; case 'individual_suffix': + case 'suffix_id': if (!self::in_value($value, CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'))) { self::addToErrorMsg(ts('Individual Suffix'), $errorMessage); } diff --git a/CRM/Core/BAO/OptionValue.php b/CRM/Core/BAO/OptionValue.php index bd92c86d52..fab3a17efd 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -290,6 +290,7 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { $value = $optionValue->value; // get the proper group name & affected field name + // todo: this may no longer be needed for individuals - check inputs $individuals = array( 'gender' => 'gender_id', 'individual_prefix' => 'prefix_id', diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 1a3d23417f..6b2d429505 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2822,6 +2822,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } } else { + // TODO: prefix, suffix and gender translation may no longer be necessary - check inputs if ($key === 'individual_suffix') { $data['suffix_id'] = $value; } diff --git a/api/api.php b/api/api.php index dc712b9740..f9e6970e19 100644 --- a/api/api.php +++ b/api/api.php @@ -265,7 +265,7 @@ function _civicrm_api_resolve($apiRequest) { * @throws CiviCRM_API3_Exception * @return array */ -function civicrm_api3($entity, $action, $params) { +function civicrm_api3($entity, $action, $params = array()) { $params['version'] = 3; $result = civicrm_api($entity, $action, $params); if(is_array($result) && !empty($result['is_error'])){ diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 834663f829..4deab7fe53 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -183,6 +183,8 @@ function _civicrm_api3_activity_create_spec(&$params) { //default for source_contact_id = currently logged in user $params['source_contact_id']['api.default'] = 'user_contact_id'; + $params['status_id']['api.aliases'] = array('activity_status'); + $params['assignee_contact_id'] = array( 'name' => 'assignee_id', 'title' => 'assigned to', -- 2.25.1