diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/ItemController.php | 7 | ||||
-rw-r--r-- | lib/Db/ItemMapperV2.php | 30 | ||||
-rw-r--r-- | lib/Service/ItemServiceV2.php | 13 |
3 files changed, 50 insertions, 0 deletions
diff --git a/lib/Controller/ItemController.php b/lib/Controller/ItemController.php index ab875b31c..577916e9d 100644 --- a/lib/Controller/ItemController.php +++ b/lib/Controller/ItemController.php @@ -229,6 +229,13 @@ class ItemController extends Controller !$showAll ); break; + case ListType::SHARED: + $items = $this->itemService->findAllSharedAfter( + $this->getUserId(), + $lastModified, + !$showAll + ); + break; default: $items = $this->itemService->findAllAfter( $this->getUserId(), diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php index 0e90fca40..5399272ce 100644 --- a/lib/Db/ItemMapperV2.php +++ b/lib/Db/ItemMapperV2.php @@ -392,6 +392,36 @@ class ItemMapperV2 extends NewsMapperV2 } /** + * @param string $userId + * @param int|null $folderId + * @param int $updatedSince + * @param bool $hideRead + * + * @return Item[] + */ + public function findAllSharedAfter( + string $userId, + int $updatedSince, + bool $hideRead + ): array { + $builder = $this->db->getQueryBuilder(); + + $builder->select('items.*') + ->from($this->tableName, 'items') + ->andWhere('items.last_modified >= :updatedSince') + ->andWhere('items.shared_with = :sharedWith') + ->setParameters(['updatedSince' => $updatedSince, 'sharedWith' => $userId]) + ->orderBy('items.last_modified', 'DESC') + ->addOrderBy('items.id', 'DESC'); + + if ($hideRead === true) { + $builder->andWhere('items.unread = 1'); + } + + return $this->findEntities($builder); + } + + /** * @param string $userId * @param int $updatedSince * @param int $feedType diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php index 10463b13a..1f5acc070 100644 --- a/lib/Service/ItemServiceV2.php +++ b/lib/Service/ItemServiceV2.php @@ -296,6 +296,19 @@ class ItemServiceV2 extends Service } /** + * Returns all new shared items + * @param string $userId the name of the user + * @param int $updatedSince a timestamp with the minimal modification date + * @param boolean $hideRead if unread items should also be returned + * + * @return array of items + */ + public function findAllSharedAfter(string $userId, int $updatedSince, bool $hideRead): array + { + return $this->mapper->findAllSharedAfter($userId, $updatedSince, $hideRead); + } + + /** * Returns all new items of a type * * @param string $userId the name of the user |