Commit 62da1711 authored by bgm's avatar bgm Committed by Aegir user
Browse files

Fix detection of activity fields. Core's checkContactActivityProfileType does...

Fix detection of activity fields. Core's checkContactActivityProfileType does not work if we have only one field type
parent 6d95a1d9
......@@ -14,7 +14,7 @@ class CRM_Activityprofile_APIWrappers_Profile {
}
$profile_id = _civicrm_api3_profile_getProfileID($params['profile_id']);
$isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($profile_id);
$isContactActivityProfile = $this->isActivityProfile($profile_id);
// If it is not for a Contact or Activity, check if it's for a new Case
if (!$isContactActivityProfile) {
......@@ -294,4 +294,30 @@ class CRM_Activityprofile_APIWrappers_Profile {
return $result;
}
/**
*
*/
public function isActivityProfile($profile_id) {
$profile_type = civicrm_api3('UFGroup', 'getsingle', [
'id' => $profile_id,
'return' => 'group_type',
])['group_type'];
if (empty($profile_type)) {
return FALSE;
}
foreach ($profile_type as $type) {
$parts = explode(',', $type);
foreach ($parts as $p) {
if ($p == 'Activity' || $p == 'Case') {
return TRUE;
}
}
}
return FALSE;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment