From 54e389ac6565ff534b87e5e46137a57d48d6c5c8 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 8 Feb 2018 17:50:33 +1300 Subject: [PATCH] CRM-21750 support addressee_id, email_greeting_id, postal_greeting_id as api filters --- CRM/Contact/DAO/Contact.php | 14 +++++++++++++- tests/phpunit/api/v3/ContactTest.php | 27 +++++++++++++++++++++++++++ xml/schema/Contact/Contact.xml | 3 +++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/DAO/Contact.php b/CRM/Contact/DAO/Contact.php index abe106af4a..334d90a018 100644 --- a/CRM/Contact/DAO/Contact.php +++ b/CRM/Contact/DAO/Contact.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contact/Contact.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:395cdbb5eaf3b1f74fb87f93269d8336) + * (GenCodeChecksum:8ace6d508a6e4412f52c6cbd2978b072) */ /** @@ -991,6 +991,10 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_INT, 'title' => ts('Email Greeting ID'), 'description' => 'FK to civicrm_option_value.id, that has to be valid registered Email Greeting.', + 'export' => TRUE, + 'where' => 'civicrm_contact.email_greeting_id', + 'headerPattern' => '', + 'dataPattern' => '', 'table_name' => 'civicrm_contact', 'entity' => 'Contact', 'bao' => 'CRM_Contact_BAO_Contact', @@ -1040,6 +1044,10 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_INT, 'title' => ts('Postal Greeting ID'), 'description' => 'FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.', + 'export' => TRUE, + 'where' => 'civicrm_contact.postal_greeting_id', + 'headerPattern' => '', + 'dataPattern' => '', 'table_name' => 'civicrm_contact', 'entity' => 'Contact', 'bao' => 'CRM_Contact_BAO_Contact', @@ -1092,6 +1100,10 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_INT, 'title' => ts('Addressee ID'), 'description' => 'FK to civicrm_option_value.id, that has to be valid registered Addressee.', + 'export' => TRUE, + 'where' => 'civicrm_contact.addressee_id', + 'headerPattern' => '', + 'dataPattern' => '', 'table_name' => 'civicrm_contact', 'entity' => 'Contact', 'bao' => 'CRM_Contact_BAO_Contact', diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index c4d094c82b..691a02c8b1 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -1000,6 +1000,33 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals("O'Connor", $result['last_name'], 'in line' . __LINE__); } + /** + * Test retrieval by addressee id. + */ + public function testGetByAddresseeID() { + $individual1ID = $this->individualCreate([ + 'skip_greeting_processing' => 1, + 'addressee_id' => 'null', + 'email_greeting_id' => 'null', + 'postal_greeting_id' => 'null' + ]); + $individual2ID = $this->individualCreate(); + + $this->assertEquals($individual1ID, + $this->callAPISuccessGetValue('Contact', ['contact_type' => 'Individual', 'addressee_id' => ['IS NULL' => 1], 'return' => 'id']) + ); + $this->assertEquals($individual1ID, + $this->callAPISuccessGetValue('Contact', ['contact_type' => 'Individual', 'email_greeting_id' => ['IS NULL' => 1], 'return' => 'id']) + ); + $this->assertEquals($individual1ID, + $this->callAPISuccessGetValue('Contact', ['contact_type' => 'Individual', 'postal_greeting_id' => ['IS NULL' => 1], 'return' => 'id']) + ); + + $this->assertEquals($individual2ID, + $this->callAPISuccessGetValue('Contact', ['contact_type' => 'Individual', 'addressee_id' => ['NOT NULL' => 1], 'return' => 'id']) + ); + } + /** * Check with complete array + custom field. * diff --git a/xml/schema/Contact/Contact.xml b/xml/schema/Contact/Contact.xml index e6a596c670..cfc14f5bd1 100644 --- a/xml/schema/Contact/Contact.xml +++ b/xml/schema/Contact/Contact.xml @@ -535,6 +535,7 @@ email_greeting_id int unsigned Email Greeting ID + true FK to civicrm_option_value.id, that has to be valid registered Email Greeting. 3.0 @@ -568,6 +569,7 @@ postal_greeting_id int unsigned Postal Greeting ID + true FK to civicrm_option_value.id, that has to be valid registered Postal Greeting. 3.0 @@ -606,6 +608,7 @@ Addressee ID FK to civicrm_option_value.id, that has to be valid registered Addressee. 3.0 + true addressee -- 2.25.1