if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
'is_enabled'
)) {
- // in order to make sure that every contact must be added to a group (CRM-4613) -
+ // Enabling multisite causes the contact to be added to the domain group
$domainGroupID = CRM_Core_BAO_Domain::getGroupId();
- if (CRM_Utils_Array::value('group', $params) && is_array($params['group'])) {
- $grpFlp = array_flip($params['group']);
- if (!array_key_exists(1, $grpFlp)) {
+ if(!empty($domainGroupID)){
+ if (CRM_Utils_Array::value('group', $params) && is_array($params['group'])) {
$params['group'][$domainGroupID] = 1;
}
- }
- else {
- $params['group'] = array($domainGroupID => 1);
+ else {
+ $params['group'] = array($domainGroupID => 1);
+ }
}
}
return FALSE;
}
+ // CRM-12929
+ // Restrict contact to be delete if contact has financial trxns
+ $error = NULL;
+ if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent(array($id), $error)) {
+ return FALSE;
+ }
+
// make sure this contact_id does not have any membership types
$membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
$id,
// delete all notes related to contact
CRM_Core_BAO_Note::cleanContactNotes($id);
+ // delete cases related to contact
+ $contactCases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($id);
+ if (!empty($contactCases)) {
+ foreach ($contactCases as $caseId) {
+ //check if case is associate with other contact or not.
+ $caseContactId = CRM_Case_BAO_Case::getCaseClients($caseId);
+ if (count($caseContactId) <= 1) {
+ CRM_Case_BAO_Case::deleteCase($caseId);
+ }
+ }
+ }
+
$contact->delete();
}
else {
* TODO: In context of chainselect, what to return if e.g. a country has no states?
*
* @param String $fieldName
- * @param String $context: e.g. "search" "edit" "create" "view"
+ * @param String $context: @see CRM_Core_DAO::buildOptionsContext
* @param Array $props: whatever is known about this dao object
*/
public static function buildOptions($fieldName, $context = NULL, $props = array()) {
}
break;
}
- return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params);
+ return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
/**