mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 09:13:02 +02:00
fixes #1968 new values for date_posted filter
* add 24h, 3m and yNNNN (year 2023 or 2022...) * remove 1y * provide labels from backend instead of managing it in javascript
This commit is contained in:
@@ -268,12 +268,23 @@ SELECT
|
||||
if (!empty($search['fields']['date_posted']))
|
||||
{
|
||||
$options = array(
|
||||
'24h' => '24 HOUR',
|
||||
'7d' => '7 DAY',
|
||||
'30d' => '30 DAY',
|
||||
'3m' => '3 MONTH',
|
||||
'6m' => '6 MONTH',
|
||||
'1y' => '1 YEAR',
|
||||
);
|
||||
$clauses[] = 'date_available > SUBDATE(NOW(), INTERVAL '.$options[ $search['fields']['date_posted'] ].')';
|
||||
|
||||
if (isset($options[ $search['fields']['date_posted'] ]))
|
||||
{
|
||||
$clauses[] = 'date_available > SUBDATE(NOW(), INTERVAL '.$options[ $search['fields']['date_posted'] ].')';
|
||||
}
|
||||
elseif (preg_match('/^y(\d+)$/', $search['fields']['date_posted'], $matches))
|
||||
{
|
||||
// that is for y2023 = all photos posted in 2022
|
||||
$clauses[] = 'YEAR(date_available) = '.$matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['fields']['filetypes']))
|
||||
|
||||
@@ -838,7 +838,7 @@ function ws_images_filteredSearch_update($params, $service)
|
||||
|
||||
if (isset($params['date_posted']))
|
||||
{
|
||||
if (!preg_match('/^(7d|30d|6m|1y|)$/', $params['date_posted']))
|
||||
if (!preg_match('/^(24h|7d|30d|3m|6m|y\d+|)$/', $params['date_posted']))
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid parameter date_posted');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user