From: Coleman Watts Date: Tue, 14 Oct 2014 22:13:05 +0000 (-0400) Subject: CRM-15451 - Fix api.getlist handling of deceased contacts X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=45fcf8b76b12e0b244bae1abe8548419ea4fec26;p=civicrm-core.git CRM-15451 - Fix api.getlist handling of deceased contacts --- diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 28f9de52f2..4f82a425a8 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -180,12 +180,12 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { 'assignee_contact_id' => array( 'type' => 'entityRef', 'label' => ts('Assigned To'), - 'attributes' => array('multiple' => TRUE, 'create' => TRUE), + 'attributes' => array('multiple' => TRUE, 'create' => TRUE, 'api' => array('params' => array('is_deceased' => 0))), ), 'followup_assignee_contact_id' => array( 'type' => 'entityRef', 'label' => ts('Assigned To'), - 'attributes' => array('multiple' => TRUE, 'create' => TRUE), + 'attributes' => array('multiple' => TRUE, 'create' => TRUE, 'api' => array('params' => array('is_deceased' => 0))), ), 'followup_activity_type_id' => array( 'type' => 'select', diff --git a/api/v3/Contact.php b/api/v3/Contact.php index e287cb21e3..de3602f10a 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -984,10 +984,6 @@ function _civicrm_api3_contact_getlist_params(&$request) { if (!empty($request['input'])) { $request['params'][$request['search_field']] = $request['input']; } - // Exclude deceased contacts by default - if (!isset($request['params']['is_deceased'])) { - $request['params']['is_deceased'] = 0; - } } /** diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 7f3b519f00..c6cd376d2c 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -1853,16 +1853,20 @@ class api_v3_ContactTest extends CiviUnitTestCase { } /** - * CRM-15443 - ensure getlist api does not return deleted or deceased contacts + * CRM-15443 - ensure getlist api does not return deleted contacts */ function testGetlistExcludeConditions() { $name = md5(time()); - $contact1 = $this->individualCreate(array('last_name' => $name, 'is_deceased' => 1)); - $contact2 = $this->individualCreate(array('last_name' => $name, 'is_deleted' => 1)); - $contact3 = $this->individualCreate(array('last_name' => $name)); + $contact = $this->individualCreate(array('last_name' => $name)); + $deceasedContact = $this->individualCreate(array('last_name' => $name, 'is_deceased' => 1)); + $deletedContact = $this->individualCreate(array('last_name' => $name, 'is_deleted' => 1)); + // We should get all but the deleted contact $result = $this->callAPISuccess('contact', 'getlist', array('input' => $name)); + $this->assertEquals(2, $result['count'], 'In line ' . __LINE__); + // Force-exclude the deceased contact + $result = $this->callAPISuccess('contact', 'getlist', array('input' => $name, 'params' => array('is_deceased' => 0))); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); - $this->assertEquals($contact3, $result['values'][0]['id'], 'In line ' . __LINE__); + $this->assertEquals($contact, $result['values'][0]['id'], 'In line ' . __LINE__); } /**