Commit 45fcf8b7 authored by colemanw's avatar colemanw

CRM-15451 - Fix api.getlist handling of deceased contacts

parent 8f41eb4a
......@@ -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',
......
......@@ -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;
}
}
/**
......
......@@ -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__);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment