diff --git a/application/Espo/SelectManagers/User.php b/application/Espo/SelectManagers/User.php index f77a653c0d..dfc170c17e 100644 --- a/application/Espo/SelectManagers/User.php +++ b/application/Espo/SelectManagers/User.php @@ -125,6 +125,16 @@ class User extends \Espo\Core\SelectManagers\Base protected function accessOnlyOwn(&$result) { + if ($this->getAcl()->get('portalPermission') == 'yes') { + $result['whereClause'][] = [ + 'OR' => [ + 'id' => $this->getUser()->id, + 'type' => 'portal', + ], + ]; + return; + } + $result['whereClause'][] = [ 'id' => $this->getUser()->id ]; @@ -141,11 +151,18 @@ class User extends \Espo\Core\SelectManagers\Base { $this->setDistinct(true, $result); $this->addLeftJoin(['teams', 'teamsAccess'], $result); + + $or = [ + 'teamsAccess.id' => $this->getUser()->getLinkMultipleIdList('teams'), + 'id' => $this->getUser()->id, + ]; + + if ($this->getAcl()->get('portalPermission') == 'yes') { + $or['type'] = 'portal'; + } + $result['whereClause'][] = [ - 'OR' => [ - 'teamsAccess.id' => $this->getUser()->getLinkMultipleIdList('teams'), - 'id' => $this->getUser()->id - ] + 'OR' => $or, ]; } }