X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FContact.php;h=438544a5aeb9fd7999ec8de0c38ab234040d8e2f;hb=e33df30ac5111d147f811b4c1d4330457048159b;hp=73e6f64f94fa1a8298997b6e311c0f13761eb545;hpb=9a84e4f8afedf897fc4627018ef99997aea76959;p=civicrm-core.git diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 73e6f64f94..438544a5ae 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -1,9 +1,9 @@ 'birth_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birthdate is equal to or greater than')); + $params['birth_date_high'] = array('name' => 'birth_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birthdate is equal to or less than')); + $params['deceased_date_low'] = array('name' => 'deceased_date_low','type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than')); + $params['deceased_date_high'] = array('name' => 'deceased_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or less than')); } /** @@ -325,17 +330,18 @@ function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeE $dedupeParams['check_permission'] = $params['check_permission']; } - $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type'], 'Strict', array()); + $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type'], 'Unsupervised', array()); if (count($ids) >0) { throw new API_Exception("Found matching contacts: ". implode(',',$ids),"duplicate",array("ids"=>$ids)); } } - //check for organisations with same name + // The BAO no longer supports the legacy param "current_employer" so here is a shim for api backward-compatability if (!empty($params['current_employer'])) { - $organizationParams = array(); - $organizationParams['organization_name'] = $params['current_employer']; + $organizationParams = array( + 'organization_name' => $params['current_employer'], + ); $dedupParams = CRM_Dedupe_Finder::formatParams($organizationParams, 'Organization'); @@ -351,6 +357,17 @@ function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeE if (empty($params['employer_id']) && (count($dupeIds) > 1)) { throw new API_Exception('Found more than one Organisation with same Name.'); } + + if ($dupeIds) { + $params['employer_id'] = $dupeIds[0]; + } + else { + $result = civicrm_api3('contact', 'create', array( + 'organization_name' => $params['current_employer'], + 'contact_type' => 'Organization' + )); + $params['employer_id'] = $result['id']; + } } return NULL; @@ -382,6 +399,7 @@ function _civicrm_api3_contact_update($params, $contactID = NULL) { * @param $params Associative array of property name/value * pairs to insert in new contact. * + * @throws API_Exception * @return array (reference ) null on success, error message otherwise * * @access public @@ -891,7 +909,7 @@ WHERE $whereClause /** - * Overrides _civicrm_api3_generic_getlist_params. + * @see _civicrm_api3_generic_getlist_params * * @param $request array */ @@ -934,7 +952,7 @@ function _civicrm_api3_contact_getlist_params(&$request) { } /** - * Overrides _civicrm_api3_generic_getlist_output + * @see _civicrm_api3_generic_getlist_output * * @param $result array * @param $request array