diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index 366c7b183..49a559044 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -380,10 +380,15 @@ SELECT } else { + // TODO we take the list of cat_ids "as is", we should check they still + // exist and are browseable to the user $cat_ids = $search['fields']['cat']['words']; } - $query = ' + // in case the album would no longer exists, we consider the filter on album no longer active + if (!empty($cat_ids)) + { + $query = ' SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' AS i @@ -391,7 +396,8 @@ SELECT WHERE category_id IN ('.implode(',', $cat_ids).') '.$forbidden.' ;'; - $image_ids_for_filter['cat'] = query2array($query, null, 'id'); + $image_ids_for_filter['cat'] = query2array($query, null, 'id'); + } } // diff --git a/search.php b/search.php index 582c87af2..0b81d86f7 100644 --- a/search.php +++ b/search.php @@ -58,6 +58,20 @@ $cat_ids = array(); if (isset($_GET['cat_id'])) { check_input_parameter('cat_id', $_GET, false, PATTERN_ID); + + $query = ' +SELECT + * + FROM '.USER_CACHE_CATEGORIES_TABLE.' + WHERE cat_id = '.$_GET['cat_id'].' + AND user_id = '.$user['id'].' +;'; + $found_categories = query2array($query); + if (empty($found_categories)) + { + page_not_found(l10n('Requested album does not exist')); + } + $cat_ids = array($_GET['cat_id']); }