+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
function civicrm_api3_profile_get($params) {
$nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE;
*/
function civicrm_api3_profile_get($params) {
$nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE;
- if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', array('contact_id' => $params['contact_id'], 'check_permissions' => 1))) {
+ if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', ['contact_id' => $params['contact_id'], 'check_permissions' => 1])) {
$ufGroupBAO = new CRM_Core_BAO_UFGroup();
foreach ($profiles as $profileID) {
$profileID = _civicrm_api3_profile_getProfileID($profileID);
$ufGroupBAO = new CRM_Core_BAO_UFGroup();
foreach ($profiles as $profileID) {
$profileID = _civicrm_api3_profile_getProfileID($profileID);
if (strtolower($profileID) == 'billing') {
$values[$profileID] = _civicrm_api3_profile_getbillingpseudoprofile($params);
continue;
if (strtolower($profileID) == 'billing') {
$values[$profileID] = _civicrm_api3_profile_getbillingpseudoprofile($params);
continue;
foreach ($profileFields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityFields[$fieldName] = $field;
foreach ($profileFields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityFields[$fieldName] = $field;
- $profileFields = civicrm_api3('Profile', 'getfields', array('action' => 'submit', 'profile_id' => $profileID));
+ $profileFields = civicrm_api3('Profile', 'getfields', ['action' => 'submit', 'profile_id' => $profileID]);
if ($params[$fieldName] && isset($params[$fieldName . '_id'])) {
$value = $params[$fieldName . '_id'];
}
if ($params[$fieldName] && isset($params[$fieldName . '_id'])) {
$value = $params[$fieldName . '_id'];
}
- $contactEntities = array('contact', 'individual', 'organization', 'household');
- $locationEntities = array('email', 'address', 'phone', 'website', 'im');
+ $contactEntities = ['contact', 'individual', 'organization', 'household'];
+ $locationEntities = ['email', 'address', 'phone', 'website', 'im'];
$entity = strtolower(CRM_Utils_Array::value('entity', $field));
if ($entity && !in_array($entity, array_merge($contactEntities, $locationEntities))) {
$entity = strtolower(CRM_Utils_Array::value('entity', $field));
if ($entity && !in_array($entity, array_merge($contactEntities, $locationEntities))) {
'contribution_id' => '$value.api.contribution.create.id',
'membership_id' => '$value.api.membership.create.id',
'contribution_id' => '$value.api.contribution.create.id',
'membership_id' => '$value.api.membership.create.id',
'contribution_id' => '$value.api.contribution.create.id',
'participant_id' => '$value.api.participant.create.id',
'contribution_id' => '$value.api.contribution.create.id',
'participant_id' => '$value.api.participant.create.id',
'billing_first_name' => '',
'billing_middle_name' => '',
'billing_last_name' => '',
'billing_first_name' => '',
'billing_middle_name' => '',
'billing_last_name' => '',
'billing_street_address-' . $locationTypeID => '',
'billing_country_id-' . $locationTypeID => $config->defaultContactCountry,
'billing_state_province_id-' . $locationTypeID => $config->defaultContactStateProvince,
'billing_street_address-' . $locationTypeID => '',
'billing_country_id-' . $locationTypeID => $config->defaultContactCountry,
'billing_state_province_id-' . $locationTypeID => $config->defaultContactStateProvince,
- $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code');
- $result = civicrm_api3('contact', 'getsingle', array(
+ $addressFields = ['street_address', 'city', 'state_province_id', 'country_id', 'postal_code'];
+ $result = civicrm_api3('contact', 'getsingle', [
- 'api.address.get.2' => array('is_billing' => TRUE, 'return' => $addressFields),
- 'api.email.get.1' => array('location_type_id' => 'Billing'),
- 'api.email.get.2' => array('is_billing' => TRUE),
+ 'api.address.get.2' => ['is_billing' => TRUE, 'return' => $addressFields],
+ 'api.email.get.1' => ['location_type_id' => 'Billing'],
+ 'api.email.get.2' => ['is_billing' => TRUE],
'return' => 'api.email.get, api.address.get, api.address.getoptions, country, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','),
'return' => 'api.email.get, api.address.get, api.address.getoptions, country, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','),
'billing_first_name' => $result['first_name'],
'billing_middle_name' => $result['middle_name'],
'billing_last_name' => $result['last_name'],
'billing_first_name' => $result['first_name'],
'billing_middle_name' => $result['middle_name'],
'billing_last_name' => $result['last_name'],
foreach ($fields['values'] as $field) {
if (!$field['is_active']) {
continue;
}
list($entity, $fieldName) = _civicrm_api3_map_profile_fields_to_entity($field);
foreach ($fields['values'] as $field) {
if (!$field['is_active']) {
continue;
}
list($entity, $fieldName) = _civicrm_api3_map_profile_fields_to_entity($field);
'api.required' => $field['is_required'],
'title' => $field['label'],
'help_pre' => CRM_Utils_Array::value('help_pre', $field),
'help_post' => CRM_Utils_Array::value('help_post', $field),
'entity' => $entity,
'weight' => CRM_Utils_Array::value('weight', $field),
'api.required' => $field['is_required'],
'title' => $field['label'],
'help_pre' => CRM_Utils_Array::value('help_pre', $field),
'help_post' => CRM_Utils_Array::value('help_post', $field),
'entity' => $entity,
'weight' => CRM_Utils_Array::value('weight', $field),
'state_province' => 'state_province_id',
'country' => 'country_id',
'participant_status' => 'status_id',
'state_province' => 'state_province_id',
'country' => 'country_id',
'participant_status' => 'status_id',
if (array_key_exists($ufFieldTaleFieldName, $hardCodedEntityFields)) {
$ufFieldTaleFieldName = $hardCodedEntityFields[$ufFieldTaleFieldName];
if (array_key_exists($ufFieldTaleFieldName, $hardCodedEntityFields)) {
$ufFieldTaleFieldName = $hardCodedEntityFields[$ufFieldTaleFieldName];
$entityGetFieldsResult = _civicrm_api3_profile_appendaliases($result['values'], $entity);
foreach ($entityFields as $entityfield => $realName) {
$fieldName = strtolower($entityfield);
$entityGetFieldsResult = _civicrm_api3_profile_appendaliases($result['values'], $entity);
foreach ($entityFields as $entityfield => $realName) {
$fieldName = strtolower($entityfield);
}
$profileFields[$profileID][$fieldName] = array_merge($entityGetFieldsResult[$realName], $profileFields[$profileID][$entityfield]);
if (!isset($profileFields[$profileID][$fieldName]['api.aliases'])) {
}
$profileFields[$profileID][$fieldName] = array_merge($entityGetFieldsResult[$realName], $profileFields[$profileID][$entityfield]);
if (!isset($profileFields[$profileID][$fieldName]['api.aliases'])) {
- if ($optionsBehaviour > 1 || !in_array($realName, array('state_province_id', 'county_id', 'country_id'))) {
- $options = civicrm_api3($entity, 'getoptions', array('field' => $realName));
+ if ($optionsBehaviour > 1 || !in_array($realName, ['state_province_id', 'county_id', 'country_id'])) {
+ $options = civicrm_api3($entity, 'getoptions', ['field' => $realName]);
- if (isset($result['values'][$realName]['default_value'])) {
- //this would be the case for a custom field with a configured default
- $profileFields[$profileID][$entityfield]['api.default'] = $result['values'][$realName]['default_value'];
- }
+ * if (isset($result['values'][$realName]['default_value'])) {
+ * //this would be the case for a custom field with a configured default
+ * $profileFields[$profileID][$entityfield]['api.default'] = $result['values'][$realName]['default_value'];
+ * }
if (in_array($entity, $contactTypes['values'])) {
$entity = 'contact';
}
$entity = _civicrm_api_get_entity_name_from_camel($entity);
if (in_array($entity, $contactTypes['values'])) {
$entity = 'contact';
}
$entity = _civicrm_api_get_entity_name_from_camel($entity);
$fieldName = $field['field_name'];
if (!empty($field['location_type_id'])) {
if ($fieldName == 'email') {
$fieldName = $field['field_name'];
if (!empty($field['location_type_id'])) {
if ($fieldName == 'email') {
// not a great solution but probably if we looked in the BAO we'd find a scary switch statement
// in a perfect world the uf_field table would hold the correct entity for each item
// & only the relationships between entities would need to be coded
// not a great solution but probably if we looked in the BAO we'd find a scary switch statement
// in a perfect world the uf_field table would hold the correct entity for each item
// & only the relationships between entities would need to be coded
'street_address' => 'address',
'street_number' => 'address',
'supplemental_address_1' => 'address',
'street_address' => 'address',
'street_number' => 'address',
'supplemental_address_1' => 'address',
if (array_key_exists($fieldName, $hardCodedEntityMappings)) {
$entity = $hardCodedEntityMappings[$fieldName];
}
if (array_key_exists($fieldName, $hardCodedEntityMappings)) {
$entity = $hardCodedEntityMappings[$fieldName];
}
*/
function _civicrm_api3_profile_getProfileID($profileID) {
if (!empty($profileID) && strtolower($profileID) != 'billing' && !is_numeric($profileID)) {
*/
function _civicrm_api3_profile_getProfileID($profileID) {
if (!empty($profileID) && strtolower($profileID) != 'billing' && !is_numeric($profileID)) {
- $profileID = civicrm_api3('uf_group', 'getvalue', array('return' => 'id', 'name' => $profileID));
+ $profileID = civicrm_api3('uf_group', 'getvalue', ['return' => 'id', 'name' => $profileID]);
- if (in_array($entity, array('membership', 'contribution'))) {
- $values['send_receipt'] = array('title' => 'Send Receipt', 'type' => (int) 16);
+ if (in_array($entity, ['membership', 'contribution'])) {
+ $values['send_receipt'] = ['title' => 'Send Receipt', 'type' => (int) 16];
'set' => 'Profile api "set" action is deprecated in favor of "submit".',
'apply' => 'Profile api "apply" action is deprecated in favor of "submit".',
'set' => 'Profile api "set" action is deprecated in favor of "submit".',
'apply' => 'Profile api "apply" action is deprecated in favor of "submit".',