X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FContact.php;h=bbd2f5e7c41f848eea70174d2899c78ae1c5092d;hb=6628866da4eb17b8ff190928d8afdbee11526ae6;hp=73e6f64f94fa1a8298997b6e311c0f13761eb545;hpb=0ec487ea57a821029c5c93649b59be52a0d50655;p=civicrm-core.git diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 73e6f64f94..bbd2f5e7c4 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -1,9 +1,9 @@ $params['current_employer'], + ); $dedupParams = CRM_Dedupe_Finder::formatParams($organizationParams, 'Organization'); @@ -351,6 +352,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; @@ -891,7 +903,7 @@ WHERE $whereClause /** - * Overrides _civicrm_api3_generic_getlist_params. + * @see _civicrm_api3_generic_getlist_params * * @param $request array */ @@ -934,7 +946,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