diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-04-06 23:43:27 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-04-06 23:43:43 +0200 |
commit | 65d28653ae1a1d2a7680ccfa694dbb7e2d4d750f (patch) | |
tree | 0e005dc5c41e7ba4c2dec602cea4d6e8aa2a4e65 /db/itemmapper.php | |
parent | 4f8b81c7a353b5704d3a1d7d438077ac06dfdb4d (diff) |
try marking same items as read if they contain the same content
Diffstat (limited to 'db/itemmapper.php')
-rw-r--r-- | db/itemmapper.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php index 895b0f7ae..a2ad70a67 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -379,5 +379,29 @@ class ItemMapper extends NewsMapper { } } + public function readItem($itemId, $isRead, $lastModified, $userId) { + $item = $this->find($itemId, $userId); + + // reading an item should set all of the same items as read, whereas + // marking an item as unread should only mark the selected instance + // as unread + if ($isRead) { + $sql = 'UPDATE `*PREFIX*news_items` + SET `status` = `status` & ? + AND `last_modified` = ? + WHERE `fingerprint` = ? + AND feed_id IN ( + SELECT `f`.`id` FROM `*PREFIX*news_feeds` `f` + WHERE `f`.`user_id` = ? + )'; + $params = [~StatusFlag::UNREAD, $lastModified, + $item->getFingerprint(), $userId]; + $this->execute($sql, $params); + } else { + $item->setLastModified($lastModified); + $item->setUnread(); + $this->update($item); + } + } } |