diff --git a/admin/configuration.php b/admin/configuration.php index 0c3f00303..96ded653d 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -112,6 +112,22 @@ $display_info_checkboxes = array( 'rating_score', ); +$filters_names_checkboxes = array( + "words", + "tags", + "post_date", + "creation_date", + "album", + "author", + "added_by", + "file_type", + "ratio", + "rating", + "file_size", + "height", + "width" +); + // image order management $sort_fields = array( '' => '', @@ -277,6 +293,23 @@ if (isset($_POST['submit'])) $_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations'])); break; } + case 'search' : + { + foreach( $filters_names_checkboxes as $checkbox) + { + if (empty($_POST['filters_views_box'][$checkbox])){ + $_POST['filters_views'][$checkbox]['access'] = 'nobody'; + $_POST['filters_views'][$checkbox]['default'] = false; + } + else{ + $_POST['filters_views'][$checkbox]['default'] = + empty($_POST['filters_views'][$checkbox]['default'])? false : true; + } + } + $_POST['filters_views']['last_filters_conf'] = + empty($_POST['filters_views']['last_filters_conf'])? false : true; + $_POST['filters_views'] = addslashes(serialize($_POST['filters_views'])); + } } // updating configuration if no error found @@ -660,6 +693,18 @@ switch ($page['section']) break; } + case 'search': + { + $filters_names = $filters_names_checkboxes; + $template->assign( + 'search', + array( + 'filters_views' => unserialize($conf['filters_views']), + 'filters_names' => $filters_names, + ), + ); + $template->assign('SHOW_FILTER_RATINGS', $conf['rate']); + } } $template->assign('isWebmaster', (is_webmaster()) ? 1 : 0); diff --git a/admin/include/add_core_tabs.inc.php b/admin/include/add_core_tabs.inc.php index 1f3e9b63f..7228657c3 100644 --- a/admin/include/add_core_tabs.inc.php +++ b/admin/include/add_core_tabs.inc.php @@ -81,6 +81,7 @@ function add_core_tabs($sheets, $tab_id) $sheets['watermark'] = array('caption' => ''.l10n('Watermark'), 'url' => $conf_link.'watermark'); $sheets['display'] = array('caption' => ''.l10n('Display'), 'url' => $conf_link.'display'); $sheets['comments'] = array('caption' => ''.l10n('Comments'), 'url' => $conf_link.'comments'); + $sheets['search'] = array('caption' => ''.l10n('Search'), 'url' => $conf_link.'search'); // $sheets['default'] = array('caption' => l10n('Guest Settings'), 'url' => $conf_link.'default'); break; diff --git a/admin/themes/clear/theme.css b/admin/themes/clear/theme.css index cc5a09900..ccb15ffc9 100644 --- a/admin/themes/clear/theme.css +++ b/admin/themes/clear/theme.css @@ -629,7 +629,6 @@ table.dataTable thead th, table.dataTable.no-footer { background: #3C3C3C; } -.font-checkbox [class*=icon-check]:before { color:#444; } #watermarkPositionBox { border:2px solid #ccc; @@ -651,7 +650,7 @@ FORM#categoryOrdering p.albumActions .userSeparator {border: 1px solid #E1E1E1;} .afterUploadActions a.secondary_button {background-color: #ECECEC;} .afterUploadActions a.secondary_button:hover {background-color: #FFA646;} -.font-checkbox:hover {color: #FFA844;} +.font-checkbox:hover {color: #3C3C3C;} .font-checkbox.selected {color: #ffa646;} LEGEND {color: #3C3C3C;} @@ -910,4 +909,10 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important; .RenameTagPopInContainer { background-color:#fff; +} + +/* Filters options */ +label:has(> .filters-icon-check:disabled), span:has(+ .filters-icon-check:disabled){ + color: #D5D5D5 !important; + cursor: not-allowed; } \ No newline at end of file diff --git a/admin/themes/default/template/configuration_search.tpl b/admin/themes/default/template/configuration_search.tpl new file mode 100644 index 000000000..ed698cb9e --- /dev/null +++ b/admin/themes/default/template/configuration_search.tpl @@ -0,0 +1,171 @@ +{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} + +{footer_script} + +filters_names = ["words","tags","post_date","creation_date","album","author","added_by","file_type","ratio","rating","file_size","height","width"]; + +for(const filter_name of filters_names){ + if(!$("input#"+filter_name+"Filters").is(':checked')){ + $("#f"+filter_name+"Select, #"+filter_name+"Arrow").hide(); + $("#default_"+filter_name).parent().hide(); + } + + if($("#f"+filter_name+"Select").val()!="admins-only"){ + $("#"+filter_name+"AdminIcon").hide(); + } + + if($("#default_"+filter_name).is(':checked')){ + $("#default_"+filter_name).parent().addClass("selected-filter-container"); + } + + $("#"+filter_name+"Filters").on("click", function(){ + if($("input#"+filter_name+"Filters").is(':checked')){ + $("#f"+filter_name+"Select, #"+filter_name+"Arrow").show(); + $("#default_"+filter_name).parent().show(); + if($("#f"+filter_name+"Select").val()=="admins-only"){ + $("#"+filter_name+"AdminIcon").show(); + } + } + else{ + $("#f"+filter_name+"Select, #"+filter_name+"Arrow, #"+filter_name+"AdminIcon").hide(); + $("#default_"+filter_name).parent().hide(); + } + }) + + $("#f"+filter_name+"Select").on("click", function(){ + if($("#f"+filter_name+"Select").val()=="admins-only"){ + $("#"+filter_name+"AdminIcon").show(); + } + else{ + $("#"+filter_name+"AdminIcon").hide(); + } + }) + + $("#default_"+filter_name).on("click", function(){ + if($("#default_"+filter_name).is(':checked')){ + $("#default_"+filter_name).parent().addClass("selected-filter-container"); + } + else{ + $("#default_"+filter_name).parent().removeClass("selected-filter-container"); + } + }) +} + +{/footer_script} + +{combine_css path="themes/default/vendor/fontello/css/gallery-icon.css" order=-10} + +
\ No newline at end of file diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css index ef8a45fec..41e5357a1 100644 --- a/admin/themes/default/theme.css +++ b/admin/themes/default/theme.css @@ -6374,13 +6374,23 @@ table.qsearch_help_table td { .font-checkbox [class*=icon-check]:before { font-size:16px; line-height:16px; - margin-right:0; + margin-right:5px; margin-left:0; + font-size: 145%; } .font-checkbox .icon-check-empty { position:relative; left:-1px; } + +.font-checkbox:hover .icon-check-empty, .font-checkbox:hover .icon-check { + color: #FF7700; +} + +.font-checkbox .icon-check { + color: #FFA646; +} + .font-checkbox input[type=checkbox], .font-checkbox input[type=radio] { display:none; } @@ -7758,3 +7768,73 @@ color:#FF7B00; box-shadow: 0px 4px 4px 0px #00000040; font-size: 10px; } + +/* Filters options */ +.filters-check::before{ + margin-right: 5px !important; + font-size: 145% !important; +} +.filters-checked-orange::before{ + margin-right: 5px !important; + color: #ffa646 !important; + font-size: 145% !important; +} +.filters-grid{ + display: grid; + grid-template-columns: 150px 118px 25px; + margin-bottom: 0px !important; +} +.select-views{ + background-color: #f3f3f3; + font-size: 11px; + border: none; + height: 16px; + margin-top: 4.5px; + padding-left: 10px; +} +.select-views-arrow{ + display: flex; + position: absolute; + margin-left: 249.9px; + margin-top: 5px; + pointer-events: none; +} +.select-views-admin{ + margin-left: 3px; +} + +.last-filters{ + display: block; + margin-bottom: 15px; + font-weight: bold; +} + +.filter-manager-options-container{ + display: inline-block; + font-size: 11px; + font-weight: normal !important; + color: #474747; + border: 1px solid #777; + border-radius: 20px; + padding: 4px 10px; + cursor: pointer; + margin-right: 7.5px; + margin-bottom: 7.5px; +} + +.filter-manager-options-container:hover{ + background-color: #EDEDED; +} + +.filter-manager-options-container.selected-filter-container{ + background-color: #777777; + color: #FFFFFF; +} + +.filter-manager-options-container.selected-filter-container:hover{ + background-color: #5D5D5D; +} + +.mcs-icon-options::before{ + margin-right: 5px; +} \ No newline at end of file diff --git a/admin/themes/roma/theme.css b/admin/themes/roma/theme.css index 509b2af2c..e384a2631 100644 --- a/admin/themes/roma/theme.css +++ b/admin/themes/roma/theme.css @@ -224,7 +224,7 @@ body .ui-resizable-autohide .ui-resizable-handle { display: none; } /* use 'body #ui-datepicker-div .ui-datepicker-buttonpane .ui-state-error:hover { background: #7e3030;} INPUT[type="text"].large { width: 317px; } -.buttonLike:disabled, input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled { +.buttonLike:disabled, .filters-icon-check:disabled, input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled { color:#555; border-color:#666; cursor:not-allowed; @@ -2381,4 +2381,26 @@ ul.jqtree-tree li.jqtree-ghost span.jqtree-line { .RenameTagPopInContainer { background-color:#444; +} + +/* Filters options */ +.select-views{ + background-color: #444444; + color: #898888; + border: 1px solid #666; +} + +.filter-manager-options-container{ + background-color: #333; + color: #aaa; + border-color: #333; +} + +.filter-manager-options-container.selected-filter-container{ + background-color: #777777; + color: #FFFFFF; +} + +label:has(> .filters-icon-check:disabled){ + color:#555; } \ No newline at end of file diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index 288d1f517..67d8d875e 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -119,10 +119,12 @@ function get_regular_search_results($search, $images_where='') $image_ids_for_filter = array(); + $display_filters = unserialize($conf["filters_views"]); + // // allwords // - if (isset($search['fields']['allwords']) and !empty($search['fields']['allwords']['words']) and count($search['fields']['allwords']['fields']) > 0) + if (isset($search['fields']['allwords']) and !empty($search['fields']['allwords']['words']) and count($search['fields']['allwords']['fields']) > 0 and ($display_filters["words"]["access"] == "everybody" or ($display_filters["words"]["access"] == "admins-only" and is_admin()) or ($display_filters["words"]["access"] == "registered-users" and is_classic_user()))) { $has_filters_filled = true; @@ -327,12 +329,12 @@ SELECT // // filetypes // - if (!empty($search['fields']['filetypes'])) + if (!empty($search['fields']['filetypes']['data'])) { $has_filters_filled = true; $filetypes_clauses = array(); - foreach ($search['fields']['filetypes'] as $ext) + foreach ($search['fields']['filetypes']['data'] as $ext) { $filetypes_clauses[] = 'path LIKE \'%.'.$ext.'\''; } @@ -351,7 +353,7 @@ SELECT // // added_by // - if (!empty($search['fields']['added_by'])) + if (!empty($search['fields']['added_by']['data'])) { $has_filters_filled = true; @@ -360,7 +362,7 @@ SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' AS i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id - WHERE added_by IN ('.implode(',', $search['fields']['added_by']).') + WHERE added_by IN ('.implode(',', $search['fields']['added_by']['data']).') '.$forbidden.' ;'; $image_ids_for_filter['added_by'] = query2array($query, null, 'id'); @@ -567,7 +569,7 @@ SELECT // // ratios // - if (!empty($search['fields']['ratios'])) + if (!empty($search['fields']['ratios']['data'])) { $has_filters_filled = true; @@ -579,7 +581,7 @@ SELECT ); $ratios_clauses = array(); - foreach ($search['fields']['ratios'] as $r) + foreach ($search['fields']['ratios']['data'] as $r) { $ratios_clauses[] = $clause_for_ratio[$r]; } @@ -598,12 +600,12 @@ SELECT // // ratings // - if ($conf['rate'] and !empty($search['fields']['ratings'])) + if ($conf['rate'] and !empty($search['fields']['ratings']['data'])) { $has_filters_filled = true; $filter_clauses = array(); - foreach ($search['fields']['ratings'] as $r) + foreach ($search['fields']['ratings']['data'] as $r) { if (0 == $r) { @@ -629,7 +631,7 @@ SELECT // // filesize // - if (!empty($search['fields']['filesize_min']) and !empty($search['fields']['filesize_max'])) + if (!empty($search['fields']['filesize_min']['data']) and !empty($search['fields']['filesize_max']['data'])) { $has_filters_filled = true; @@ -640,7 +642,7 @@ SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' AS i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id - WHERE filesize BETWEEN '.($search['fields']['filesize_min']-100).' AND '.($search['fields']['filesize_max']+100).' + WHERE filesize BETWEEN '.($search['fields']['filesize_min']['data']-100).' AND '.($search['fields']['filesize_max']['data']+100).' '.$forbidden.' ;'; $image_ids_for_filter['filesize'] = query2array($query, null, 'id'); @@ -649,7 +651,7 @@ SELECT // // height // - if (!empty($search['fields']['height_min']) and !empty($search['fields']['height_max'])) + if (!empty($search['fields']['height_min']['data']) and !empty($search['fields']['height_max']['data'])) { $has_filters_filled = true; @@ -658,7 +660,7 @@ SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' AS i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id - WHERE height BETWEEN '.$search['fields']['height_min'].' AND '.$search['fields']['height_max'].' + WHERE height BETWEEN '.$search['fields']['height_min']['data'].' AND '.$search['fields']['height_max']['data'].' '.$forbidden.' ;'; $image_ids_for_filter['height'] = query2array($query, null, 'id'); @@ -667,7 +669,7 @@ SELECT // // width // - if (!empty($search['fields']['width_min']) and !empty($search['fields']['width_max'])) + if (!empty($search['fields']['width_min']['data']) and !empty($search['fields']['width_max']['data'])) { $has_filters_filled = true; @@ -676,7 +678,7 @@ SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' AS i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id - WHERE width BETWEEN '.$search['fields']['width_min'].' AND '.$search['fields']['width_max'].' + WHERE width BETWEEN '.$search['fields']['width_min']['data'].' AND '.$search['fields']['width_max']['data'].' '.$forbidden.' ;'; $image_ids_for_filter['width'] = query2array($query, null, 'id'); diff --git a/include/search_filters.inc.php b/include/search_filters.inc.php index 82e6591c2..9c2bb07d9 100644 --- a/include/search_filters.inc.php +++ b/include/search_filters.inc.php @@ -6,6 +6,9 @@ // | file that was distributed with this source code. | // +-----------------------------------------------------------------------+ +$filters_views = unserialize($conf['filters_views']); +$template->assign('display_filter', $filters_views); + // we add isset($page['search_details']) in this condition because it only // applies to regular search, not the legacy qsearch. As Piwigo 14 will still // be able to show an old quicksearch result, we must check this condtion too. @@ -40,8 +43,14 @@ if ('search' == $page['section'] and isset($page['search_details'])) $search_items_clause = '1=1'; } + if (isset($my_search['fields']['allwords'])) + { + $my_search['fields']['allwords']["access"] = $filters_views["words"]["access"]; + } + if (isset($my_search['fields']['tags'])) { + $my_search['fields']['tags']["access"] = $filters_views["tags"]["access"]; $filter_tags = array(); // TODO calling get_available_tags(), with lots of photos/albums/tags may cost time, @@ -79,6 +88,7 @@ if ('search' == $page['section'] and isset($page['search_details'])) if (isset($my_search['fields']['author'])) { + $my_search['fields']['author']["access"] = $filters_views["author"]["access"]; $filter_clause = get_clause_for_filter('author'); $query = ' @@ -120,6 +130,7 @@ SELECT if (isset($my_search['fields']['date_posted'])) { + $my_search['fields']['date_posted']["access"] = $filters_views["post_date"]["access"]; $filter_clause = get_clause_for_filter('date_posted'); $cache_key = $persistent_cache->make_key('filter_date_posted'.$user['id'].$user['cache_update_time']); $set_persistent_cache = !preg_match('/^image_id IN/', $filter_clause) and !$persistent_cache->get($cache_key, $date_posted); @@ -222,6 +233,7 @@ SELECT if (isset($my_search['fields']['date_created'])) { + $my_search['fields']['date_created']["access"] = $filters_views["creation_date"]["access"]; $filter_clause = get_clause_for_filter('date_created'); $cache_key = $persistent_cache->make_key('filter_date_created'.$user['id'].$user['cache_update_time']); $set_persistent_cache = !preg_match('/^image_id IN/', $filter_clause) and !$persistent_cache->get($cache_key, $date_created); @@ -327,6 +339,7 @@ SELECT if (isset($my_search['fields']['added_by'])) { + $my_search['fields']['added_by']["access"] = $filters_views["added_by"]["access"]; $filter_clause = get_clause_for_filter('added_by'); $query = ' @@ -385,14 +398,19 @@ SELECT $template->assign('ADDED_BY', $added_by); // in case the search has forbidden added_by users for current user, we need to filter the search rule - $my_search['fields']['added_by'] = array_intersect($my_search['fields']['added_by'], $user_ids); + $my_search['fields']['added_by']['data'] = array_intersect($my_search['fields']['added_by']['data'], $user_ids); } - if (isset($my_search['fields']['cat']) and !empty($my_search['fields']['cat']['words'])) + if (isset($my_search['fields']['cat'])) { - $fullname_of = array(); + $my_search['fields']['cat']["access"] = $filters_views["album"]["access"]; + + if (!empty($my_search['fields']['cat']['words'])) + { + $my_search['fields']['cat']["access"] = "hahaha"; + $fullname_of = array(); - $query = ' + $query = ' SELECT id, uppercats @@ -400,27 +418,29 @@ SELECT INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id = cat_id AND user_id = '.$user['id'].' WHERE id IN ('.implode(',', $my_search['fields']['cat']['words']).') ;'; - $result = pwg_query($query); + $result = pwg_query($query); - while ($row = pwg_db_fetch_assoc($result)) - { - $cat_display_name = get_cat_display_name_cache( - $row['uppercats'], - 'admin.php?page=album-' // TODO not sure it's relevant to link to admin pages - ); - $row['fullname'] = strip_tags($cat_display_name); + while ($row = pwg_db_fetch_assoc($result)) + { + $cat_display_name = get_cat_display_name_cache( + $row['uppercats'], + 'admin.php?page=album-' // TODO not sure it's relevant to link to admin pages + ); + $row['fullname'] = strip_tags($cat_display_name); - $fullname_of[$row['id']] = $row['fullname']; + $fullname_of[$row['id']] = $row['fullname']; + } + + $template->assign('fullname_of', json_encode($fullname_of)); + + // in case the search has forbidden albums for current user, we need to filter the search rule + $my_search['fields']['cat']['words'] = array_intersect($my_search['fields']['cat']['words'], array_keys($fullname_of)); } - - $template->assign('fullname_of', json_encode($fullname_of)); - - // in case the search has forbidden albums for current user, we need to filter the search rule - $my_search['fields']['cat']['words'] = array_intersect($my_search['fields']['cat']['words'], array_keys($fullname_of)); } if (isset($my_search['fields']['filetypes'])) { + $my_search['fields']['filetypes']["access"] = $filters_views["file_type"]["access"]; $filter_clause = get_clause_for_filter('filetypes'); // get all file extensions for this user in the gallery, whatever the current filters @@ -476,6 +496,7 @@ SELECT if (isset($my_search['fields']['ratings'])) { + $my_search['fields']['ratings']["access"] = $filters_views["rating"]["access"]; $filter_clause = get_clause_for_filter('ratings'); $cache_key = $persistent_cache->make_key('filter_ratings'.$user['id'].$user['cache_update_time']); @@ -538,6 +559,8 @@ SELECT // For filesize if (isset($my_search['fields']['filesize_min']) && isset($my_search['fields']['filesize_max'])) { + $my_search['fields']['filesize_min']["access"] = $filters_views["file_size"]["access"]; + $my_search['fields']['filesize_max']["access"] = $filters_views["file_size"]["access"]; $filter_clause = get_clause_for_filter('filesize'); $filesizes = array(); @@ -576,8 +599,8 @@ SELECT // current search won't always be the first/last values found. It's going to be a // problem with this way to select selected values $filesize['selected'] = array( - 'min' => !empty($my_search['fields']['filesize_min']) ? sprintf('%.1f', $my_search['fields']['filesize_min']/1024) : $unique_filesizes[0], - 'max' => !empty($my_search['fields']['filesize_max']) ? sprintf('%.1f', $my_search['fields']['filesize_max']/1024) : end($unique_filesizes), + 'min' => !empty($my_search['fields']['filesize_min']['data']) ? sprintf('%.1f', $my_search['fields']['filesize_min']['data']/1024) : $unique_filesizes[0], + 'max' => !empty($my_search['fields']['filesize_max']['data']) ? sprintf('%.1f', $my_search['fields']['filesize_max']['data']/1024) : end($unique_filesizes), ); $template->assign('FILESIZE', $filesize ); @@ -585,6 +608,7 @@ SELECT if (isset($my_search['fields']['ratios'])) { + $my_search['fields']['ratios']["access"] = $filters_views["ratio"]["access"]; $filter_clause = get_clause_for_filter('ratios'); $cache_key = $persistent_cache->make_key('filter_ratios'.$user['id'].$user['cache_update_time']); @@ -654,6 +678,8 @@ SELECT if (isset($my_search['fields']['height_min']) and isset($my_search['fields']['height_max'])) { + $my_search['fields']['height_min']["access"] = $filters_views["height"]["access"]; + $my_search['fields']['height_max']["access"] = $filters_views["height"]["access"]; $filter_clause = get_clause_for_filter('height'); $query = ' @@ -691,8 +717,8 @@ SELECT 'max' => end($heights), ), 'selected' => array( - 'min' => !empty($my_search['fields']['height_min']) ? $my_search['fields']['height_min'] : $heights[0], - 'max' => !empty($my_search['fields']['height_max']) ? $my_search['fields']['height_max'] : end($heights), + 'min' => !empty($my_search['fields']['height_min']['data']) ? $my_search['fields']['height_min']['data'] : $heights[0], + 'max' => !empty($my_search['fields']['height_max']['data']) ? $my_search['fields']['height_max']['data'] : end($heights), ) ); @@ -701,6 +727,8 @@ SELECT if (isset($my_search['fields']['width_min']) and isset($my_search['fields']['width_max'])) { + $my_search['fields']['width_min']["access"] = $filters_views["width"]["access"]; + $my_search['fields']['width_max']["access"] = $filters_views["width"]["access"]; $filter_clause = get_clause_for_filter('width'); $query = ' @@ -738,8 +766,8 @@ SELECT 'max' => end($widths), ), 'selected' => array( - 'min' => !empty($my_search['fields']['width_min']) ? $my_search['fields']['width_min'] : $widths[0], - 'max' => !empty($my_search['fields']['width_max']) ? $my_search['fields']['width_max'] : end($widths), + 'min' => !empty($my_search['fields']['width_min']['data']) ? $my_search['fields']['width_min']['data'] : $widths[0], + 'max' => !empty($my_search['fields']['width_max']['data']) ? $my_search['fields']['width_max']['data'] : end($widths), ) ); diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index a36584f5a..d99ecb753 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -843,7 +843,7 @@ function ws_images_filteredSearch_create($params, $service) } } - $search['fields']['filetypes'] = $params['filetypes']; + $search['fields']['filetypes']['data'] = $params['filetypes']; } if (isset($params['added_by'])) @@ -856,7 +856,7 @@ function ws_images_filteredSearch_create($params, $service) } } - $search['fields']['added_by'] = $params['added_by']; + $search['fields']['added_by']['data'] = $params['added_by']; } if (isset($params['date_posted_preset'])) @@ -1001,42 +1001,42 @@ function ws_images_filteredSearch_create($params, $service) } } - $search['fields']['ratios'] = $params['ratios']; + $search['fields']['ratios']['data'] = $params['ratios']; } if ($conf['rate'] and isset($params['ratings'])) { - $search['fields']['ratings'] = $params['ratings']; + $search['fields']['ratings']['data'] = $params['ratings']; } if (isset($params['filesize_min'])) { - $search['fields']['filesize_min'] = $params['filesize_min']; + $search['fields']['filesize_min']['data'] = $params['filesize_min']; } if (isset($params['filesize_max'])) { - $search['fields']['filesize_max'] = $params['filesize_max']; + $search['fields']['filesize_max']['data'] = $params['filesize_max']; } if (isset($params['width_min'])) { - $search['fields']['width_min'] = $params['width_min']; + $search['fields']['width_min']['data'] = $params['width_min']; } if (isset($params['width_max'])) { - $search['fields']['width_max'] = $params['width_max']; + $search['fields']['width_max']['data'] = $params['width_max']; } if (isset($params['height_min'])) { - $search['fields']['height_min'] = $params['height_min']; + $search['fields']['height_min']['data'] = $params['height_min']; } if (isset($params['height_max'])) { - $search['fields']['height_max'] = $params['height_max']; + $search['fields']['height_max']['data'] = $params['height_max']; } list($search_uuid, $search_url) = save_search($search, $search_info['id'] ?? null); diff --git a/install/config.sql b/install/config.sql index 1dc6915ea..d2e9ede61 100644 --- a/install/config.sql +++ b/install/config.sql @@ -80,3 +80,4 @@ INSERT INTO piwigo_config (param,value) VALUES ('index_search_in_set_action','tr INSERT INTO piwigo_config (param,value) VALUES ('upload_detect_duplicate','true'); INSERT INTO piwigo_config (param,value) VALUES ('webmaster_id','1'); INSERT INTO piwigo_config (param,value) VALUES ('use_standard_pages','true'); +INSERT INTO piwigo_config (param,value,comment) VALUES ('filters_views','a:14:{s:5:"words";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:1;}s:4:"tags";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:9:"post_date";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:13:"creation_date";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:1;}s:5:"album";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:1;}s:6:"author";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:8:"added_by";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:9:"file_type";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:5:"ratio";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:6:"rating";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:9:"file_size";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:6:"height";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:5:"width";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:17:"last_filters_conf";b:1;}','Filters displays configuration'); diff --git a/search.php b/search.php index 0b81d86f7..6fa152a6d 100644 --- a/search.php +++ b/search.php @@ -28,9 +28,23 @@ $search = array( ); // list of filters in user preferences -// allwords, cat, tags, author, added_by, filetypes, date_posted -$default_fields = array('allwords', 'cat', 'tags', 'author'); -if (is_a_guest() or is_generic()) +// allwords, cat, tags, author, added_by, filetypes, date_posted, date_created, ratios, ratings (if rating is allowed in this Piwigo), height, width +//import the conf for the filters +$filters_conf = unserialize($conf['filters_views']); +//change the name of the keys so that they can be used with this part of the program +$filters_conf = array_combine(array("allwords", "tags", "date_posted", "date_created", "cat", "author", "added_by", "filetypes", "ratios", "ratings", "filesize", "height", "width", "last_filters_conf"), $filters_conf); + +//get all default filters +$default_fields = array(); +foreach($filters_conf as $filt_name => $filt_conf){ + if(isset($filt_conf["default"])){ + if($filt_conf["default"] == true){ + $default_fields[] = $filt_name; + } + } +} + +if (is_a_guest() or is_generic() or $filters_conf["last_filters_conf"]==false) { $fields = $default_fields; } @@ -131,11 +145,28 @@ SELECT } } -foreach (array('added_by', 'filetypes', 'date_posted') as $field) +foreach (array('added_by', 'filetypes', 'ratios', 'ratings') as $field) { if (in_array($field, $fields)) { - $search['fields'][$field] = array(); + $search['fields'][$field]["data"] = array(); + } +} + +foreach (array('date_posted', 'date_created') as $field){ + if (in_array($field, $fields)) + { + $search['fields'][$field] = array( + 'preset' => '' + ); + } +} + +foreach (array('filesize_min', 'filesize_max', 'width_min', 'width_max', 'height_min', 'height_max') as $field) +{ + if (in_array($field, $fields)) + { + $search['fields'][$field]["data"] = ''; } } diff --git a/themes/default/js/mcs.js b/themes/default/js/mcs.js index ec20466ee..0c30c5113 100644 --- a/themes/default/js/mcs.js +++ b/themes/default/js/mcs.js @@ -33,8 +33,10 @@ $(document).ready(function () { PS_params.search_id = search_id; empty_filters_list = []; + filters_to_remove = []; + // Setup word filter - if (global_params.fields.allwords) { + if (global_params.fields.allwords && (global_params.fields.allwords.access == "everybody" || (global_params.fields.allwords.access == "admins-only" && user_rank == "admin") || (global_params.fields.allwords.access == "registered-users" && user_rank == "user"))) { $(".filter-word").css("display", "flex"); $(".filter-manager-controller.word").prop("checked", true); @@ -76,6 +78,13 @@ $(document).ready(function () { empty_filters_list.push(PS_params.allwords); } + + else if (global_params.fields.allwords && !(global_params.fields.allwords.access == "everybody" || (global_params.fields.allwords.access == "admins-only" && user_rank == "admin") || (global_params.fields.allwords.access == "registered-users" && user_rank == "user"))) + { + updateFilters('word', 'del'); + filters_to_remove.push("allwords"); + } + //Hide filter spinner $(".filter-spinner").hide(); @@ -87,8 +96,8 @@ $(document).ready(function () { items: global_params.fields.tags ? global_params.fields.tags.words : null, }); }); - - if (global_params.fields.tags) { + + if (global_params.fields.tags && (global_params.fields.tags.access == "everybody" || (global_params.fields.tags.access == "admins-only" && user_rank == "admin") || (global_params.fields.tags.access == "registered-users" && user_rank == "user"))) { $(".filter-tag").css("display", "flex"); $(".filter-manager-controller.tags").prop("checked", true); $(".filter-tag-form .search-params input[value=" + global_params.fields.tags.mode + "]").prop("checked", true); @@ -115,8 +124,14 @@ $(document).ready(function () { empty_filters_list.push(PS_params.tags); } + else if (global_params.fields.tags && !(global_params.fields.tags.access == "everybody" || (global_params.fields.tags.access == "admins-only" && user_rank == "admin") || (global_params.fields.tags.access == "registered-users" && user_rank == "user"))) + { + updateFilters('tag', 'del'); + filters_to_remove.push("tags"); + } + // Setup Date post filter - if (global_params.fields.date_posted) { + if (global_params.fields.date_posted && (global_params.fields.date_posted.access == "everybody" || (global_params.fields.date_posted.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_posted.access == "registered-users" && user_rank == "user"))) { $(".filter-date_posted").css("display", "flex"); $(".filter-manager-controller.date_posted").prop("checked", true); @@ -226,9 +241,15 @@ $(document).ready(function () { empty_filters_list.push(PS_params.date_posted_custom); } + else if (global_params.fields.date_posted && !(global_params.fields.date_posted.access == "everybody" || (global_params.fields.date_posted.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_posted.access == "registered-users" && user_rank == "user"))) + { + updateFilters('date_posted', 'del'); + filters_to_remove.push("date_posted"); + } + // Setup Date creation filter - if (global_params.fields.date_created) { + if (global_params.fields.date_created && (global_params.fields.date_created.access == "everybody" || (global_params.fields.date_created.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_created.access == "registered-users" && user_rank == "user"))) { $(".filter-date_created").css("display", "flex"); $(".filter-manager-controller.date_created").prop("checked", true); @@ -336,8 +357,14 @@ $(document).ready(function () { empty_filters_list.push(PS_params.date_created_custom); } + else if (global_params.fields.date_created && !(global_params.fields.date_created.access == "everybody" || (global_params.fields.date_created.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_created.access == "registered-users" && user_rank == "user"))) + { + updateFilters('date_created', 'del'); + filters_to_remove.push("date_created"); + } + // Setup album filter - if (global_params.fields.cat) { + if (global_params.fields.cat && (global_params.fields.cat.access == "everybody" || (global_params.fields.cat.access == "admins-only" && user_rank == "admin") || (global_params.fields.cat.access == "registered-users" && user_rank == "user"))) { $(".filter-album").css("display", "flex"); $(".filter-manager-controller.album").prop("checked", true); @@ -388,6 +415,12 @@ $(document).ready(function () { empty_filters_list.push(PS_params.categories); } + + else if (global_params.fields.cat && !(global_params.fields.cat.access == "everybody" || (global_params.fields.cat.access == "admins-only" && user_rank == "admin") || (global_params.fields.cat.access == "registered-users" && user_rank == "user"))) + { + updateFilters('album', 'del'); + filters_to_remove.push("cat"); + } // Setup author filter $("#authors").each(function() { @@ -396,7 +429,7 @@ $(document).ready(function () { maxOptions:$(this).find("option").length, items: global_params.fields.author ? global_params.fields.author.words : null, }); - if (global_params.fields.author) { + if (global_params.fields.author && (global_params.fields.author.access == "everybody" || (global_params.fields.author.access == "admins-only" && user_rank == "admin") || (global_params.fields.author.access == "registered-users" && user_rank == "user"))) { $(".filter-authors").css("display", "flex"); $(".filter-manager-controller.author").prop("checked", true); @@ -420,14 +453,20 @@ $(document).ready(function () { empty_filters_list.push(PS_params.authors); } + + else if (global_params.fields.author && !(global_params.fields.author.access == "everybody" || (global_params.fields.author.access == "admins-only" && user_rank == "admin") || (global_params.fields.author.access == "registered-users" && user_rank == "user"))) + { + updateFilters('author', 'del'); + filters_to_remove.push("author"); + } }); // Setup added_by filter - if (global_params.fields.added_by) { + if (global_params.fields.added_by && (global_params.fields.added_by.access == "everybody" || (global_params.fields.added_by.access == "admins-only" && user_rank == "admin") || (global_params.fields.added_by.access == "registered-users" && user_rank == "user"))) { $(".filter-added_by").css("display", "flex"); $(".filter-manager-controller.added_by").prop("checked", true); - if (global_params.fields.added_by && global_params.fields.added_by.length > 0) { + if (global_params.fields.added_by && global_params.fields.added_by.data.length > 0) { $(".filter-added_by").addClass("filter-filled"); added_by_names = []; @@ -436,7 +475,7 @@ $(document).ready(function () { input = $(this).find('input'); added_by_id = parseInt(input.attr('name')); - if (jQuery.inArray(added_by_id, global_params.fields.added_by) >= 0) { + if (jQuery.inArray(added_by_id, global_params.fields.added_by.data) >= 0) { input.prop('checked', true); added_by_names.push($(this).find('.added_by-name').text()); } @@ -452,27 +491,33 @@ $(document).ready(function () { $(".filter-added_by .added_by-option input").prop("checked", false); }); - PS_params.added_by = global_params.fields.added_by.length > 0 ? global_params.fields.added_by : ''; + PS_params.added_by = global_params.fields.added_by.data.length > 0 ? global_params.fields.added_by.data : ''; empty_filters_list.push(PS_params.added_by); } + else if (global_params.fields.added_by && !(global_params.fields.added_by.access == "everybody" || (global_params.fields.added_by.access == "admins-only" && user_rank == "admin") || (global_params.fields.added_by.access == "registered-users" && user_rank == "user"))) + { + updateFilters('added_by', 'del'); + filters_to_remove.push("added_by"); + } + // Setup filetypes filter - if (global_params.fields.filetypes) { + if (global_params.fields.filetypes && (global_params.fields.filetypes.access == "everybody" || (global_params.fields.filetypes.access == "admins-only" && user_rank == "admin") || (global_params.fields.filetypes.access == "registered-users" && user_rank == "user"))) { $(".filter-filetypes").css("display", "flex"); $(".filter-manager-controller.filetypes").prop("checked", true); filetypes_search_str = ""; - global_params.fields.filetypes.forEach(ft => { + global_params.fields.filetypes.data.forEach(ft => { filetypes_search_str += ft + ", "; }); - if (global_params.fields.filetypes && global_params.fields.filetypes.length > 0) { + if (global_params.fields.filetypes && global_params.fields.filetypes.data.length > 0) { $(".filter-filetypes").addClass("filter-filled"); $(".filter.filter-filetypes .search-words").text(filetypes_search_str.toUpperCase().slice(0, -2)); $(".filetypes-option input").each(function () { - if (global_params.fields.filetypes.includes($(this).attr('name'))) { + if (global_params.fields.filetypes.data.includes($(this).attr('name'))) { $(this).prop('checked', true); } }); @@ -484,27 +529,33 @@ $(document).ready(function () { $(".filter-filetypes .filetypes-option input").prop("checked", false); }); - PS_params.filetypes = global_params.fields.filetypes.length > 0 ? global_params.fields.filetypes : ''; + PS_params.filetypes = global_params.fields.filetypes.data.length > 0 ? global_params.fields.filetypes.data : ''; empty_filters_list.push(PS_params.filetypes); } + else if (global_params.fields.filetypes && !(global_params.fields.filetypes.access == "everybody" || (global_params.fields.filetypes.access == "admins-only" && user_rank == "admin") || (global_params.fields.filetypes.access == "registered-users" && user_rank == "user"))) + { + updateFilters('filetypes', 'del'); + filters_to_remove.push("filetypes"); + } + // Setup Ratio filter - if (global_params.fields.ratios) { + if (global_params.fields.ratios && (global_params.fields.ratios.access == "everybody" || (global_params.fields.ratios.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratios.access == "registered-users" && user_rank == "user"))) { $(".filter-ratios").css("display", "flex"); $(".filter-manager-controller.ratios").prop("checked", true); ratios_search_str = ""; - global_params.fields.ratios.forEach(ft => { + global_params.fields.ratios.data.forEach(ft => { ratios_search_str += str_ratios_label[ft] + ", "; }); - if (global_params.fields.ratios && global_params.fields.ratios.length > 0) { + if (global_params.fields.ratios && global_params.fields.ratios.data.length > 0) { $(".filter-ratios").addClass("filter-filled"); $(".filter.filter-ratios .search-words").text(ratios_search_str.slice(0, -2)); $(".ratios-option input").each(function () { - if (global_params.fields.ratios.includes($(this).attr('name'))) { + if (global_params.fields.ratios.data.includes($(this).attr('name'))) { $(this).prop('checked', true); } }); @@ -516,23 +567,29 @@ $(document).ready(function () { $(".filter-ratios .ratios-option input").prop("checked", false); }); - PS_params.ratios = global_params.fields.ratios.length > 0 ? global_params.fields.ratios : ''; + PS_params.ratios = global_params.fields.ratios.data.length > 0 ? global_params.fields.ratios.data : ''; empty_filters_list.push(PS_params.ratios); } + else if (global_params.fields.ratios && !(global_params.fields.ratios.access == "everybody" || (global_params.fields.ratios.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratios.access == "registered-users" && user_rank == "user"))) + { + updateFilters('ratios', 'del'); + filters_to_remove.push("ratios"); + } + // Setup rating filter - if (global_params.fields.ratings && show_filter_ratings) { + if (global_params.fields.ratings && show_filter_ratings && (global_params.fields.ratings.access == "everybody" || (global_params.fields.ratings.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratings.access == "registered-users" && user_rank == "user"))) { $(".filter-ratings").css("display", "flex"); $(".filter-manager-controller.ratings").prop("checked", true); ratings_search_str = ""; - global_params.fields.ratings.forEach(function(ft, i){ + global_params.fields.ratings.data.forEach(function(ft, i){ if(0 == ft ) { ratings_search_str += str_no_rating - if(global_params.fields.ratings.length > 1) + if(global_params.fields.ratings.data.length > 1) { ratings_search_str += ", "; } @@ -541,19 +598,19 @@ $(document).ready(function () { { str_between = str_between_rating.split("%d"); ratings_search_str += str_between[0] + (ft-1) + str_between[1] + ft + str_between[2]; - if(global_params.fields.ratings.length-1 != i) + if(global_params.fields.ratings.data.length-1 != i) { ratings_search_str += ", "; } } }); - if (global_params.fields.ratings && global_params.fields.ratings.length > 0) { + if (global_params.fields.ratings && global_params.fields.ratings.data.length > 0) { $(".filter-ratings").addClass("filter-filled"); $(".filter.filter-ratings .search-words").text(ratings_search_str); $(".ratings-option input").each(function () { - if (global_params.fields.ratings.includes($(this).attr('name'))) { + if (global_params.fields.ratings.data.includes($(this).attr('name'))) { $(this).prop('checked', true); } }); @@ -565,21 +622,22 @@ $(document).ready(function () { $(".filter-ratings .ratings-option input").prop("checked", false); }); - PS_params.ratings = global_params.fields.ratings.length > 0 ? global_params.fields.ratings : ''; + PS_params.ratings = global_params.fields.ratings.data.length > 0 ? global_params.fields.ratings.data : ''; empty_filters_list.push(PS_params.ratings); } - else if (!show_filter_ratings) + else if (global_params.fields.ratings && (!show_filter_ratings || global_params.fields.ratings && !(global_params.fields.ratings.access == "everybody" || (global_params.fields.ratings.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratings.access == "registered-users" && user_rank == "user")))) { - updateFilters('ratings', 'add'); + updateFilters('ratings', 'del'); + filters_to_remove.push("ratings"); } // Setup filesize filter - if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null) { + if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null && (global_params.fields.filesize_min.access == "everybody" || (global_params.fields.filesize_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.filesize_min.access == "registered-users" && user_rank == "user"))) { $(".filter-filesize").css("display", "flex"); $(".filter-manager-controller.filesize").prop("checked", true); - $(".filter.filter-filesize .slider-info").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max,)); + $(".filter.filter-filesize .slider-info").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max)); $('[data-slider=filesizes]').pwgDoubleSlider(sliders.filesizes); @@ -592,9 +650,9 @@ $(document).ready(function () { }); - if( global_params.fields.filesize_min != null && global_params.fields.filesize_max > 0) { + if( global_params.fields.filesize_min.data != null && global_params.fields.filesize_max.data > 0) { $(".filter-filesize").addClass("filter-filled"); - $(".filter.filter-filesize .search-words").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max,)); + $(".filter.filter-filesize .search-words").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max)); } else { @@ -611,24 +669,30 @@ $(document).ready(function () { } }); - PS_params.filesize_min = global_params.fields.filesize_min != null ? global_params.fields.filesize_min : ''; - PS_params.filesize_max = global_params.fields.filesize_max != null ? global_params.fields.filesize_max : ''; + PS_params.filesize_min = global_params.fields.filesize_min.data != null ? global_params.fields.filesize_min.data : ''; + PS_params.filesize_max = global_params.fields.filesize_max.data != null ? global_params.fields.filesize_max.data : ''; empty_filters_list.push(PS_params.filesize_min); empty_filters_list.push(PS_params.filesize_max); } + else if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null && !(global_params.fields.filesize_min.access == "everybody" || (global_params.fields.filesize_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.filesize_min.access == "registered-users" && user_rank == "user"))) + { + updateFilters('filesize', 'del'); + filters_to_remove.push("filesize"); + } + // Setup Height filter - if (global_params.fields.height_min != null && global_params.fields.height_max != null) { + if (global_params.fields.height_min != null && global_params.fields.height_max != null && (global_params.fields.height_min.access == "everybody" || (global_params.fields.height_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.height_min.access == "registered-users" && user_rank == "user"))) { $(".filter-height").css("display", "flex"); $(".filter-manager-controller.height").prop("checked", true); - $(".filter.filter-height .slider-info").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max,)); + $(".filter.filter-height .slider-info").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max)); $('[data-slider=heights]').pwgDoubleSlider(sliders.heights); - if( global_params.fields.height_min > 0 && global_params.fields.height_max > 0) { + if( global_params.fields.height_min.data > 0 && global_params.fields.height_max.data > 0) { $(".filter-height").addClass("filter-filled"); - $(".filter.filter-height .search-words").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max,)); + $(".filter.filter-height .search-words").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max)); } else { @@ -645,24 +709,30 @@ $(document).ready(function () { } }); - PS_params.height_min = global_params.fields.height_min != null ? global_params.fields.height_min : ''; - PS_params.height_max = global_params.fields.height_max != null ? global_params.fields.height_max : ''; + PS_params.height_min = global_params.fields.height_min.data != null ? global_params.fields.height_min.data : ''; + PS_params.height_max = global_params.fields.height_max.data != null ? global_params.fields.height_max.data : ''; empty_filters_list.push(PS_params.height_min); empty_filters_list.push(PS_params.height_max); } + else if (global_params.fields.height_min != null && global_params.fields.height_max != null && !(global_params.fields.height_min.access == "everybody" || (global_params.fields.height_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.height_min.access == "registered-users" && user_rank == "user"))) + { + updateFilters('height', 'del'); + filters_to_remove.push("height"); + } + // Setup Width filter - if (global_params.fields.width_min != null && global_params.fields.width_max != null) { + if (global_params.fields.width_min != null && global_params.fields.width_max != null && (global_params.fields.width_min.access == "everybody" || (global_params.fields.width_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.width_min.access == "registered-users" && user_rank == "user"))) { $(".filter-width").css("display", "flex"); $(".filter-manager-controller.width").prop("checked", true); - $(".filter.filter-width .slider-info").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max,)); + $(".filter.filter-width .slider-info").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max)); $('[data-slider=widths]').pwgDoubleSlider(sliders.widths); - if( global_params.fields.width_min > 0 && global_params.fields.width_max > 0) { + if( global_params.fields.width_min.data > 0 && global_params.fields.width_max.data > 0) { $(".filter-width").addClass("filter-filled"); - $(".filter.filter-width .search-words").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max,)); + $(".filter.filter-width .search-words").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max)); } else { @@ -679,13 +749,23 @@ $(document).ready(function () { } }); - PS_params.width_min = global_params.fields.width_min != null ? global_params.fields.width_min : ''; - PS_params.width_max = global_params.fields.width_max != null ? global_params.fields.width_max : ''; + PS_params.width_min = global_params.fields.width_min.data != null ? global_params.fields.width_min.data : ''; + PS_params.width_max = global_params.fields.width_max.data != null ? global_params.fields.width_max.data : ''; empty_filters_list.push(PS_params.width_min); empty_filters_list.push(PS_params.width_max); } + else if (global_params.fields.width_min != null && global_params.fields.width_max != null && !(global_params.fields.width_min.access == "everybody" || (global_params.fields.width_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.width_min.access == "registered-users" && user_rank == "user"))) + { + updateFilters('width', 'del'); + filters_to_remove.push("width"); + } + + if(filters_to_remove.length > 0){ + filters_to_remove = []; + performSearch(PS_params, true); + } // Adapt no result message if ($(".filter-filled").length === 0) { @@ -693,7 +773,7 @@ $(document).ready(function () { $(".mcs-no-result .text .bot").html(str_empty_search_bot_alt); } - if (!empty_filters_list.every(param => param === "" || param === null)) { + if (!empty_filters_list.every(param => param === "" || param === null || (typeof param == 'undefined'))) { $(".clear-all").addClass("clickable"); $(".clear-all.clickable").on('click', function () { exclude_params = ['search_id', 'allwords_mode', 'allwords_fields', 'tags_mode', 'categories_withsubs']; @@ -1173,7 +1253,7 @@ $(document).ready(function () { ratios_array.push($(this).attr('name')); }); - global_params.fields.ratios = ratios_array; + global_params.fields.ratios.data = ratios_array; PS_params.ratios = ratios_array.length > 0 ? ratios_array : ''; } diff --git a/themes/default/template/include/search_filters.inc.tpl b/themes/default/template/include/search_filters.inc.tpl index c1a5ff012..aad13dd3b 100644 --- a/themes/default/template/include/search_filters.inc.tpl +++ b/themes/default/template/include/search_filters.inc.tpl @@ -23,6 +23,14 @@ fullname_of_cat = {$fullname_of}; search_id = '{$SEARCH_ID}'; {/if} +{if is_admin()} +user_rank = "admin"; +{elseif is_classic_user()} +user_rank = "user"; +{else} +user_rank = "none"; +{/if} + str_word_widget_label = "{'Search for words'|@translate|escape:javascript}"; str_tags_widget_label = "{'Tag'|@translate|escape:javascript}"; str_album_widget_label = "{'Album'|@translate|escape:javascript}"; @@ -101,60 +109,86 @@ const prefix_icon = 'gallery-icon-';