Fix undefined array key

This commit is contained in:
grandeljay 2023-01-28 17:15:45 +01:00
parent c31a07d855
commit 73ad4012df
2 changed files with 36 additions and 35 deletions

View file

@ -44,6 +44,16 @@ $(function () {
/** Show modal */
wish_details
.modal({
'onShow' : function() {
var user_is_current = wishlist && wishlist.user === parseInt($('[name="user-id"]').val());
if (user_is_current) {
$('.ui.button.wish-fulfil').remove();
} else {
$('.ui.button.wish-fulfilled').remove();
$('.ui.dropdown.wish-options').remove();
}
},
'onVisible' : function() {
/**
* Dirty hack to change the default `display: block;` to

View file

@ -7,6 +7,11 @@
namespace wishthis;
?>
<?php if ($_SESSION['user']->isLoggedIn()) { ?>
<input type="hidden" name="user-id" value="<?= $_SESSION['user']->id ?>" />
<?php } ?>
<div class="wishlist-filter-wrapper">
<div class="ui stackable grid">
<div class="column">
@ -248,51 +253,37 @@ namespace wishthis;
</div>
<div class="actions">
<?php
/** Determine if current user is wishlist owner */
$url = new URL($_SERVER['REQUEST_URI']);
$wishlist_id = $_GET['id'] ?? $_GET['hash'];
$wishlist = new Wishlist($wishlist_id);
<button class="ui disabled primary labeled icon button wish-fulfilled">
<i class="check icon"></i>
<span><?= __('Mark as fulfilled') ?></span>
</button>
$userIsCurrent = $_SESSION['user']->isLoggedIn()
&& $_SESSION['user']->id === $wishlist->user;
?>
<?php if ($userIsCurrent) { ?>
<button class="ui disabled primary labeled icon button wish-fulfilled">
<i class="check icon"></i>
<span><?= __('Mark as fulfilled') ?></span>
</button>
<?php } else { ?>
<button class="ui disabled primary labeled icon button wish-fulfil">
<i class="gift icon"></i>
<span><?= __('Fulfil wish') ?></span>
</button>
<?php } ?>
<button class="ui disabled primary labeled icon button wish-fulfil">
<i class="gift icon"></i>
<span><?= __('Fulfil wish') ?></span>
</button>
<a class="ui disabled labeled icon button wish-visit" target="_blank">
<i class="external icon"></i>
<span><?= __('Visit') ?></span>
</a>
<?php if ($userIsCurrent) { ?>
<div class="ui disabled labeled icon top left pointing dropdown button wish-options">
<i class="cog icon"></i>
<span class="text"><?= __('Options') ?></span>
<div class="ui disabled labeled icon top left pointing dropdown button wish-options">
<i class="cog icon"></i>
<span class="text"><?= __('Options') ?></span>
<div class="menu">
<button class="item disabled wish-edit">
<i class="pen icon"></i>
<span><?= __('Edit') ?></span>
</button>
<div class="menu">
<button class="item disabled wish-edit">
<i class="pen icon"></i>
<span><?= __('Edit') ?></span>
</button>
<button class="item disabled wish-delete">
<i class="trash icon"></i>
<span><?= __('Delete') ?></span>
</button>
</div>
<button class="item disabled wish-delete">
<i class="trash icon"></i>
<span><?= __('Delete') ?></span>
</button>
</div>
<?php } ?>
</div>
<button class="ui cancel labeled icon button wish-close">
<i class="close icon"></i>