From 72d22b2b3b28a0786a51deb6a35b6b73a1af295f Mon Sep 17 00:00:00 2001 From: mestrode <35630715+mestrode@users.noreply.github.com> Date: Sat, 20 Jan 2018 15:21:25 +0100 Subject: [PATCH] mark all item w/ equal links as read/unread --- fever/fever_api.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/fever/fever_api.php b/fever/fever_api.php index dc93bb6..5354004 100644 --- a/fever/fever_api.php +++ b/fever/fever_api.php @@ -706,6 +706,30 @@ class FeverAPI extends Handler { return $savedItemIdsCSV; } + function getEqualItems($id) + { + //get all ids which have identical links (Reference is found by id) + $sth = $this->pdo->prepare("SELECT id + FROM ttrss_entries,ttrss_user_entries + WHERE id=ref_id AND owner_uid = ? + AND link=(SELECT link FROM ttrss_entries WHERE id = ?)"); + $sth->execute(array_merge([clean($_SESSION["uid"]), $id])); + + $ids = ""; + while ($line = $sth->fetch()) + { + $ids .= $line["id"] . ","; + } + $ids = trim($ids, ","); + + if (self::DEBUG) { + // add request to debug log + error_log(print_r($ids, true)); + } + + return $ids; + } + function setItem($id, $field_raw, $mode) { /* classes/api.php updateArticle */ @@ -761,12 +785,15 @@ class FeverAPI extends Handler { function setItemAsRead($id) { - $this->setItem($id, 1, 0); + //action is true for all Equal Items + $ids = $this->getEqualItems($id); + $this->setItem($ids, 1, 0); } function setItemAsUnread($id) { - $this->setItem($id, 1, 1); + $ids = $this->getEqualItems($id); + $this->setItem($ids, 1, 1); } function setItemAsSaved($id)