diff options
author | Aurélien <dav.aurelien@gmail.com> | 2021-01-28 13:54:08 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 22:31:21 +0200 |
commit | 5f69c256e30bdebf40264166e6dd29f12904e14e (patch) | |
tree | 51fa6e29273c83835ab77ace63ba42167e22b5ba /lib/Db | |
parent | f3c4d744c011df8d18c49495f5111a17197b7038 (diff) |
Add function for avoid duplicate item (share)
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/ItemMapper.php | 19 |
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']; + } } |