fix: #179 shared wishlist not accessible
This commit is contained in:
parent
87de601872
commit
2966a5c109
3 changed files with 60 additions and 29 deletions
|
@ -104,7 +104,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
|
||||
case 'GET':
|
||||
$getWishlistCardsFromPriority = isset($_GET['wishlist_id'], $_GET['priority']);
|
||||
$getWishlistFromHash = isset($_GET['wishlist_hash']);
|
||||
$getWishlistFromHash = isset($_GET['wishlist_hash'], $_GET['priority']);
|
||||
$getOwnWishlists = $user->isLoggedIn();
|
||||
|
||||
if ($getWishlistCardsFromPriority) {
|
||||
|
@ -170,16 +170,30 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
} elseif ($getWishlistFromHash) {
|
||||
$wishlist = Wishlist::getFromHash($_GET['wishlist_hash']);
|
||||
|
||||
if ($wishlist instanceof Wishlist) {
|
||||
$response['results'] = array(
|
||||
'id' => $wishlist->getId(),
|
||||
'hash' => $wishlist->getHash(),
|
||||
'userId' => $wishlist->getUserId(),
|
||||
$priorityAll = -1;
|
||||
$priorityNone = 0;
|
||||
$priority = (int) $_GET['priority'] ?? $priorityAll;
|
||||
|
||||
$options = array(
|
||||
'style' => $_GET['style'],
|
||||
'placeholders' => array(),
|
||||
);
|
||||
;
|
||||
} else {
|
||||
http_response_code(404);
|
||||
$where = array(
|
||||
'wishlist' => '`wishlist` = ' . $wishlist->getId(),
|
||||
'priority' => '`priority` = ' . $priority,
|
||||
);
|
||||
|
||||
if ($priorityAll === $priority) {
|
||||
unset($where['priority']);
|
||||
}
|
||||
|
||||
if ($priorityNone === $priority) {
|
||||
$where['priority'] = '`priority` IS NULL OR `priority` = 0';
|
||||
}
|
||||
|
||||
$options['WHERE'] = '(' . implode(') AND (', $where) . ')';
|
||||
|
||||
$response['results'] = $wishlist->getCards($options);
|
||||
} elseif ($getOwnWishlists) {
|
||||
$wishlists = array();
|
||||
$wishlistsItems = array();
|
||||
|
|
|
@ -163,7 +163,8 @@ global $options;
|
|||
<?php
|
||||
$api_urls = array(
|
||||
'get wishlists' => '/index.php?page=api&module=wishlists',
|
||||
'get wishlists by priority' => '/index.php?page=api&module=wishlists&style={style}&wishlist_id={wishlistid}&priority={priority}',
|
||||
'get wishes by wishlist id' => '/index.php?page=api&module=wishlists&style={style}&priority={priority}&wishlist_id={wishlistid}',
|
||||
'get wishes by wishlist hash' => '/index.php?page=api&module=wishlists&style={style}&priority={priority}&wishlist_hash={wishlisthash}',
|
||||
'delete wishlist' => '/index.php?page=api&module=wishlists',
|
||||
'update wish status' => '/index.php?page=api&module=wishes',
|
||||
'delete wish' => '/index.php?page=api&module=wishes&wish_id={wishid}',
|
||||
|
|
|
@ -3,14 +3,7 @@ $(function () {
|
|||
/**
|
||||
* Filter wishes
|
||||
*/
|
||||
$('.ui.dropdown.filter.priority')
|
||||
.dropdown({
|
||||
'match' : 'text',
|
||||
'fullTextSearch' : true,
|
||||
})
|
||||
.api({
|
||||
'action' : 'get wishlists by priority',
|
||||
'beforeSend' : function (settings) {
|
||||
var apiGetWishesByWishlistId = function (settings) {
|
||||
var wishlistId = $('.wishlist-cards[data-wishlist]').attr('data-wishlist');
|
||||
|
||||
if (undefined === wishthis.$_GET.id && undefined !== wishlistId && wishlistId.length > 0) {
|
||||
|
@ -22,7 +15,30 @@ $(function () {
|
|||
settings.urlData.wishlistid = wishthis.$_GET.id;
|
||||
|
||||
return settings;
|
||||
},
|
||||
};
|
||||
var apiGetWishesByWishlistHash = function (settings) {
|
||||
settings.urlData.style = $('input[name="style"]').val();
|
||||
settings.urlData.priority = $('.ui.dropdown.filter.priority').dropdown('get value');
|
||||
settings.urlData.wishlisthash = wishthis.$_GET.hash;
|
||||
|
||||
return settings;
|
||||
};
|
||||
var action = 'get wishes by wishlist id';
|
||||
var apiGetWishes = apiGetWishesByWishlistId;
|
||||
|
||||
if (wishthis.$_GET.hash) {
|
||||
var action = 'get wishes by wishlist hash';
|
||||
var apiGetWishes = apiGetWishesByWishlistHash;
|
||||
}
|
||||
|
||||
$('.ui.dropdown.filter.priority')
|
||||
.dropdown({
|
||||
'match' : 'text',
|
||||
'fullTextSearch' : true,
|
||||
})
|
||||
.api({
|
||||
'action' : action,
|
||||
'beforeSend' : apiGetWishes,
|
||||
'onSuccess' : function (response, dropdown_wishlists, xhr) {
|
||||
var html = response.results ? response.results : '';
|
||||
|
||||
|
|
Loading…
Reference in a new issue