Skip to content

Commit

Permalink
CRM-21750 support addressee_id, email_greeting_id, postal_greeting_id…
Browse files Browse the repository at this point in the history
… as api filters
  • Loading branch information
eileenmcnaughton committed Feb 8, 2018
1 parent 16f3fde commit 54e389a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
14 changes: 13 additions & 1 deletion CRM/Contact/DAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contact/Contact.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:395cdbb5eaf3b1f74fb87f93269d8336)
* (GenCodeChecksum:8ace6d508a6e4412f52c6cbd2978b072)
*/

/**
Expand Down Expand Up @@ -991,6 +991,10 @@ public static function &fields() {
'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',
Expand Down Expand Up @@ -1040,6 +1044,10 @@ public static function &fields() {
'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',
Expand Down Expand Up @@ -1092,6 +1100,10 @@ public static function &fields() {
'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',
Expand Down
27 changes: 27 additions & 0 deletions tests/phpunit/api/v3/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,33 @@ public function testGetApostropheCRM10857() {
$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.
*
Expand Down
3 changes: 3 additions & 0 deletions xml/schema/Contact/Contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@
<name>email_greeting_id</name>
<type>int unsigned</type>
<title>Email Greeting ID</title>
<export>true</export>
<comment>FK to civicrm_option_value.id, that has to be valid registered Email Greeting.</comment>
<add>3.0</add>
<pseudoconstant>
Expand Down Expand Up @@ -568,6 +569,7 @@
<name>postal_greeting_id</name>
<type>int unsigned</type>
<title>Postal Greeting ID</title>
<export>true</export>
<comment>FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.</comment>
<add>3.0</add>
<html>
Expand Down Expand Up @@ -606,6 +608,7 @@
<title>Addressee ID</title>
<comment>FK to civicrm_option_value.id, that has to be valid registered Addressee.</comment>
<add>3.0</add>
<export>true</export>
<pseudoconstant>
<optionGroupName>addressee</optionGroupName>
</pseudoconstant>
Expand Down

0 comments on commit 54e389a

Please sign in to comment.