diff --git a/lib/Db/ContextMapper.php b/lib/Db/ContextMapper.php index 15959e767..d6cbe8fb9 100644 --- a/lib/Db/ContextMapper.php +++ b/lib/Db/ContextMapper.php @@ -165,17 +165,27 @@ public function findAll(?string $userId = null): array { return $resultEntities; } - public function findForNavBar(string $userId): array { $qb = $this->getFindContextBaseQuery($userId); - $qb->andWhere($qb->expr()->andX( + $qb->andWhere($qb->expr()->orX( // default - $qb->expr()->gt('n.display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_HIDDEN, IQueryBuilder::PARAM_INT)), - // user override - $qb->expr()->orX( - $qb->expr()->gt('n2.display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_HIDDEN, IQueryBuilder::PARAM_INT)), + $qb->expr()->andX( + // requires lack of user overwrite, indicated by n2.display_mode $qb->expr()->isNull('n2.display_mode'), - ) + // requires a display mode also depending on the roleā€¦ + $qb->expr()->orX( + // not an owner: requires RECIPIENT or ALL + $qb->expr()->andX( + // groups are not considered, yet + $qb->expr()->neq('c.owner_id', $qb->createNamedParameter($userId)), + $qb->expr()->gt('n.display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_HIDDEN, IQueryBuilder::PARAM_INT)), + ), + // an owner (no explicit check necessary): requires ALL + $qb->expr()->eq('n.display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_ALL, IQueryBuilder::PARAM_INT)), + ), + ), + // user override + $qb->expr()->gt('n2.display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_HIDDEN, IQueryBuilder::PARAM_INT)), )); $result = $qb->executeQuery(); diff --git a/lib/Listener/BeforeTemplateRenderedListener.php b/lib/Listener/BeforeTemplateRenderedListener.php index 4371aa5f4..284a40d44 100644 --- a/lib/Listener/BeforeTemplateRenderedListener.php +++ b/lib/Listener/BeforeTemplateRenderedListener.php @@ -38,30 +38,6 @@ public function handle(Event $event): void { $contexts = $this->contextService->findForNavigation($user->getUID()); foreach ($contexts as $context) { - if ($context->getOwnerType() === Application::OWNER_TYPE_USER - && $context->getOwnerId() === $user->getUID()) { - - // filter out entries for owners unless it is set to be visible - $skipEntry = true; - foreach ($context->getSharing() as $shareInfo) { - // TODO: integrate into DB query in Mapper - if (isset($shareInfo['display_mode']) && $shareInfo['display_mode'] === Application::NAV_ENTRY_MODE_ALL) { - // a custom override makes it visible - $skipEntry = false; - break; - } - - if (!isset($shareInfo['display_mode']) && $shareInfo['display_mode_default'] === Application::NAV_ENTRY_MODE_ALL) { - // no custom override, and visible also for owner by default - $skipEntry = false; - break; - } - } - if ($skipEntry) { - continue; - } - } - $this->navigationManager->add(function () use ($context) { $iconRelPath = 'material/' . $context->getIcon() . '.svg'; if (file_exists(__DIR__ . '/../../img/' . $iconRelPath)) {