issue #1941 search, implement filter by file type

This commit is contained in:
plegall
2023-07-10 15:17:46 +02:00
parent 382884836a
commit 2d46924bf6
3 changed files with 26 additions and 0 deletions
+10
View File
@@ -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']).')';
+13
View File
@@ -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)
+3
View File
@@ -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'