diff --git a/admin/configuration.php b/admin/configuration.php
index e29fa32f1..bbc62cae2 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -117,7 +117,7 @@ if (!isset($conf['filters_views']))
conf_update_param('filters_views', $conf['default_filters_views'], true);
}
-$filters_names_checkboxes = array_diff(array_keys(safe_unserialize($conf['filters_views'])), array('last_filters_conf'));
+$filters_names_checkboxes = array_values(array_diff(array_keys(safe_unserialize($conf['filters_views'])), array('last_filters_conf')));
// image order management
$sort_fields = array(
@@ -688,12 +688,11 @@ switch ($page['section'])
}
case 'search':
{
- $filters_names = $filters_names_checkboxes;
$template->assign(
'search',
array(
'filters_views' => safe_unserialize($conf['filters_views']),
- 'filters_names' => $filters_names,
+ 'filters_names' => $filters_names_checkboxes,
),
);
$template->assign('SHOW_FILTER_RATINGS', $conf['rate']);
diff --git a/admin/themes/default/template/configuration_search.tpl b/admin/themes/default/template/configuration_search.tpl
index d5d8aaed8..42b36a0d2 100644
--- a/admin/themes/default/template/configuration_search.tpl
+++ b/admin/themes/default/template/configuration_search.tpl
@@ -2,22 +2,7 @@
{footer_script}
-filters_names =
-[
- 'words',
- 'tags',
- 'post_date',
- 'creation_date',
- 'album',
- 'author',
- 'added_by',
- 'file_type',
- 'ratio',
- 'rating',
- 'file_size',
- 'height',
- 'width'
-];
+const filters_names = {$search.filters_names|json_encode};
for(const filter_name of filters_names){
if(!$("input#"+filter_name+"Filters").is(':checked')){
@@ -91,6 +76,8 @@ for(const filter_name of filters_names){
>
{if $filter_name == 'words'}
{'Search for words'|translate}
+ {else if $filter_name == 'expert'}
+ {'Expert mode'|translate}
{else if $filter_name == 'file_size'}
{'Filesize'|translate}
{else}
@@ -100,7 +87,7 @@ for(const filter_name of filters_names){
@@ -225,7 +212,14 @@ for(const filter_name of filters_names){
{/if}
hidden/>
-
+
diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css
index a8b075766..d7d3e96ca 100644
--- a/admin/themes/default/theme.css
+++ b/admin/themes/default/theme.css
@@ -8454,7 +8454,7 @@ color:#FF7B00;
/* Filters options */
.filters-grid{
display: grid;
- grid-template-columns: 200px 118px 25px;
+ grid-template-columns: 200px 150px 25px;
margin-bottom: 0px !important;
}
.select-views{
@@ -8468,7 +8468,7 @@ color:#FF7B00;
.select-views-arrow{
display: flex;
position: absolute;
- margin-left: 299.9px;
+ margin-left: 333px;
margin-top: 5px;
pointer-events: none;
}
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 0dd0a84d1..4dc7fec47 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -1054,6 +1054,7 @@ $conf['default_filters_views'] = array(
'file_size' => ['access'=>'everybody', 'default'=>false],
'height' => ['access'=>'everybody', 'default'=>false],
'width' => ['access'=>'everybody', 'default'=>false],
+ 'expert' => ['access'=>'everybody', 'default'=>false],
'last_filters_conf' => true,
);
diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php
index 8fda28f6c..1df62e96d 100644
--- a/include/functions_search.inc.php
+++ b/include/functions_search.inc.php
@@ -119,15 +119,7 @@ function get_regular_search_results($search, $images_where='')
$image_ids_for_filter = array();
- if (isset($conf['filters_views']))
- {
- $display_filters = unserialize($conf['filters_views']);
- }
- else
- {
- $display_filters = unserialize('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;}');
- }
-
+ $display_filters = safe_unserialize(conf_get_param('filters_views', $conf['default_filters_views']));
foreach($display_filters as $filt_name => $filt_conf){
if(isset($filt_conf['access']))
@@ -146,7 +138,7 @@ function get_regular_search_results($search, $images_where='')
//
// expert
//
- if (isset($search['fields']['expert']) and !empty($search['fields']['expert']['string']))
+ if (isset($search['fields']['expert']) and !empty($search['fields']['expert']['string']) and $display_filters['expert']['access'])
{
$has_filters_filled = true;
diff --git a/include/search_filters.inc.php b/include/search_filters.inc.php
index 7ffb65636..11ec3198a 100644
--- a/include/search_filters.inc.php
+++ b/include/search_filters.inc.php
@@ -109,7 +109,14 @@ if ('search' == $page['section'] and isset($page['search_details']))
if (isset($my_search['fields']['expert']))
{
- load_language('help_quick_search.lang');
+ if (!$display_filters['expert']['access'])
+ {
+ unset($my_search['fields']['expert']);
+ }
+ else
+ {
+ load_language('help_quick_search.lang');
+ }
}
if (isset($my_search['fields']['author']) and $display_filters['author']['access'])
diff --git a/install/db/178-database.php b/install/db/178-database.php
index 29c32da7a..ef8365f7f 100644
--- a/install/db/178-database.php
+++ b/install/db/178-database.php
@@ -13,7 +13,9 @@ if (!defined('PHPWG_ROOT_PATH'))
$upgrade_description = 'add config parameters to the gallery filters';
-conf_update_param('filters_views', $conf['default_filters_views']);
+// let the $conf['filters_views'] be written in config table when the admin will change settings in administration.
+//
+// conf_update_param('filters_views', $conf['default_filters_views']);
echo "\n".$upgrade_description."\n";
diff --git a/install/db/181-database.php b/install/db/181-database.php
new file mode 100644
index 000000000..f0b2d9bd8
--- /dev/null
+++ b/install/db/181-database.php
@@ -0,0 +1,33 @@
+
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index b5e93b9ee..f108c3a60 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -1420,5 +1420,6 @@ $lang['If a photo in this album has the same filename, update the file without c
$lang['Empty lounge'] = 'Empty lounge';
$lang['There is currently %d photos in the lounge (upload buffer)'] = 'There is currently %d photos in the lounge (upload buffer)';
$lang['%d photos were moved from the upload lounge to their albums'] = '%d photos were moved from the upload lounge to their albums';
+$lang['Admins only'] = 'Admins only';
// Leave this line empty
\ No newline at end of file
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index a1fd32f4e..e7613c735 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -1422,4 +1422,5 @@ $lang['If a photo in this album has the same filename, update the file without c
$lang['Empty lounge'] = 'Vider le lounge';
$lang['There is currently %d photos in the lounge (upload buffer)'] = 'Il y a actuellement %d photos dans le lounge (salle d\'attente des transferts)';
$lang['%d photos were moved from the upload lounge to their albums'] = '%d photos ont été déplacées du lounge vers leurs albums respectifs';
+$lang['Admins only'] = 'Admins uniquement';
// Leave this line empty
diff --git a/search.php b/search.php
index c7391b3f7..5ddafe471 100644
--- a/search.php
+++ b/search.php
@@ -28,38 +28,28 @@ $search = array(
);
// list of filters in user preferences
-// 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
-if (isset($conf['filters_views']))
-{
- $filters_conf = unserialize($conf['filters_views']);
-}
-else
-{
- $filters_conf = unserialize('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_views = safe_unserialize(conf_get_param('filters_views', $conf['default_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
+$filter_rename_for = array(
+ 'words' => 'allwords',
+ 'post_date' => 'date_posted',
+ 'creation_date' => 'date_created',
+ 'album' => 'cat',
+ 'file_type' => 'filetypes',
+ 'ratio' => 'ratios',
+ 'rating' => 'ratings',
+ 'file_size' => 'filesize',
);
+$filters_conf = array();
+foreach ($filters_views as $filter_name => $filter_value)
+{
+ $key = isset($filter_rename_for[$filter_name]) ? $filter_rename_for[$filter_name] : $filter_name;
+
+ $filters_conf[$key] = $filter_value;
+}
+
//get all default filters
$default_fields = array();
foreach($filters_conf as $filt_name => $filt_conf){
diff --git a/themes/default/template/include/search_filters.inc.tpl b/themes/default/template/include/search_filters.inc.tpl
index 0e3284e11..2b9091d69 100644
--- a/themes/default/template/include/search_filters.inc.tpl
+++ b/themes/default/template/include/search_filters.inc.tpl
@@ -191,11 +191,12 @@ const prefix_icon = 'gallery-icon-';
{/if}
+{if $display_filter.expert.access == 'everybody' or ($display_filter.expert.access == 'admins-only' and is_admin()) or ($display_filter.expert.access == 'registered-users' and is_classic_user())}
-
+{/if}