return CRM_Case_BAO_Case::caseCount($contactId);
case 'activity':
- return \Civi\Api4\Activity::get(TRUE)
+ $excludeCaseActivities = (CRM_Core_Component::isEnabled('CiviCase') && !\Civi::settings()->get('civicaseShowCaseActivities'));
+ $activityApi = \Civi\Api4\Activity::get(TRUE)
->selectRowCount()
->addJoin('ActivityContact AS activity_contact', 'INNER')
->addWhere('activity_contact.contact_id', '=', $contactId)
->addWhere('is_test', '=', FALSE)
- ->addGroupBy('id')
- ->execute()
- ->count();
+ ->addGroupBy('id');
+ if ($excludeCaseActivities) {
+ $activityApi->addWhere('case_id', 'IS EMPTY');
+ }
+ return $activityApi->execute()->count();
case 'mailing':
$params = ['contact_id' => $contactId];