summaryrefslogtreecommitdiffstats
path: root/lib/Db/ItemMapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Db/ItemMapper.php')
-rw-r--r--lib/Db/ItemMapper.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Db/ItemMapper.php b/lib/Db/ItemMapper.php
index 765c67698..d5ffc41a5 100644
--- a/lib/Db/ItemMapper.php
+++ b/lib/Db/ItemMapper.php
@@ -582,4 +582,23 @@ class ItemMapper extends NewsMapper
// persist new item
$this->insert($newItem);
}
+
+ /**
+ * Check if the article is already shared between the users
+ */
+ public function checkSharing($itemId, $shareWithId, $userId)
+ {
+ $item = $this->find($userId, $itemId);
+
+ $sql = 'SELECT COUNT(*) AS size FROM `*PREFIX*news_items` `items` ' .
+ 'WHERE `items`.`shared_by` = ? '.
+ 'AND `items`.`shared_with` = ?'.
+ 'AND `items`.`guid_hash` = ?';
+
+ $params = [$userId ,$shareWithId, $item->getGuidHash()];
+
+ $result = $this->execute($sql, $params)->fetch();
+
+ return (int)$result['size'];
+ }
}