Group remembered wishlists by user

This commit is contained in:
grandeljay 2022-06-27 11:36:36 +02:00
parent 3b7a902f8e
commit c0e9d66df0

View file

@ -14,19 +14,31 @@ $page->bodyStart();
$page->navigation(); $page->navigation();
$wishlists = $_SESSION['user']->getSavedWishlists(); $wishlists = $_SESSION['user']->getSavedWishlists();
$wishlists_by_user = array();
foreach ($wishlists as $wishlist_saved) {
$wishlists_by_user[$wishlist_saved['user']][] = $wishlist_saved;
}
?> ?>
<main> <main>
<div class="ui container"> <div class="ui container">
<h1 class="ui header"><?= $page->title ?></h1> <h1 class="ui header"><?= $page->title ?></h1>
<?php if (!empty($wishlists)) { ?> <?php if (!empty($wishlists_by_user)) { ?>
<?php foreach ($wishlists_by_user as $wishlist_user => $wishlists_saved) { ?>
<?php
$wishlist_user = User::getFromID($wishlist_user);
?>
<h2 class="ui header"><?= $wishlist_user->getDisplayName() ?></h2>
<?php if (!empty($wishlists_saved)) { ?>
<div class="ui four column doubling stackable grid wishlists-saved"> <div class="ui four column doubling stackable grid wishlists-saved">
<?php foreach ($wishlists as $wishlist_saved) { ?> <?php foreach ($wishlists_saved as $wishlist_saved) { ?>
<?php <?php
$wishlist = new Wishlist($wishlist_saved['wishlist']); $wishlist = new Wishlist($wishlist_saved['wishlist']);
$wishlist_user = User::getFromID($wishlist_saved['user']);
$wishlist_href = Page::PAGE_WISHLIST . '&hash=' . $wishlist->hash; $wishlist_href = Page::PAGE_WISHLIST . '&hash=' . $wishlist->hash;
?> ?>
<div class="column"> <div class="column">
<a class="header" href="<?= $wishlist_href ?>"> <a class="header" href="<?= $wishlist_href ?>">
<div class="ui rounded bordered fluid image"> <div class="ui rounded bordered fluid image">
@ -41,6 +53,8 @@ $wishlists = $_SESSION['user']->getSavedWishlists();
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
<?php } ?>
<?php } ?>
<?php } else { ?> <?php } else { ?>
<?= Page::info(__('Ask somebody to share their wishlist with you and hit the remember button for it to show up here!'), __('No lists')); ?> <?= Page::info(__('Ask somebody to share their wishlist with you and hit the remember button for it to show up here!'), __('No lists')); ?>
<?php } ?> <?php } ?>