* UF group BAO class.
*/
class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
+
const PUBLIC_VISIBILITY = 1,
ADMIN_VISIBILITY = 2,
LISTINGS_VISIBILITY = 4;
* @param int $mode
* Mode.
*
- * @param null $ctype
+ * @param string $ctype
*
* @return array
* the fields that are needed for registration
+ *
+ * @throws \Exception
*/
public static function getRegistrationFields($action, $mode, $ctype = NULL) {
if ($mode & CRM_Profile_Form::MODE_REGISTER) {
return FALSE;
}
- $fields = array();
+ $fields = [];
foreach ($ufGroups as $id => $title) {
if ($ctype) {
* @param null $restrict
* @param bool $skipPermission
* @param int $permissionType
+ *
* @return array
* the fields that are listings related
+ *
+ * @throws \Exception
*/
public static function getListingFields(
$action,
else {
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
- $fields = array();
+ $fields = [];
foreach ($ufGroups as $id => $title) {
$subset = self::getFields($id, FALSE, $action,
$visibility, $searchable,
*
* @return array
* The fields that belong to this ufgroup(s)
- * @throws \Exception
+ *
+ * @throws \CRM_Core_Exception
*/
public static function getFields(
$id,
) {
if (!is_array($id)) {
$id = CRM_Utils_Type::escape($id, 'Positive');
- $profileIds = array($id);
+ $profileIds = [$id];
}
else {
$profileIds = $id;
}
$gids = implode(',', $profileIds);
- $params = array();
+ $params = [];
if ($restrict) {
$query = "SELECT g.* from civicrm_uf_group g
LEFT JOIN civicrm_uf_join j ON (j.uf_group_id = g.id)
WHERE g.id IN ( {$gids} )
AND ((j.uf_group_id IN ( {$gids} ) AND j.module = %1) OR g.is_reserved = 1 )
";
- $params = array(1 => array($restrict, 'String'));
+ $params = [1 => [$restrict, 'String']];
}
else {
$query = "SELECT g.* from civicrm_uf_group g WHERE g.id IN ( {$gids} ) ";
$query .= " AND g.is_active = 1";
}
- $checkPermission = array(
- array(
+ $checkPermission = [
+ [
'administer CiviCRM',
'manage event profiles',
- ),
- );
+ ],
+ ];
if ($eventProfile && CRM_Core_Permission::check($checkPermission)) {
$skipPermission = TRUE;
}
$query .= " ORDER BY FIELD( g.id, {$gids} )";
}
$group = CRM_Core_DAO::executeQuery($query, $params);
- $fields = array();
+ $fields = [];
$validGroup = FALSE;
while ($group->fetch()) {
}
if (empty($fields) && !$validGroup) {
- CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
- array(1 => implode(',', $profileIds))
+ throw new CRM_Core_Exception(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
+ [1 => implode(',', $profileIds)]
));
}
else {
$importableFields = self::getImportableFields($showAll, $profileType, $contactActivityProfile);
list($customFields, $addressCustomFields) = self::getCustomFields($ctype);
- $formattedFields = array();
+ $formattedFields = [];
foreach ($fieldArrs as $fieldArr) {
$field = (object) $fieldArr;
if (!self::filterUFField($field, $searchable, $showAll, $visibility)) {
* @param array $importableFields
* @param int $permissionType
* Eg CRM_Core_Permission::CREATE.
+ *
* @return array
*/
protected static function formatUFField(
$title = $field->label;
$addressCustom = FALSE;
- if (in_array($permissionType, array(
- CRM_Core_Permission::CREATE,
- CRM_Core_Permission::EDIT,
- )) &&
+ if (in_array($permissionType, [CRM_Core_Permission::CREATE, CRM_Core_Permission::EDIT]) &&
in_array($field->field_name, array_keys($addressCustomFields))
) {
$addressCustom = TRUE;
if (isset($field->phone_type_id)) {
$name .= "-{$field->phone_type_id}";
}
- $fieldMetaData = CRM_Utils_Array::value($name, $importableFields, (isset($importableFields[$field->field_name]) ? $importableFields[$field->field_name] : array()));
+ $fieldMetaData = CRM_Utils_Array::value($name, $importableFields, (isset($importableFields[$field->field_name]) ? $importableFields[$field->field_name] : []));
// No lie: this is bizarre; why do we need to mix so many UFGroup properties into UFFields?
// I guess to make field self sufficient with all the required data and avoid additional calls
- $formattedField = array(
+ $formattedField = [
'name' => $name,
'groupTitle' => $group->title,
'groupName' => $group->name,
'skipDisplay' => 0,
'data_type' => CRM_Utils_Type::getDataTypeFromFieldMetadata($fieldMetaData),
'bao' => CRM_Utils_Array::value('bao', $fieldMetaData),
- );
+ ];
$formattedField = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $formattedField);
}
$formattedField['is_multi_summary'] = $field->is_multi_summary;
- return array($name, $formattedField);
+ return [$name, $formattedField];
}
else {
$formattedField = NULL;
- return array($name, $formattedField);
+ return [$name, $formattedField];
}
}
- return array($name, $formattedField);
+ return [$name, $formattedField];
}
/**
* @param int $visibility
* @param string $orderBy
* Comma-delimited list of SQL columns.
+ *
* @return string
*/
protected static function createUFFieldQuery($groupId, $searchable, $showAll, $visibility, $orderBy) {
}
if ($visibility) {
- $clause = array();
+ $clause = [];
if ($visibility & self::PUBLIC_VISIBILITY) {
$clause[] = 'visibility = "Public Pages"';
}
* @param bool $searchable
* @param bool $showAll
* @param int $visibility
+ *
* @return bool
* TRUE if field is displayable
*/
}
if ($visibility) {
- $allowedVisibilities = array();
+ $allowedVisibilities = [];
if ($visibility & self::PUBLIC_VISIBILITY) {
$allowedVisibilities[] = 'Public Pages';
}
/**
* Get a list of filtered field metadata.
*
- * @deprecated use getProfileFieldMetadata
- *
* @param $showAll
* @param $profileType
* @param $contactActivityProfile
* send this confusion to history.
*
* @return array
+ * @deprecated use getProfileFieldMetadata
+ *
*/
protected static function getImportableFields($showAll, $profileType, $contactActivityProfile, $filterMode = TRUE) {
if (!$showAll) {
* @return array
*/
public static function getLocationFields() {
- static $locationFields = array(
+ static $locationFields = [
'street_address',
'supplemental_address_1',
'supplemental_address_2',
'im',
'address_name',
'phone_ext',
- );
+ ];
return $locationFields;
}
* @return mixed
*/
protected static function getCustomFields($ctype) {
- static $customFieldCache = array();
+ static $customFieldCache = [];
if (!isset($customFieldCache[$ctype])) {
$customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype, FALSE, FALSE, FALSE, TRUE, TRUE);
// hack to add custom data for components
- $components = array('Contribution', 'Participant', 'Membership', 'Activity', 'Case');
+ $components = ['Contribution', 'Participant', 'Membership', 'Activity', 'Case'];
foreach ($components as $value) {
$customFields = array_merge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value));
}
$addressCustomFields = CRM_Core_BAO_CustomField::getFieldsForImport('Address');
$customFields = array_merge($customFields, $addressCustomFields);
- $customFieldCache[$ctype] = array($customFields, $addressCustomFields);
+ $customFieldCache[$ctype] = [$customFields, $addressCustomFields];
}
return $customFieldCache[$ctype];
}
// get the contact details (hier)
$returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($fields);
- $params = $cid ? array(array('contact_id', '=', $cid, 0, 0)) : array();
+ $params = $cid ? [['contact_id', '=', $cid, 0, 0]] : [];
// add conditions specified by components. eg partcipant_id etc
if (!empty($componentWhere)) {
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
- $multipleFields = array('url');
+ $multipleFields = ['url'];
//start of code to set the default values
foreach ($fields as $name => $field) {
// hack for CRM-665
if (isset($details->$name) || $name == 'group' || $name == 'tag') {
// to handle gender / suffix / prefix
- if (in_array(substr($name, 0, -3), array('gender', 'prefix', 'suffix'))) {
+ if (in_array(substr($name, 0, -3), ['gender', 'prefix', 'suffix'])) {
$params[$index] = $details->$name;
$values[$index] = $details->$name;
}
$name = $name . '_id';
$params[$index] = $details->$name;
}
- elseif (in_array($name, array(
+ elseif (in_array($name, [
'state_province',
'country',
'county',
- ))) {
+ ])) {
$values[$index] = $details->$name;
$idx = $name . '_id';
$params[$index] = $details->$idx;
}
elseif ($name == 'group') {
$groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', NULL, FALSE, TRUE);
- $title = $ids = array();
+ $title = $ids = [];
foreach ($groups as $g) {
// CRM-8362: User and User Admin visibility groups should be included in display if user has
}
elseif ($name == 'tag') {
$entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
- $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $title = array();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]);
+ $title = [];
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
}
elseif ($name == 'contact_sub_type') {
$contactSubTypeNames = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name);
if (!empty($contactSubTypeNames)) {
- $contactSubTypeLabels = array();
+ $contactSubTypeLabels = [];
// get all contact subtypes
$allContactSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
// build contact subtype labels array
$image_URL = '<img src="' . $details->$name . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . ' />';
$values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->$name}\", {$width}, {$height});'>{$image_URL}</a>";
}
- elseif (in_array($name, array(
+ elseif (in_array($name, [
'birth_date',
'deceased_date',
- ))) {
+ ])) {
// @todo this set should be determined from metadata, not hard-coded.
$values[$index] = CRM_Utils_Date::customFormat($details->$name);
$params[$index] = CRM_Utils_Date::isoToMysql($details->$name);
$detailName = "{$locationTypeName}-{$fieldName}";
$detailName = str_replace(' ', '_', $detailName);
- if (in_array($fieldName, array(
+ if (in_array($fieldName, [
'phone',
'im',
'email',
'openid',
- ))) {
+ ])) {
if ($type) {
$detailName .= "-{$type}";
}
}
- if (in_array($fieldName, array(
+ if (in_array($fieldName, [
'state_province',
'country',
'county',
- ))) {
+ ])) {
$values[$index] = $details->$detailName;
$idx = $detailName . '_id';
$params[$index] = $details->$idx;
if ($htmlType == 'Link') {
$url = $params[$index];
}
- elseif (in_array($htmlType, array(
+ elseif (in_array($htmlType, [
'CheckBox',
'Multi-Select',
'Multi-Select State/Province',
'Multi-Select Country',
- ))) {
+ ])) {
$valSeperator = CRM_Core_DAO::VALUE_SEPARATOR;
$selectedOptions = explode($valSeperator, $params[$index]);
) {
if (is_array($url) && !empty($url)) {
- $links = array();
+ $links = [];
$eachMultiValue = explode(', ', $values[$index]);
foreach ($eachMultiValue as $key => $valueLabel) {
$links[] = '<a href="' . $url[$key] . '">' . $valueLabel . '</a>';
*
* @return object
*/
- public static function add(&$params, $ids = array()) {
- $fields = array(
+ public static function add(&$params, $ids = []) {
+ $fields = [
'is_active',
'add_captcha',
'is_map',
'is_edit_link',
'is_uf_link',
'is_cms_user',
- );
+ ];
foreach ($fields as $field) {
$params[$field] = CRM_Utils_Array::value($field, $params, FALSE);
}
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($groupTypes)) {
- $groupTypes = array();
+ $groupTypes = [];
}
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($ufGroupRecord)) {
- $ufGroupRecord = array();
+ $ufGroupRecord = [];
}
// check which values has to be inserted/deleted for contact
$menuRebuild = FALSE;
foreach ($allUFGroupType as $key => $value) {
- $joinParams = array();
+ $joinParams = [];
$joinParams['uf_group_id'] = $ufGroupId;
$joinParams['module'] = $key;
if ($key == 'User Account') {
WHERE uf_group_id = %2
AND ( entity_id IS NULL OR entity_id <= 0 )
";
- $p = array(
- 1 => array($params['weight'], 'Integer'),
- 2 => array($ufGroupId, 'Integer'),
- );
+ $p = [
+ 1 => [$params['weight'], 'Integer'],
+ 2 => [$ufGroupId, 'Integer'],
+ ];
CRM_Core_DAO::executeQuery($query, $p);
// Do a menu rebuild, so it gets all the new menu entries for user account
*/
public static function getUFJoinRecord($ufGroupId = NULL, $displayName = NULL, $status = NULL) {
if ($displayName) {
- $UFGroupType = array();
+ $UFGroupType = [];
$UFGroupType = CRM_Core_SelectValues::ufGroupTypes();
}
- $ufJoin = array();
+ $ufJoin = [];
$dao = new CRM_Core_DAO_UFJoin();
if ($ufGroupId) {
}
$dao->find();
- $ufJoin = array();
+ $ufJoin = [];
while ($dao->fetch()) {
if (!$displayName) {
*/
public static function getWeight($ufGroupId = NULL) {
//calculate the weight
- $p = array();
+ $p = [];
if (!$ufGroupId) {
$queryString = "SELECT ( MAX(civicrm_uf_join.weight)+1) as new_weight
FROM civicrm_uf_join
FROM civicrm_uf_join
WHERE civicrm_uf_join.uf_group_id = %1
AND ( entity_id IS NULL OR entity_id <= 0 )";
- $p[1] = array($ufGroupId, 'Integer');
+ $p[1] = [$ufGroupId, 'Integer'];
}
$dao = CRM_Core_DAO::executeQuery($queryString, $p);
* array of ufgroups for a module
*/
public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL) {
- $selectFields = array('id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type');
+ $selectFields = ['id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type'];
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_uf_group', 'description')) {
// CRM-13555, since description field was added later (4.4), and to avoid any problems with upgrade
$queryString = 'SELECT civicrm_uf_group.' . implode(', civicrm_uf_group.', $selectFields) . '
FROM civicrm_uf_group
LEFT JOIN civicrm_uf_join ON (civicrm_uf_group.id = uf_group_id)';
- $p = array();
+ $p = [];
if ($moduleName) {
$queryString .= ' AND civicrm_uf_group.is_active = 1
WHERE civicrm_uf_join.module = %2';
- $p[2] = array($moduleName, 'String');
+ $p[2] = [$moduleName, 'String'];
}
// add permissioning for profiles only if not registration
$queryString .= ' ORDER BY civicrm_uf_join.weight, civicrm_uf_group.title';
$dao = CRM_Core_DAO::executeQuery($queryString, $p);
- $ufGroups = array();
+ $ufGroups = [];
while ($dao->fetch()) {
//skip mix profiles in user Registration / User Account
- if (($moduleName == 'User Registration' || $moduleName == 'User Account') &&
+ if (($moduleName === 'User Registration' || $moduleName === 'User Account') &&
CRM_Core_BAO_UFField::checkProfileType($dao->id)
) {
continue;
}
foreach ($selectFields as $key => $field) {
- if ($field == 'id') {
+ if ($field === 'id') {
continue;
}
$ufGroups[$dao->id][$field] = $dao->$field;
}
//allow special mix profiles for Contribution and Participant
- $specialProfiles = array('Contribution', 'Participant', 'Membership');
+ $specialProfiles = ['Contribution', 'Participant', 'Membership'];
if (in_array($profileType, $specialProfiles)) {
return TRUE;
$rowNumber = NULL,
$prefix = ''
) {
- $defaultValues = array();
+ $defaultValues = [];
$fieldName = $field['name'];
$title = $field['title'];
$attributes = $field['attributes'];
$name = $fieldName;
}
- $selectAttributes = array('class' => 'crm-select2', 'placeholder' => TRUE);
+ $selectAttributes = ['class' => 'crm-select2', 'placeholder' => TRUE];
if ($fieldName == 'image_URL' && $mode == CRM_Profile_Form::MODE_EDIT) {
$deleteExtra = json_encode(ts('Are you sure you want to delete contact image.'));
- $deleteURL = array(
- CRM_Core_Action::DELETE => array(
+ $deleteURL = [
+ CRM_Core_Action::DELETE => [
'name' => ts('Delete Contact Image'),
'url' => 'civicrm/contact/image',
'qs' => 'reset=1&id=%%id%%&gid=%%gid%%&action=delete',
'extra' => 'onclick = "' . htmlspecialchars("if (confirm($deleteExtra)) this.href+='&confirmed=1'; else return false;") . '"',
- ),
- );
+ ],
+ ];
$deleteURL = CRM_Core_Action::formLink($deleteURL,
CRM_Core_Action::DELETE,
- array(
+ [
'id' => $form->get('id'),
'gid' => $form->get('gid'),
- ),
+ ],
ts('more'),
FALSE,
'contact.profileimage.delete',
);
if (substr($fieldName, 0, 14) === 'state_province') {
- $form->addChainSelect($name, array('label' => $title, 'required' => $required));
+ $form->addChainSelect($name, ['label' => $title, 'required' => $required]);
$config = CRM_Core_Config::singleton();
- if (!in_array($mode, array(
- CRM_Profile_Form::MODE_EDIT,
- CRM_Profile_Form::MODE_SEARCH,
- )) &&
+ if (!in_array($mode, [CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH]) &&
$config->defaultContactStateProvince
) {
$defaultValues[$name] = $config->defaultContactStateProvince;
}
}
elseif (substr($fieldName, 0, 7) === 'country') {
- $form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required, $selectAttributes);
+ $form->add('select', $name, $title, ['' => ts('- select -')] + CRM_Core_PseudoConstant::country(), $required, $selectAttributes);
$config = CRM_Core_Config::singleton();
- if (!in_array($mode, array(
- CRM_Profile_Form::MODE_EDIT,
- CRM_Profile_Form::MODE_SEARCH,
- )) &&
+ if (!in_array($mode, [CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH]) &&
$config->defaultContactCountry
) {
$defaultValues[$name] = $config->defaultContactCountry;
}
elseif (substr($fieldName, 0, 6) === 'county') {
if ($addressOptions['county']) {
- $form->addChainSelect($name, array('label' => $title, 'required' => $required));
+ $form->addChainSelect($name, ['label' => $title, 'required' => $required]);
}
}
elseif (substr($fieldName, 0, 9) === 'image_URL') {
$form->add('text', $name, $title, $attributes, $required);
if (!$contactId) {
if ($usedFor) {
- if (substr($name, -1) == ']') {
+ if (substr($name, -1) === ']') {
$providerName = substr($name, 0, -1) . '-provider_id]';
}
$form->add('select', $providerName, NULL,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
+ ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
);
}
else {
$form->add('select', $name . '-provider_id', $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
+ ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
);
}
elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') {
list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo();
$sel = &$form->addElement('hierselect', $name, $title);
- $select = array('' => ts('- select -'));
+ $select = ['' => ts('- select -')];
if (count($orgInfo) == 1 && $field['is_required']) {
// we only have one org - so we should default to it. Not sure about defaulting to first type
// as it could be missed - so adding a select
else {
$orgInfo = $select + $orgInfo;
}
- $sel->setOptions(array($orgInfo, $types));
+ $sel->setOptions([$orgInfo, $types]);
}
elseif (CRM_Utils_Array::value('name', $field) == 'membership_status') {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required
+ ] + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required
);
}
- elseif (in_array($fieldName, array('gender_id', 'communication_style_id'))) {
- $options = array();
+ elseif (in_array($fieldName, ['gender_id', 'communication_style_id'])) {
+ $options = [];
$pseudoValues = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $fieldName);
foreach ($pseudoValues as $key => $var) {
$options[$key] = $form->createElement('radio', NULL, ts($title), $var, $key);
}
$group = $form->addGroup($options, $name, $title);
if ($required) {
- $form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required');
+ $form->addRule($name, ts('%1 is a required field.', [1 => $title]), 'required');
}
else {
$group->setAttribute('allowClear', TRUE);
}
}
elseif ($fieldName === 'prefix_id' || $fieldName === 'suffix_id') {
- $form->addSelect($name, array(
+ $form->addSelect($name, [
'label' => $title,
'entity' => 'contact',
'field' => $fieldName,
'class' => 'six',
'placeholder' => '',
- ), $required);
+ ], $required);
}
elseif ($fieldName === 'contact_sub_type') {
$gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field);
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
- $subtypes = $profileType ? CRM_Contact_BAO_ContactType::subTypePairs($profileType) : array();
+ $subtypes = $profileType ? CRM_Contact_BAO_ContactType::subTypePairs($profileType) : [];
if ($setSubtype) {
- $subtypeList = array();
+ $subtypeList = [];
$subtypeList[$setSubtype] = $subtypes[$setSubtype];
}
else {
$subtypeList = $subtypes;
}
- $form->add('select', $name, $title, $subtypeList, $required, array('class' => 'crm-select2', 'multiple' => TRUE));
+ $form->add('select', $name, $title, $subtypeList, $required, ['class' => 'crm-select2', 'multiple' => TRUE]);
}
elseif (in_array($fieldName, CRM_Contact_BAO_Contact::$_greetingTypes)) {
- //add email greeting, postal greeting, addressee, CRM-4575
- $gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field);
+ // Get contact type for greeting selector
+ $gId = $form->get('gid') ?: CRM_Utils_Array::value('group_id', $field);
$profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE);
- if (empty($profileType) || in_array($profileType, array(
- 'Contact',
- 'Contribution',
- 'Participant',
- 'Membership',
- ))
- ) {
- $profileType = 'Individual';
+ if (!$profileType || in_array($profileType, ['Contact', 'Contribution', 'Participant', 'Membership'])) {
+ $profileType = ($profileType == 'Contact' && $form->get('id')) ? CRM_Contact_BAO_Contact::getContactType($form->get('id')) : 'Individual';
}
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
- $greeting = array(
+ $greeting = [
'contact_type' => $profileType,
'greeting_type' => $fieldName,
- );
- $form->add('select', $name, $title,
- array(
- '' => ts('- select -'),
- ) + CRM_Core_PseudoConstant::greeting($greeting), $required
- );
+ ];
+ $form->add('select', $name, $title, ['' => ts('- select -')] + CRM_Core_PseudoConstant::greeting($greeting), $required);
// add custom greeting element
- $form->add('text', $fieldName . '_custom', ts('Custom %1', array(1 => ucwords(str_replace('_', ' ', $fieldName)))),
+ $form->add('text', $fieldName . '_custom', ts('Custom %1', [1 => ucwords(str_replace('_', ' ', $fieldName))]),
NULL, FALSE
);
}
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
}
elseif ($fieldName === 'preferred_language') {
- $form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contact_BAO_Contact::buildOptions('preferred_language'));
+ $form->add('select', $name, $title, ['' => ts('- select -')] + CRM_Contact_BAO_Contact::buildOptions('preferred_language'));
}
elseif ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$form->addRule($name,
ts('External ID already exists in Database.'),
'objectExists',
- array('CRM_Contact_DAO_Contact', $contID, 'external_identifier')
+ ['CRM_Contact_DAO_Contact', $contID, 'external_identifier']
);
}
elseif ($fieldName === 'group') {
$form->addElement('checkbox', $name, $title);
}
elseif ($fieldName == 'soft_credit') {
- $form->addEntityRef("soft_credit_contact_id[$rowNumber]", ts('Soft Credit To'), array('create' => TRUE));
+ $form->addEntityRef("soft_credit_contact_id[$rowNumber]", ts('Soft Credit To'), ['create' => TRUE]);
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
}
- elseif ($fieldName == 'product_name') {
+ elseif ($fieldName === 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel = &$form->addElement('hierselect', $name, $title);
- $products = array(
- '0' => ts('- select -'),
- ) + $products;
- $sel->setOptions(array($products, $options));
+ $products = ['0' => ts('- select -')] + $products;
+ $sel->setOptions([$products, $options]);
}
- elseif ($fieldName == 'payment_instrument') {
+ elseif ($fieldName === 'payment_instrument') {
$form->add('select', $name, $title,
- array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
+ ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
}
- elseif ($fieldName == 'financial_type') {
+ elseif ($fieldName === 'financial_type') {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Contribute_PseudoConstant::financialType(), $required
+ ] + CRM_Contribute_PseudoConstant::financialType(), $required
);
}
- elseif ($fieldName == 'contribution_status_id') {
- $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
+ elseif ($fieldName === 'contribution_status_id') {
+ $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label');
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- foreach (array(
- 'In Progress',
- 'Overdue',
- 'Refunded',
- ) as $suppress) {
+ foreach (['In Progress', 'Overdue', 'Refunded'] as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + $contributionStatuses, $required
+ ] + $contributionStatuses, $required
);
}
- elseif ($fieldName == 'soft_credit_type') {
+ elseif ($fieldName === 'soft_credit_type') {
$name = "soft_credit_type[$rowNumber]";
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Core_OptionGroup::values("soft_credit_type")
+ ] + CRM_Core_OptionGroup::values("soft_credit_type")
);
//CRM-15350: choose SCT field default value as 'Gift' for membership use
//else (for contribution), use configured SCT default value
if ($field['field_type'] == 'Membership') {
$SCTDefaultValue = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'gift');
}
- $form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id'));
+ $form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, ['id' => 'sct_default_id']);
}
elseif ($fieldName == 'contribution_soft_credit_pcp_id') {
CRM_Contribute_Form_SoftCredit::addPCPFields($form, "[$rowNumber]");
}
elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"'
+ ] + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"'
);
}
elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Core_PseudoConstant::activityStatus(), $required
+ ] + CRM_Core_PseudoConstant::activityStatus(), $required
);
}
elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Campaign_PseudoConstant::engagementLevel(), $required
+ ] + CRM_Campaign_PseudoConstant::engagementLevel(), $required
);
}
elseif ($fieldName == 'participant_status') {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required
+ ] + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required
);
}
elseif ($fieldName == 'participant_role') {
}
else {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Event_PseudoConstant::participantRole(), $required
+ ] + CRM_Event_PseudoConstant::participantRole(), $required
);
}
}
$form->_componentCampaigns
));
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + $campaigns, $required, 'class="crm-select2 big"'
+ ] + $campaigns, $required, 'class="crm-select2 big"'
);
}
}
elseif ($fieldName == 'activity_details') {
- $form->add('wysiwyg', $fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
+ $form->add('wysiwyg', $fieldName, $title, ['rows' => 4, 'cols' => 60], $required);
}
elseif ($fieldName == 'activity_duration') {
$form->add('text', $name, $title, $attributes, $required);
}
elseif ($fieldName == 'case_status') {
$form->add('select', $name, $title,
- array(
+ [
'' => ts('- select -'),
- ) + CRM_Case_BAO_Case::buildOptions('case_status_id', 'create'),
+ ] + CRM_Case_BAO_Case::buildOptions('case_status_id', 'create'),
$required
);
}
}
//add the rules
- if (in_array($fieldName, array(
+ if (in_array($fieldName, [
'non_deductible_amount',
'total_amount',
'fee_amount',
'net_amount',
- ))) {
+ ])) {
$form->addRule($name, ts('Please enter a valid amount.'), 'money');
}
if ($rule) {
if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) {
- $form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule);
+ $form->addRule($name, ts('Please enter a valid %1', [1 => $title]), $rule);
}
}
}
//get the contact details
list($contactDetails, $options) = CRM_Contact_BAO_Contact::getHierContactDetails($contactId, $fields);
$details = CRM_Utils_Array::value($contactId, $contactDetails);
- $multipleFields = array('website' => 'url');
+ $multipleFields = ['website' => 'url'];
//start of code to set the default values
foreach ($fields as $name => $field) {
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $details));
// hack to add custom data for components
- $components = array('Contribution', 'Participant', 'Membership', 'Activity');
+ $components = ['Contribution', 'Participant', 'Membership', 'Activity'];
foreach ($components as $value) {
$customFields = CRM_Utils_Array::crmArrayMerge($customFields,
CRM_Core_BAO_CustomField::getFieldsForImport($value)
}
}
else {
- $blocks = array('email', 'phone', 'im', 'openid');
+ $blocks = ['email', 'phone', 'im', 'openid'];
list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $name, 3);
if (!in_array($fieldName, $multipleFields)) {
if (is_array($details)) {
* associative array of profiles
*/
public static function getProfiles($types, $onlyPure = FALSE) {
- $profiles = array();
+ $profiles = [];
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups);
return NULL;
}
- $profiles = array();
+ $profiles = [];
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups);
CRM_Core_Permission::CREATE, NULL
);
- $validProfile = array();
+ $validProfile = [];
if (!empty($profileFields)) {
$fields = array_keys($profileFields);
foreach ($fields as $val) {
public static function copy($id) {
$maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_uf_group");
- $title = ts('[Copy id %1]', array(1 => $maxId + 1));
- $fieldsFix = array(
- 'suffix' => array(
+ $title = ts('[Copy id %1]', [1 => $maxId + 1]);
+ $fieldsFix = [
+ 'suffix' => [
'title' => ' ' . $title,
'name' => '__Copy_id_' . ($maxId + 1) . '_',
- ),
- );
+ ],
+ ];
$copy = CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFGroup',
- array('id' => $id),
+ ['id' => $id],
NULL,
$fieldsFix
);
$copy->save();
$copyUFJoin = CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin',
- array('uf_group_id' => $id),
- array('uf_group_id' => $copy->id),
+ ['uf_group_id' => $id],
+ ['uf_group_id' => $copy->id],
NULL,
'entity_table'
);
$copyUFField = CRM_Core_DAO::copyGeneric('CRM_Core_BAO_UFField',
- array('uf_group_id' => $id),
- array('uf_group_id' => $copy->id)
+ ['uf_group_id' => $id],
+ ['uf_group_id' => $copy->id]
);
$maxWeight = CRM_Utils_Weight::getMax('CRM_Core_DAO_UFJoin', NULL, 'weight');
WHERE uf_group_id = %2
AND ( entity_id IS NULL OR entity_id <= 0 )
";
- $p = array(
- 1 => array($maxWeight + 1, 'Integer'),
- 2 => array($copy->id, 'Integer'),
- );
+ $p = [
+ 1 => [$maxWeight + 1, 'Integer'],
+ 2 => [$copy->id, 'Integer'],
+ ];
CRM_Core_DAO::executeQuery($query, $p);
if ($copy->is_reserved) {
$query = "UPDATE civicrm_uf_group SET is_reserved = 0 WHERE id = %1";
- $params = array(1 => array($copy->id, 'Integer'));
+ $params = [1 => [$copy->id, 'Integer']];
CRM_Core_DAO::executeQuery($query, $params);
}
CRM_Utils_Hook::copy('UFGroup', $copy);
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
- CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
+ CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl]));
}
foreach ($emailList as $emailTo) {
// FIXME: take the below out of the foreach loop
CRM_Core_BAO_MessageTemplate::sendTemplate(
- array(
+ [
'groupName' => 'msg_tpl_workflow_uf',
'valueName' => 'uf_notify',
'contactId' => $contactID,
- 'tplParams' => array(
+ 'tplParams' => [
'displayName' => $displayName,
'currentDate' => date('r'),
'contactLink' => $contactLink,
- ),
+ ],
'from' => "$domainEmailName <$domainEmailAddress>",
'toEmail' => $emailTo,
- )
+ ]
);
}
}
public function checkFieldsEmptyValues($gid, $cid, $params, $skipCheck = FALSE) {
if ($gid) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $cid) || $skipCheck) {
- $values = array();
+ $values = [];
$fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::VIEW);
CRM_Core_BAO_UFGroup::getValues($cid, $fields, $values, FALSE, $params, TRUE);
if (!empty($values) &&
!empty($email)
) {
- $val = array(
+ $val = [
'id' => $gid,
'values' => $values,
'email' => $email,
- );
+ ];
return $val;
}
}
$primaryLocationType = $defaultLocationType->id;
}
- $data = array();
- $locationType = array();
+ $data = [];
+ $locationType = [];
$count = 1;
$primaryLocation = 0;
foreach ($params as $key => $value) {
$value = $date;
}
- $data['custom'][$customFieldID] = array(
+ $data['custom'][$customFieldID] = [
'id' => $id,
'value' => $value,
'extends' => $customFields[$customFieldID]['extends'],
'type' => $customFields[$customFieldID]['data_type'],
'custom_field_id' => $customFieldID,
- );
+ ];
}
}
elseif ($key == 'edit') {
* list of calculated group type
*/
public static function _calculateGroupType($ufFields, $includeTypeValues = FALSE, $ignoreFieldId = NULL) {
- $groupType = $groupTypeValues = $customFieldIds = array();
+ $groupType = $groupTypeValues = $customFieldIds = [];
if (!empty($ufFields)) {
foreach ($ufFields as $fieldName => $fieldValue) {
//ignore field from group type when provided.
*
* @return bool
*/
- public static function updateGroupTypes($gId, $groupTypes = array()) {
+ public static function updateGroupTypes($gId, $groupTypes = []) {
if (!is_array($groupTypes) || !$gId) {
return FALSE;
}
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $gId, 'group_type', 'null');
}
- $componentGroupTypes = array('Contribution', 'Participant', 'Membership', 'Activity', 'Case');
- $validGroupTypes = array_merge(array(
+ $componentGroupTypes = ['Contribution', 'Participant', 'Membership', 'Activity', 'Case'];
+ $validGroupTypes = array_merge([
'Contact',
'Individual',
'Organization',
'Household',
- ), $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes());
+ ], $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes());
- $gTypes = $gTypeValues = array();
+ $gTypes = $gTypeValues = [];
- $participantExtends = array('ParticipantRole', 'ParticipantEventName', 'ParticipantEventType');
+ $participantExtends = ['ParticipantRole', 'ParticipantEventName', 'ParticipantEventType'];
// Get valid group type and group subtypes
foreach ($groupTypes as $groupType => $value) {
if (in_array($groupType, $validGroupTypes) && !in_array($groupType, $gTypes)) {
*/
public static function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
if (!$componentId ||
- !in_array($component, array('Contribute', 'Membership', 'Event', 'Activity', 'Case'))
+ !in_array($component, ['Contribute', 'Membership', 'Event', 'Activity', 'Case'])
) {
return;
}
case 'Membership':
$componentBAO = 'CRM_Member_BAO_Membership';
$componentBAOName = 'Membership';
- $componentSubType = array('membership_type_id');
+ $componentSubType = ['membership_type_id'];
break;
case 'Contribute':
$componentBAO = 'CRM_Contribute_BAO_Contribution';
$componentBAOName = 'Contribution';
- $componentSubType = array('financial_type_id');
+ $componentSubType = ['financial_type_id'];
break;
case 'Event':
$componentBAO = 'CRM_Event_BAO_Participant';
$componentBAOName = 'Participant';
- $componentSubType = array('role_id', 'event_id', 'event_type_id');
+ $componentSubType = ['role_id', 'event_id', 'event_type_id'];
break;
case 'Activity':
$componentBAO = 'CRM_Activity_BAO_Activity';
$componentBAOName = 'Activity';
- $componentSubType = array('activity_type_id');
+ $componentSubType = ['activity_type_id'];
break;
case 'Case':
$componentBAO = 'CRM_Case_BAO_Case';
$componentBAOName = 'Case';
- $componentSubType = array('case_type_id');
+ $componentSubType = ['case_type_id'];
break;
}
- $values = array();
- $params = array('id' => $componentId);
+ $values = [];
+ $params = ['id' => $componentId];
//get the component values.
CRM_Core_DAO::commonRetrieve($componentBAO, $params, $values);
if ($componentBAOName == 'Participant') {
- $values += array('event_type_id' => CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values['event_id'], 'event_type_id'));
+ $values += ['event_type_id' => CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values['event_id'], 'event_type_id')];
}
- $formattedGroupTree = array();
+ $formattedGroupTree = [];
foreach ($fields as $name => $field) {
$fldName = $isStandalone ? $name : "field[$componentId][$name]";
$noteDetails = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant');
$defaults[$fldName] = array_pop($noteDetails);
}
- elseif (in_array($name, array(
+ elseif (in_array($name, [
'financial_type',
'payment_instrument',
'participant_status',
'participant_role',
- ))) {
+ ])) {
$defaults[$fldName] = $values["{$name}_id"];
}
elseif ($name == 'membership_type') {
elseif ($name == 'case_status') {
$defaults[$fldName] = $values['case_status_id'];
}
- elseif (CRM_Core_BAO_CustomField::getKeyID($name, TRUE) !== array(NULL, NULL)) {
+ elseif (CRM_Core_BAO_CustomField::getKeyID($name, TRUE) !== [NULL, NULL]) {
if (empty($formattedGroupTree)) {
//get the groupTree as per subTypes.
- $groupTree = array();
+ $groupTree = [];
foreach ($componentSubType as $subType) {
$subTree = CRM_Core_BAO_CustomGroup::getTree($componentBAOName, NULL,
$componentId, 0, $values[$subType]
* returns array
*/
public static function profileGroups($profileID) {
- $groupTypes = array();
+ $groupTypes = [];
$profileTypes = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'group_type');
if ($profileTypes) {
$groupTypeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $profileTypes);
*/
public static function getDoubleOptInGroupIds(&$params, $contactId = NULL) {
$config = CRM_Core_Config::singleton();
- $subscribeGroupIds = array();
+ $subscribeGroupIds = [];
// process further only if profileDoubleOptIn enabled and if groups exist
if (!array_key_exists('group', $params) ||
}
//do check for already subscriptions.
- $contactGroups = array();
+ $contactGroups = [];
if ($contactId) {
$query = "
SELECT group_id
WHERE status = 'Added'
AND contact_id = %1";
- $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($contactId, 'Integer')));
+ $dao = CRM_Core_DAO::executeQuery($query, [1 => [$contactId, 'Integer']]);
while ($dao->fetch()) {
$contactGroups[$dao->group_id] = $dao->group_id;
}
public static function checkForMixProfiles($profileIds) {
$mixProfile = FALSE;
- $contactTypes = array('Individual', 'Household', 'Organization');
+ $contactTypes = ['Individual', 'Household', 'Organization'];
$subTypes = CRM_Contact_BAO_ContactType::subTypes();
- $components = array('Contribution', 'Participant', 'Membership', 'Activity');
+ $components = ['Contribution', 'Participant', 'Membership', 'Activity'];
- $typeCount = array('ctype' => array(), 'subtype' => array());
+ $typeCount = ['ctype' => [], 'subtype' => []];
foreach ($profileIds as $gid) {
$profileType = CRM_Core_BAO_UFField::getProfileType($gid);
// ignore profile of type Contact
* group type values
*/
public static function groupTypeValues($profileId, $groupType = NULL) {
- $groupTypeValue = array();
+ $groupTypeValue = [];
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileId, 'group_type');
$groupTypeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $groupTypes);
if (empty($groupTypeParts[1])) {
return $groupTypeValue;
}
- $participantExtends = array('ParticipantRole', 'ParticipantEventName', 'ParticipantEventType');
+ $participantExtends = ['ParticipantRole', 'ParticipantEventName', 'ParticipantEventType'];
foreach (explode(',', $groupTypeParts[1]) as $groupTypeValues) {
- $values = array();
+ $values = [];
$valueParts = explode(':', $groupTypeValues);
if ($groupType &&
($valueParts[0] != "{$groupType}Type" ||
FROM civicrm_uf_group
WHERE name IN ('contribution_batch_entry', 'membership_batch_entry')";
$dao = CRM_Core_DAO::executeQuery($query);
- $profileIds = array();
+ $profileIds = [];
while ($dao->fetch()) {
$profileIds[$dao->id] = $dao->id;
}
}
/**
- * @todo what do I do?
* @param $source
* @param $destination
* @param bool $returnMultiSummaryFields
*
* @return array|null
+ * @todo what do I do?
*/
public static function shiftMultiRecordFields(&$source, &$destination, $returnMultiSummaryFields = FALSE) {
- $multiSummaryFields = $returnMultiSummaryFields ? array() : NULL;
+ $multiSummaryFields = $returnMultiSummaryFields ? [] : NULL;
foreach ($source as $field => $properties) {
if (!CRM_Core_BAO_CustomField::getKeyID($field)) {
continue;
}
}
+ /**
+ * Get the frontend_title for the profile, falling back on 'title' if none.
+ *
+ * @param int $profileID
+ *
+ * @return string
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ public static function getFrontEndTitle(int $profileID) {
+ $profile = civicrm_api3('UFGroup', 'getsingle', ['id' => $profileID, 'return' => ['title', 'frontend_title']]);
+ return $profile['frontend_title'] ?? $profile['title'];
+ }
+
}