}
$params = array_merge($defaults, $params);
+ if (!empty($params['deceased_date']) && $params['deceased_date'] !== 'null') {
+ $params['is_deceased'] = TRUE;
+ }
$allNull = $contact->copyValues($params);
$contact->id = $contactID;
if ($contact->contact_type === 'Individual') {
$allNull = FALSE;
- // @todo allow the lines below to be overridden by input or hooks & add tests,
- // as has been done for households and organizations.
- // Format individual fields.
+ // @todo get rid of this - most of this formatting should
+ // be done by time we get here - maybe start with some
+ // deprecation notices.
CRM_Contact_BAO_Individual::format($params, $contact);
}
$missingGreetingParams = [];
foreach ($allGreetingParams as $greetingIndex => $greetingParam) {
+ if (!empty($params[$greetingIndex . '_custom']) && empty($params[$greetingParam])) {
+ $params[$greetingParam] = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greetingParam, 'Customized');
+ }
// An empty string means NULL
if (($params[$greetingParam] ?? NULL) === '') {
$params[$greetingParam] = 'null';
'id' => $contact->id,
'is_deleted' => 1,
];
- CRM_Utils_Hook::pre('update', $contact->contact_type, $contact->id, $updateParams);
+ CRM_Utils_Hook::pre('edit', $contact->contact_type, $contact->id, $updateParams);
$params = [1 => [$contact->id, 'Integer']];
$query = 'DELETE FROM civicrm_uf_match WHERE contact_id = %1';
$contact->save();
CRM_Core_BAO_Log::register($contact->id, 'civicrm_contact', $contact->id);
- CRM_Utils_Hook::post('update', $contact->contact_type, $contact->id, $contact);
+ CRM_Utils_Hook::post('edit', $contact->contact_type, $contact->id, $contact);
return TRUE;
}
CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $reverse);
- CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'communication_style', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'), $reverse);
//lookup value of email/postal greeting, addressee, CRM-4575
'href' => CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=case'),
'permissions' => ['add cases'],
],
- 'grant' => [
- 'title' => ts('Add Grant'),
- 'weight' => 26,
- 'ref' => 'new-grant',
- 'key' => 'grant',
- 'tab' => 'grant',
- 'component' => 'CiviGrant',
- 'href' => CRM_Utils_System::url('civicrm/contact/view/grant',
- 'reset=1&action=add&context=grant'
- ),
- 'permissions' => ['edit grants'],
- ],
'rel' => [
'title' => ts('Add Relationship'),
'weight' => 30,
return CRM_Contact_BAO_Contact_Permission::allow($record['id'], $actionType, $userID);
}
+ /**
+ * Get icon for a particular contact.
+ *
+ * Example: `CRM_Contact_BAO_Contact::getIcon('Contact', 123)`
+ *
+ * @param string $entityName
+ * Always "Contact".
+ * @param int $entityId
+ * Id of the contact.
+ * @throws CRM_Core_Exception
+ */
+ public static function getEntityIcon(string $entityName, int $entityId) {
+ $contactTypes = CRM_Contact_BAO_ContactType::getAllContactTypes();
+ $subTypes = CRM_Utils_Array::explodePadded(CRM_Core_DAO::getFieldValue(parent::class, $entityId, 'contact_sub_type'));
+ foreach ((array) $subTypes as $subType) {
+ if (!empty($contactTypes[$subType]['icon'])) {
+ return $contactTypes[$subType]['icon'];
+ }
+ }
+ // If no sub-type icon, lookup contact type
+ $contactType = CRM_Core_DAO::getFieldValue(parent::class, $entityId, 'contact_type');
+ return $contactTypes[$contactType]['icon'] ?? self::$_icon;
+ }
+
}