X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FContact.php;h=4ec440ef9b27c2766ff28e20de00a8fb8ff77eea;hb=85bb0909cffd925f4cd5c0022a68a1ff74d3ad8e;hp=4921d0b92eac299efbae83bf5a91370de93888cb;hpb=67cfa3334fa2782fbe827ee1036e87d78c24b2f8;p=civicrm-core.git diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 4921d0b92e..4ec440ef9b 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')); } /** @@ -281,6 +291,17 @@ function civicrm_api3_contact_delete($params) { } +/** + * @param $params + * @param bool $dupeCheck + * @param bool $dupeErrorArray + * @param bool $obsoletevalue + * @param null $dedupeRuleGroupID + * + * @return null + * @throws API_Exception + * @throws CiviCRM_API3_Exception + */ function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeErrorArray = false, $obsoletevalue = true, $dedupeRuleGroupID = null ) { @@ -332,10 +353,11 @@ function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeE } } - //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 +373,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; @@ -379,10 +412,10 @@ function _civicrm_api3_contact_update($params, $contactID = NULL) { /** * Validate the addressee or email or postal greetings * - * @param $params Associative array of property name/value + * @param array $params Associative array of property name/value * pairs to insert in new contact. * - * @return array (reference ) null on success, error message otherwise + * @throws API_Exception * * @access public */ @@ -839,12 +872,21 @@ function civicrm_api3_contact_merge($params) { } } +/** + * @param $params + */ function _civicrm_api3_contact_proximity_spec(&$params) { $params['latitude']['api.required'] = 1; $params['longitude']['api.required'] = 1; $params['unit']['api.default'] = 'meter'; } +/** + * @param $params + * + * @return array + * @throws Exception + */ function civicrm_api3_contact_proximity($params) { $latitude = CRM_Utils_Array::value('latitude', $params); $longitude = CRM_Utils_Array::value('longitude', $params); @@ -891,7 +933,7 @@ WHERE $whereClause /** - * Overrides _civicrm_api3_generic_getlist_params. + * @see _civicrm_api3_generic_getlist_params * * @param $request array */ @@ -928,11 +970,13 @@ function _civicrm_api3_contact_getlist_params(&$request) { $request['params']['return'] = array_unique(array_merge($list, $request['extra'])); $request['params']['options']['sort'] = 'sort_name'; // Contact api doesn't support array(LIKE => 'foo') syntax - $request['params'][$request['search_field']] = $request['input']; + if (!empty($request['input'])) { + $request['params'][$request['search_field']] = $request['input']; + } } /** - * Overrides _civicrm_api3_generic_getlist_output + * @see _civicrm_api3_generic_getlist_output * * @param $result array * @param $request array