diff --git a/application/Espo/Modules/Crm/Controllers/Activities.php b/application/Espo/Modules/Crm/Controllers/Activities.php index 8a9e46cad5..edf5b45fa0 100644 --- a/application/Espo/Modules/Crm/Controllers/Activities.php +++ b/application/Espo/Modules/Crm/Controllers/Activities.php @@ -74,20 +74,7 @@ class Activities extends \Espo\Core\Controllers\Base if ($userIdList) { $userIdList = explode(',', $userIdList); - - $resultList = []; - foreach ($userIdList as $userId) { - try { - $userResultList = $service->getEvents($userId, $from, $to, $scopeList); - } catch (\Exception $e) { - continue; - } - foreach ($userResultList as $item) { - $item['userId'] = $userId; - $resultList[] = $item; - } - } - return $resultList; + return $service->getEventsForUsers($userIdList, $from, $to, $scopeList); } else { if (!$userId) { $userId = $this->getUser()->id; diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index b1d60b472a..969eaecefa 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -1178,6 +1178,26 @@ class Activities extends \Espo\Core\Services\Base return $selectParams; } + public function getEventsForUsers($userIdList, $from, $to, $scopeList = null) + { + $resultList = []; + foreach ($userIdList as $userId) { + try { + $userResultList = $this->getEvents($userId, $from, $to, $scopeList); + } catch (\Exception $e) { + if ($e instanceof Forbidden) { + continue; + } + throw new \Exception($e->getMessage(), $e->getCode(), $e); + } + foreach ($userResultList as $item) { + $item['userId'] = $userId; + $resultList[] = $item; + } + } + return $resultList; + } + public function getEventsForTeams($teamIdList, $from, $to, $scopeList = null) { if ($this->getAcl()->get('userPermission') === 'no') {