summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Db/ItemMapper.php16
-rw-r--r--lib/Service/ItemService.php11
2 files changed, 27 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)
{
diff --git a/lib/Service/ItemService.php b/lib/Service/ItemService.php
index f1f3c968b..946c1ad30 100644
--- a/lib/Service/ItemService.php
+++ b/lib/Service/ItemService.php
@@ -361,4 +361,15 @@ class ItemService extends Service
throw new ServiceNotFoundException($ex->getMessage());
}
}
+
+ /**
+ * Returns the shared count
+ *
+ * @param string $userId the name of the user
+ * @return int the count
+ */
+ public function starredShared($userId)
+ {
+ return $this->itemMapper->sharedCount($userId);
+ }
}