X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FContact.php;h=2d1da21a38d19f36b470d779284c0ddc60fe590a;hb=3c53c5df46bccc842a5fe6bbcf2c89bb5607edf5;hp=e09fc91ee17bc544fc21bba3d3ea8d0c2ce0127a;hpb=019f6a19ff823a42c09ab00d12a55aeb92e1cb6c;p=civicrm-core.git diff --git a/api/v3/Contact.php b/api/v3/Contact.php index e09fc91ee1..2d1da21a38 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -129,6 +129,8 @@ function civicrm_api3_contact_create($params) { _civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]); } + $values = _civicrm_api3_contact_formatResult($params, $values); + return civicrm_api3_create_success($values, $params, 'Contact', 'create'); } @@ -168,9 +170,39 @@ function civicrm_api3_contact_get($params) { $options = array(); _civicrm_api3_contact_get_supportanomalies($params, $options); $contacts = _civicrm_api3_get_using_query_object('Contact', $params, $options); + $contacts = _civicrm_api3_contact_formatResult($params, $contacts); return civicrm_api3_create_success($contacts, $params, 'Contact'); } +/** + * Filter the result. + * + * @param array $result + * + * @return array + * @throws \CRM_Core_Exception + */ +function _civicrm_api3_contact_formatResult($params, $result) { + $apiKeyPerms = array('edit api keys', 'administer CiviCRM'); + $allowApiKey = empty($params['check_permissions']) || CRM_Core_Permission::check(array($apiKeyPerms)); + if (!$allowApiKey) { + if (is_array($result)) { + // Single-value $result + if (isset($result['api_key'])) { + unset($result['api_key']); + } + + // Multi-value $result + foreach ($result as $key => $row) { + if (is_array($row)) { + unset($result[$key]['api_key']); + } + } + } + } + return $result; +} + /** * Get number of contacts matching the supplied criteria. * @@ -212,6 +244,10 @@ function _civicrm_api3_contact_get_spec(&$params) { 'title' => 'Primary Address Supplemental Address 2', 'type' => CRM_Utils_Type::T_STRING, ); + $params['supplemental_address_3'] = array( + 'title' => 'Primary Address Supplemental Address 3', + 'type' => CRM_Utils_Type::T_STRING, + ); $params['current_employer'] = array( 'title' => 'Current Employer', 'type' => CRM_Utils_Type::T_STRING, @@ -1250,6 +1286,11 @@ function _civicrm_api3_contact_getlist_params(&$request) { // Contact api doesn't support array(LIKE => 'foo') syntax if (!empty($request['input'])) { $request['params'][$request['search_field']] = $request['input']; + // Temporarily override wildcard setting + if (Civi::settings()->get('includeWildCardInName') != $request['add_wildcard']) { + Civi::$statics['civicrm_api3_contact_getlist']['override_wildcard'] = !$request['add_wildcard']; + Civi::settings()->set('includeWildCardInName', $request['add_wildcard']); + } } } @@ -1302,6 +1343,11 @@ function _civicrm_api3_contact_getlist_output($result, $request) { $output[] = $data; } } + // Restore wildcard override by _civicrm_api3_contact_getlist_params + if (isset(Civi::$statics['civicrm_api3_contact_getlist']['override_wildcard'])) { + Civi::settings()->set('includeWildCardInName', Civi::$statics['civicrm_api3_contact_getlist']['override_wildcard']); + unset(Civi::$statics['civicrm_api3_contact_getlist']['override_wildcard']); + } return $output; }