* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
- protected static function createContact($contactID, $params) {
+ protected static function updateContact(int $contactID, $params): void {
// 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,
- int $contactID,
- $ufGroupId = NULL,
- $ctype = NULL
+ $params,
+ int $contactID
) {
$data = $contactDetails = [];
// get the contact details (hier)
- $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;
}
}
- if ($ctype == 'Organization') {
- $data['organization_name'] = $contactDetails['organization_name'] ?? NULL;
- }
- elseif ($ctype == 'Household') {
- $data['household_name'] = $contactDetails['household_name'] ?? NULL;
- }
-
$locationType = [];
$count = 1;
$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;
- }
- }
- }
- }
-
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.
*
if (!isset($submitted['suffix_id']) && !empty($migrationInfo['main_details']['suffix_id'])) {
$submitted['suffix_id'] = $migrationInfo['main_details']['suffix_id'];
}
- self::createContact($mainId, $submitted);
+ self::updateContact($mainId, $submitted);
}
$transaction->commit();
CRM_Utils_Hook::post('merge', 'Contact', $mainId);
/**
* 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
*