@@ -107,6 +107,21 @@ class BoardService {
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function getUserBoards(int $since = -1): array {
|
||||
$userInfo = $this->getBoardPrerequisites();
|
||||
$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null, $since);
|
||||
$groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups'],null, null, $since);
|
||||
$circleBoards = $this->boardMapper->findAllByCircles($userInfo['user'], null, null, $since);
|
||||
$mergedBoards = array_merge($userBoards, $groupBoards, $circleBoards);
|
||||
$result = [];
|
||||
/** @var Board $item */
|
||||
foreach ($mergedBoards as &$item) {
|
||||
if (!array_key_exists($item->getId(), $result)) {
|
||||
$result[$item->getId()] = $item;
|
||||
}
|
||||
}
|
||||
return array_values($result);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -114,37 +129,30 @@ class BoardService {
|
||||
if ($this->boardsCache) {
|
||||
return $this->boardsCache;
|
||||
}
|
||||
$userInfo = $this->getBoardPrerequisites();
|
||||
$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null, $since);
|
||||
$groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups'],null, null, $since);
|
||||
$circleBoards = $this->boardMapper->findAllByCircles($userInfo['user'], null, null, $since);
|
||||
$complete = array_merge($userBoards, $groupBoards, $circleBoards);
|
||||
$result = [];
|
||||
$complete = $this->getUserBoards($since);
|
||||
/** @var Board $item */
|
||||
foreach ($complete as &$item) {
|
||||
if (!array_key_exists($item->getId(), $result)) {
|
||||
$this->boardMapper->mapOwner($item);
|
||||
if ($item->getAcl() !== null) {
|
||||
foreach ($item->getAcl() as &$acl) {
|
||||
$this->boardMapper->mapAcl($acl);
|
||||
}
|
||||
$this->boardMapper->mapOwner($item);
|
||||
if ($item->getAcl() !== null) {
|
||||
foreach ($item->getAcl() as &$acl) {
|
||||
$this->boardMapper->mapAcl($acl);
|
||||
}
|
||||
if ($details !== null) {
|
||||
$this->enrichWithStacks($item);
|
||||
$this->enrichWithLabels($item);
|
||||
$this->enrichWithUsers($item);
|
||||
}
|
||||
$permissions = $this->permissionService->matchPermissions($item);
|
||||
$item->setPermissions([
|
||||
'PERMISSION_READ' => $permissions[Acl::PERMISSION_READ] ?? false,
|
||||
'PERMISSION_EDIT' => $permissions[Acl::PERMISSION_EDIT] ?? false,
|
||||
'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE] ?? false,
|
||||
'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE] ?? false
|
||||
]);
|
||||
$result[$item->getId()] = $item;
|
||||
}
|
||||
if ($details !== null) {
|
||||
$this->enrichWithStacks($item);
|
||||
$this->enrichWithLabels($item);
|
||||
$this->enrichWithUsers($item);
|
||||
}
|
||||
$permissions = $this->permissionService->matchPermissions($item);
|
||||
$item->setPermissions([
|
||||
'PERMISSION_READ' => $permissions[Acl::PERMISSION_READ] ?? false,
|
||||
'PERMISSION_EDIT' => $permissions[Acl::PERMISSION_EDIT] ?? false,
|
||||
'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE] ?? false,
|
||||
'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE] ?? false
|
||||
]);
|
||||
$result[$item->getId()] = $item;
|
||||
}
|
||||
$this->boardsCache = $result;
|
||||
$this->boardsCache = $complete;
|
||||
return array_values($result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user