$condition = NULL;
$casesList = array();
- //validate access for own cases.
+ // validate access for own cases.
if (!self::accessCiviCase()) {
return $getCount ? 0 : $casesList;
}
+ // Return cached value instead of re-running query
+ if (isset(Civi::$statics[__CLASS__]['totalCount']) && $getCount) {
+ return Civi::$statics[__CLASS__]['totalCount'];
+ }
+
$type = CRM_Utils_Array::value('type', $params, 'upcoming');
$userID = CRM_Core_Session::singleton()->get('userID');
$caseActivityIDColumn = 'case_recent_activity_id';
}
- //validate access for all cases.
+ // validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
$allCases = FALSE;
}
}
$condition = implode(' AND ', $whereClauses);
- $totalCount = CRM_Core_DAO::singleValueQuery(self::getCaseActivityCountQuery($type, $userID, $condition));
+ Civi::$statics[__CLASS__]['totalCount'] = $totalCount = CRM_Core_DAO::singleValueQuery(self::getCaseActivityCountQuery($type, $userID, $condition));
if ($getCount) {
return $totalCount;
}