'rel_table_custom_groups' => [
'title' => ts('Custom Groups'),
'tables' => ['civicrm_custom_group'],
- 'url' => CRM_Utils_System::url('civicrm/admin/custom/group', 'reset=1'),
+ 'url' => CRM_Utils_System::url('civicrm/admin/custom/group'),
],
'rel_table_uf_groups' => [
'title' => ts('Profiles'),
foreach ($sqls as $sql) {
CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, TRUE);
}
- CRM_Dedupe_Merger::addMembershipToRealtedContacts($mainId);
+ CRM_Dedupe_Merger::addMembershipToRelatedContacts($mainId);
}
/**
// This parameter causes blank fields to be be emptied out.
// We can probably remove.
$params['updateBlankLocInfo'] = TRUE;
- $data = self::formatProfileContactParams($params, [], $contactID);
+ $data = self::formatProfileContactParams($params, $contactID);
CRM_Contact_BAO_Contact::create($data);
}
* eliminate a toxic function.
*
* @param array $params
- * @param $fields
* @param int $contactID
- * @param int $ufGroupId
- * @param null $ctype
*
* @return array
*/
private static function formatProfileContactParams(
- &$params,
- $fields,
- $contactID = NULL,
- $ufGroupId = NULL,
- $ctype = NULL
+ $params,
+ int $contactID
) {
$data = $contactDetails = [];
// get the contact details (hier)
- if ($contactID) {
- $details = CRM_Contact_BAO_Contact::getHierContactDetails($contactID, $fields);
+ $details = CRM_Contact_BAO_Contact::getHierContactDetails($contactID, []);
- $contactDetails = $details[$contactID];
- $data['contact_type'] = $contactDetails['contact_type'] ?? NULL;
- $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL;
- }
- else {
- //we should get contact type only if contact
- if ($ufGroupId) {
- $data['contact_type'] = CRM_Core_BAO_UFField::getProfileType($ufGroupId, TRUE, FALSE, TRUE);
-
- //special case to handle profile with only contact fields
- if ($data['contact_type'] == 'Contact') {
- $data['contact_type'] = 'Individual';
- }
- elseif (CRM_Contact_BAO_ContactType::isaSubType($data['contact_type'])) {
- $data['contact_type'] = CRM_Contact_BAO_ContactType::getBasicType($data['contact_type']);
- }
- }
- elseif ($ctype) {
- $data['contact_type'] = $ctype;
- }
- else {
- $data['contact_type'] = 'Individual';
- }
- }
+ $contactDetails = $details[$contactID];
+ $data['contact_type'] = $contactDetails['contact_type'] ?? NULL;
+ $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL;
//fix contact sub type CRM-5125
if (array_key_exists('contact_sub_type', $params) &&
}
}
- if ($ctype == 'Organization') {
- $data['organization_name'] = $contactDetails['organization_name'] ?? NULL;
- }
- elseif ($ctype == 'Household') {
- $data['household_name'] = $contactDetails['household_name'] ?? NULL;
- }
-
$locationType = [];
$count = 1;
- if ($contactID) {
- //add contact id
- $data['contact_id'] = $contactID;
- $primaryLocationType = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactID);
- }
- else {
- $defaultLocation = CRM_Core_BAO_LocationType::getDefault();
- $defaultLocationId = $defaultLocation->id;
- }
+ //add contact id
+ $data['contact_id'] = $contactID;
+ $primaryLocationType = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactID);
$billingLocationTypeId = CRM_Core_BAO_LocationType::getBilling();
[$fieldName, $locTypeId, $typeId] = CRM_Utils_System::explode('-', $key, 3);
if ($locTypeId == 'Primary') {
- if ($contactID) {
- if (in_array($fieldName, $blocks)) {
- $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactID, FALSE, $fieldName);
- }
- else {
- $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactID, FALSE, 'address');
- }
- $primaryLocationType = $locTypeId;
+ if (in_array($fieldName, $blocks)) {
+ $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactID, FALSE, $fieldName);
}
else {
- $locTypeId = $defaultLocationId;
+ $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactID, FALSE, 'address');
}
+ $primaryLocationType = $locTypeId;
}
if (is_numeric($locTypeId) &&
$data['contact_type'] = 'Individual';
}
- //set the values for checkboxes (do_not_email, do_not_mail, do_not_trade, do_not_phone)
- $privacy = CRM_Core_SelectValues::privacy();
- foreach ($privacy as $key => $value) {
- if (array_key_exists($key, $fields)) {
- // do not reset values for existing contacts, if fields are added to a profile
- if (array_key_exists($key, $params)) {
- $data[$key] = $params[$key];
- if (empty($params[$key])) {
- $data[$key] = 0;
- }
- }
- elseif (!$contactID) {
- $data[$key] = 0;
- }
- }
- }
-
return $data;
}
*
* @param bool $checkPermissions
* Respect logged in user permissions.
- * @param bool|NULL $reloadCacheIfEmpty
+ * @param bool|null $reloadCacheIfEmpty
* If not set explicitly this is calculated but it is preferred that it be set
* per comments on isSelected above.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public static function addMembershipToRealtedContacts($contactID) {
+ public static function addMembershipToRelatedContacts($contactID) {
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contactID;
$dao->is_test = 0;
/**
* Build up the location block for the contact in dedupe-screen display format.
*
- * @param integer $cid
+ * @param int $cid
* @param array $blockInfo
* @param string $blockName
*