mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
issue #2106 added details to search history
API method modification `ws_history_search`: Added a new property in API return `SEARCH_DETAILS` only for searches. These details are displayed on the `History` page in the `Search` section.
This commit is contained in:
@@ -798,6 +798,7 @@ SELECT rules
|
||||
$category_ids = array();
|
||||
$image_ids = array();
|
||||
$has_tags = false;
|
||||
$search_ids = array();
|
||||
|
||||
foreach ($data as $row)
|
||||
{
|
||||
@@ -818,10 +819,51 @@ SELECT rules
|
||||
$has_tags = true;
|
||||
}
|
||||
|
||||
if (isset($row['search_id']))
|
||||
{
|
||||
array_push($search_ids, $row['search_id']);
|
||||
}
|
||||
|
||||
$history_lines[] = $row;
|
||||
}
|
||||
|
||||
// prepare reference data (users, tags, categories...)
|
||||
if (count($search_ids) > 0)
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
id,
|
||||
rules
|
||||
FROM '.SEARCH_TABLE.'
|
||||
WHERE id IN ('.implode(',', $search_ids).')
|
||||
;';
|
||||
$search_details = query2array($query, 'id', 'rules');
|
||||
|
||||
foreach ($search_details as $id_search => $rules_search)
|
||||
{
|
||||
$rules_search = safe_unserialize($rules_search)['fields'];
|
||||
if (!empty($rules_search['tags']['words']))
|
||||
{
|
||||
$has_tags = true;
|
||||
}
|
||||
|
||||
if (!empty($rules_search['cat']['words']))
|
||||
{
|
||||
$category_ids = array_merge($category_ids, $rules_search['cat']['words']);
|
||||
}
|
||||
|
||||
if(!empty($rules_search['added_by']))
|
||||
{
|
||||
foreach ($rules_search['added_by'] as $key)
|
||||
{
|
||||
$user_ids[$key] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$search_details[$id_search] = $rules_search;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($user_ids) > 0)
|
||||
{
|
||||
$query = '
|
||||
@@ -1011,6 +1053,23 @@ SELECT
|
||||
.'" alt="'.$image_title.'" title="'.$image_title.'">';
|
||||
}
|
||||
|
||||
if (isset($line['search_id']))
|
||||
{
|
||||
$search_detail = array(
|
||||
'allwords' => !empty($search_details[$line['search_id']]['allwords']['words']) ? $search_details[$line['search_id']]['allwords']['words'] : null,
|
||||
'tags' => !empty($search_details[$line['search_id']]['tags']['words']) ? array_intersect_key($name_of_tag, array_flip($search_details[$line['search_id']]['tags']['words'])) : null,
|
||||
'date_posted' => !empty($search_details[$line['search_id']]['date_posted']) ? $search_details[$line['search_id']]['date_posted'] : null,
|
||||
'cat' => !empty($search_details[$line['search_id']]['cat']['words']) ? array_intersect_key($name_of_category, array_flip($search_details[$line['search_id']]['cat']['words'])) : null,
|
||||
'author' => !empty($search_details[$line['search_id']]['author']['words']) ? $search_details[$line['search_id']]['author']['words'] : null,
|
||||
'added_by' => !empty($search_details[$line['search_id']]['added_by']) ? array_intersect_key($username_of, array_flip($search_details[$line['search_id']]['added_by'])) : null,
|
||||
'filetypes' => !empty($search_details[$line['search_id']]['filetypes']) ? $search_details[$line['search_id']]['filetypes'] : null,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_detail = null;
|
||||
}
|
||||
|
||||
@$sorted_members[$user_name] += 1;
|
||||
|
||||
array_push(
|
||||
@@ -1033,6 +1092,7 @@ SELECT
|
||||
'SEARCH_ID' => $line['search_id'] ?? null,
|
||||
'TAGS' => explode(",",$tag_names),
|
||||
'TAGIDS' => explode(",",$tag_ids),
|
||||
'SEARCH_DETAILS' => $search_detail,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user