CRM-13344 - Update search builder and other code for pseudoconstant fields
authorColeman Watts <coleman@civicrm.org>
Tue, 1 Oct 2013 00:27:52 +0000 (17:27 -0700)
committerColeman Watts <coleman@civicrm.org>
Tue, 1 Oct 2013 00:27:52 +0000 (17:27 -0700)
----------------------------------------
* 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
CRM/Contact/Form/Search/Builder.php
CRM/Contact/Import/Parser/Contact.php
CRM/Core/BAO/OptionValue.php
CRM/Core/BAO/UFGroup.php
api/api.php
api/v3/Activity.php

index de3ac1fdd807e2319b7ff5ffd43b95d39628be0e..d4c2dad662eae9759169c8aa5d5ab7797e920432 100644 (file)
@@ -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,
index 0699dfb1d821020fb5cd111e96c1c8d0cc33471f..bb639f6125da28ec565d79ad92730f3cc0ee9d81 100644 (file)
@@ -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;
index b8220044b05ca5f4a0e5ecf1369fd4c4919badc1..2ea3e6232e4a932ba71737e0d95cc787100d73ea 100644 (file)
@@ -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);
             }
index bd92c86d5230ad5b309e4a3edc68819496d7c386..fab3a17efd8fb6f9b2f96f407605b51542114666 100644 (file)
@@ -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',
index 1a3d23417f46d69a1bcad9751bd14dd57660efbd..6b2d42950540d6a2d4e653e16154df658b78e081 100644 (file)
@@ -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;
         }
index dc712b97401167aa3e724fab91ef91cc0a1dc71c..f9e6970e19c80902258a75afdef09193b5ffe968 100644 (file)
@@ -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'])){
index 834663f829da49ba8561ae60cecfa0f05884558f..4deab7fe533026694e04873a94e9fb52d3cc07c9 100644 (file)
@@ -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',