diff options
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/ItemMapper.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Db/ItemMapper.php b/lib/Db/ItemMapper.php index 9420395c3..92993bdba 100644 --- a/lib/Db/ItemMapper.php +++ b/lib/Db/ItemMapper.php @@ -542,6 +542,22 @@ class ItemMapper extends NewsMapper return $this->findEntitiesIgnoringNegativeLimit($sql, $params, $limit); } + + /** + * Returns the count of unread shared items for user $userId + */ + public function sharedCount(string $userId) + { + $sql = 'SELECT COUNT(*) AS size FROM `*PREFIX*news_items` `items` ' . + 'WHERE `items`.`shared_with` = ? ' . + 'AND `items`.`unread` = `1`'; + + $params = [$userId]; + + $result = $this->execute($sql, $params)->fetch(); + + return (int)$result['size']; + } public function shareItem($itemId, $shareWithId, $userId) { |