From b2ea073c161cc7aef8fa73d26b442d9d52d084f3 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 10 Sep 2018 10:24:09 +0300 Subject: [PATCH] fix notifications --- application/Espo/Entities/Note.php | 12 ++++++++++++ application/Espo/Hooks/Note/Notifications.php | 13 +++++++++++-- application/Espo/Services/Stream.php | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/application/Espo/Entities/Note.php b/application/Espo/Entities/Note.php index c3d98498c7..7533a37877 100644 --- a/application/Espo/Entities/Note.php +++ b/application/Espo/Entities/Note.php @@ -31,6 +31,18 @@ namespace Espo\Entities; class Note extends \Espo\Core\ORM\Entity { + private $aclIsProcessed = false; + + public function setAclIsProcessed() + { + $this->aclIsProcessed = true; + } + + public function isAclProcessed() + { + return $this->aclIsProcessed; + } + public function loadAttachments() { $data = $this->get('data'); diff --git a/application/Espo/Hooks/Note/Notifications.php b/application/Espo/Hooks/Note/Notifications.php index 245128281f..49ef60e71b 100644 --- a/application/Espo/Hooks/Note/Notifications.php +++ b/application/Espo/Hooks/Note/Notifications.php @@ -133,10 +133,19 @@ class Notifications extends \Espo\Core\Hooks\Base $targetType = $parentType; } - $teamIdList = $entity->getLinkMultipleIdList('teams'); - $userIdList = $entity->getLinkMultipleIdList('users'); + $skipAclCheck = false; + if (!$entity->isAclProcessed()) { + $skipAclCheck = true; + } else { + $teamIdList = $entity->getLinkMultipleIdList('teams'); + $userIdList = $entity->getLinkMultipleIdList('users'); + } foreach ($userList as $user) { + if ($skipAclCheck) { + $notifyUserIdList[] = $user->id; + continue; + } if ($user->isAdmin()) { $notifyUserIdList[] = $user->id; continue; diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index 59d47a7c0e..8962255e79 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -889,6 +889,10 @@ class Stream extends \Espo\Core\Services\Base protected function processNoteTeamsUsers(Entity $note, Entity $entity) { + $note->setAclIsProcessed(); + $note->set('teamsIds', []); + $note->set('usersIds', []); + if ($entity->hasLinkMultipleField('teams') && $entity->has('teamsIds')) { $teamIdList = $entity->get('teamsIds'); if (!empty($teamIdList)) {