diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index 3eefe91c19..e61e8da16b 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -406,7 +406,8 @@ class Stream extends \Espo\Core\Services\Base ], ]; - if ($this->getUserAclManager($user)->check($user, 'Email', 'read')) { + $aclManager = $this->getUserAclManager($user); + if ($aclManager && $aclManager->check($user, 'Email', 'read')) { $selectParamsSubscription['leftJoins'][] = [ 'noteUser', 'noteUser', [ 'noteUser.noteId=:' => 'id', @@ -1682,6 +1683,12 @@ class Stream extends \Espo\Core\Services\Base if ($user->isPortal() && !$this->getUser()->isPortal()) { $aclManager = new \Espo\Core\Portal\AclManager($this->getInjection('container')); + $portals = $user->get('portals'); + if (count($portals)) { + $aclManager->setPortal($portals[0]); + } else { + $aclManager = null; + } } return $aclManager; @@ -1715,15 +1722,6 @@ class Stream extends \Espo\Core\Services\Base $aclManager = $this->getUserAclManager($user); - if ($user->isPortal() && !$this->getUser()->isPortal()) { - $portals = $user->get('portals'); - if (count($portals)) { - $aclManager->setPortal($portals[0]); - } else { - $aclManager = null; - } - } - foreach ($scopes as $scope => $item) { if (empty($item['entity'])) continue; if (empty($item['object'])) continue;