From dd0aae59389abf8d46e1d1f7fd4ee2e94735de0a Mon Sep 17 00:00:00 2001 From: grandeljay Date: Mon, 5 Dec 2022 10:26:12 +0100 Subject: [PATCH] Fix fulfilled wishes disappearing for wishlist owner #58 --- src/classes/wishlist.php | 18 +++++++++++++++++- src/pages/changelog.php | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/classes/wishlist.php b/src/classes/wishlist.php index d2bd70ca..437d299b 100644 --- a/src/classes/wishlist.php +++ b/src/classes/wishlist.php @@ -64,7 +64,23 @@ class Wishlist $WHERE = isset($sql['WHERE']) ? $sql['WHERE'] : '`wishlist` = ' . $this->id; $ORDER_BY = isset($sql['ORDER_BY']) ? $sql['ORDER_BY'] : '`priority` DESC, `url` ASC, `title` ASC'; - $WHERE .= ' AND (`status` IS NULL)'; + /** Determine if user owns the requested wish list */ + $wish_status = ' AND (`status` IS NULL)'; + + if ($_SESSION['user']->isLoggedIn()) { + $wishlist_ids = array_map( + function ($wishlist_data) { + return intval($wishlist_data['id']); + }, + $_SESSION['user']->getWishlists() + ); + + if (in_array($this->id, $wishlist_ids, true)) { + $wish_status = ''; + } + } + + $WHERE .= $wish_status; $this->wishes = $database ->query( diff --git a/src/pages/changelog.php b/src/pages/changelog.php index af2d875a..3598d66c 100644 --- a/src/pages/changelog.php +++ b/src/pages/changelog.php @@ -24,6 +24,7 @@ $page->navigation(); +
+
+
+

+
+
+

+
    +
  • + + #58 +
  • +
+
+
+
+