summaryrefslogtreecommitdiffstats
path: root/lib/Db
diff options
context:
space:
mode:
authorWENDLING NICOLAS <nicolas.wendling2@etu.unistra.fr>2021-01-26 15:30:40 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit393636234376b61610ff227943db3c652093a34a (patch)
treea29097ef535ba37d2e9dbc16709f42a32a976dbd /lib/Db
parent6ebe676911584bf86d246c4656d42a176f08f242 (diff)
✨ Get all shared items with an user
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/ItemMapper.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Db/ItemMapper.php b/lib/Db/ItemMapper.php
index 090461c17..6c804c6ac 100644
--- a/lib/Db/ItemMapper.php
+++ b/lib/Db/ItemMapper.php
@@ -518,6 +518,30 @@ class ItemMapper extends NewsMapper
return [];
}
+ /**
+ * Returns all items shared with $userId
+ */
+ public function findAllShared($limit, $offset, $showAll, $oldestFirst, $userId, $search)
+ {
+ $sql = 'SELECT `*` FROM `*PREFIX*news_items`' .
+ 'WHERE `shared_with` = ? ';
+ $sql .= $this->buildStatusQueryPart($showAll);
+
+ if ($offset !== 0) {
+ $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $params[] = $offset;
+ }
+
+ if ($oldestFirst) {
+ $sql .= ' ORDER BY `items`.`id` ASC';
+ } else {
+ $sql .= ' ORDER BY `items`.`id` DESC';
+ }
+
+ $params = [$userId];
+
+ return $this->findEntitiesIgnoringNegativeLimit($sql, $params, $limit);
+ }
public function shareItem($itemId, $shareWithId, $userId)
{