From 237363e087c629f8902828575908d3c54e5aa348 Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Thu, 18 Feb 2021 23:18:04 +0100 Subject: =?UTF-8?q?=F0=9F=92=A1=20Added=20comments=20to=20ItemMapper=20sha?= =?UTF-8?q?re=20fncts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- lib/Db/ItemMapper.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/Db') diff --git a/lib/Db/ItemMapper.php b/lib/Db/ItemMapper.php index 01365d866..036ebf1be 100644 --- a/lib/Db/ItemMapper.php +++ b/lib/Db/ItemMapper.php @@ -36,6 +36,12 @@ class ItemMapper extends NewsMapper parent::__construct($db, $time, Item::class); } + /** + * Constructs the SQL query + * + * A user can access an item if it's in his feeds and is not shared + * XOR it's not in his feeds but is shared with him + */ private function makeSelectQuery( $prependTo = '', $oldestFirst = false, @@ -572,6 +578,16 @@ class ItemMapper extends NewsMapper return (int)$result['size']; } + /** + * @param int $itemId id of the item to share + * @param string $shareWithId user the item is being shared with + * @param string $userId user who's sharing the article, article owner + * + * Sharing by copying - the item is duplicated, and the 'sharedBy' and + * 'sharedWith' fields are filled accordingly. + * We copy the 'feedId', because the article will still be owned by + * $userId, and it'll be stored in his feed + */ public function shareItem($itemId, $shareWithId, $userId) { // find existing item and copy it -- cgit v1.2.3