mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
issue #1941 search, implement filter by file type
This commit is contained in:
@@ -195,6 +195,16 @@ SELECT
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['fields']['filetypes']))
|
||||
{
|
||||
$filetypes_clauses = array();
|
||||
foreach ($search['fields']['filetypes'] as $ext)
|
||||
{
|
||||
$filetypes_clauses[] = 'path LIKE \'%.'.$ext.'\'';
|
||||
}
|
||||
$clauses[] = implode(' OR ', $filetypes_clauses);
|
||||
}
|
||||
|
||||
if (!empty($search['fields']['added_by']))
|
||||
{
|
||||
$clauses[] = 'added_by IN ('.implode(',', $search['fields']['added_by']).')';
|
||||
|
||||
@@ -806,6 +806,19 @@ SELECT id
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($params['filetypes']))
|
||||
{
|
||||
foreach ($params['filetypes'] as $ext)
|
||||
{
|
||||
if (!preg_match('/^[a-z0-9]+$/i', $ext))
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid parameter filetypes');
|
||||
}
|
||||
}
|
||||
|
||||
$search['fields']['filetypes'] = $params['filetypes'];
|
||||
}
|
||||
|
||||
if (isset($params['added_by']))
|
||||
{
|
||||
foreach ($params['added_by'] as $user_id)
|
||||
|
||||
@@ -1410,6 +1410,9 @@ enabled_high, registration_date, registration_date_string, registration_date_sin
|
||||
'flags' => WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
|
||||
'type' => WS_TYPE_ID,
|
||||
),
|
||||
'filetypes' => array(
|
||||
'flags' => WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
|
||||
),
|
||||
),
|
||||
'',
|
||||
$ws_functions_root . 'pwg.images.php'
|
||||
|
||||
Reference in New Issue
Block a user