aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2007-03-11 15:53:25 +0000
committerplegall <plg@piwigo.org>2007-03-11 15:53:25 +0000
commit091b30247b63966eb7ce77986f10ca40c461fd7d (patch)
tree6c98d7948e6c233a6baeb7618b0b997d5c1d4c22 /admin
parent0d28196ad453434aeaab8a459ad7fecad4ad17a4 (diff)
New: history search can be filtered on image id and filename.
git-svn-id: http://piwigo.org/svn/trunk@1892 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/history.php71
1 files changed, 60 insertions, 11 deletions
diff --git a/admin/history.php b/admin/history.php
index 0de17864d..b82fc58cc 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -71,7 +71,7 @@ check_status(ACCESS_ADMINISTRATOR);
// | Build search criteria and redirect to results |
// +-----------------------------------------------------------------------+
-$errors = array();
+$page['errors'] = array();
$search = array();
if (isset($_POST['submit']))
@@ -100,6 +100,23 @@ if (isset($_POST['submit']))
$search['fields']['types'] = $_POST['types'];
$search['fields']['user'] = $_POST['user'];
+
+ if (!empty($_POST['image_id']))
+ {
+ $search['fields']['image_id'] = intval($_POST['image_id']);
+ }
+
+ if (!empty($_POST['filename']))
+ {
+ $search['fields']['filename'] = str_replace(
+ '*',
+ '%',
+ mysql_escape_string($_POST['filename'])
+ );
+ }
+
+ // TODO manage inconsistency of having $_POST['image_id'] and
+ // $_POST['filename'] simultaneously
// echo '<pre>'; print_r($search); echo '</pre>';
@@ -123,7 +140,7 @@ INSERT INTO '.SEARCH_TABLE.'
}
else
{
- array_push($errors, $lang['search_one_clause_at_least']);
+ array_push($page['errors'], $lang['search_one_clause_at_least']);
}
}
@@ -195,6 +212,18 @@ INSERT INTO '.SEARCH_TABLE.'
);
}
+
+ if (isset($page['search']['fields']['filename']))
+ {
+ $query = '
+SELECT
+ id
+ FROM '.IMAGES_TABLE.'
+ WHERE file LIKE \''.$page['search']['fields']['filename'].'\'
+;';
+ $page['search']['image_ids'] = array_from_query($query, 'id');
+ }
+
// echo '<pre>'; print_r($page['search']); echo '</pre>';
$clauses = array();
@@ -252,6 +281,30 @@ INSERT INTO '.SEARCH_TABLE.'
'user_id = '.$page['search']['fields']['user']
);
}
+
+ if (isset($page['search']['fields']['image_id']))
+ {
+ array_push(
+ $clauses,
+ 'image_id = '.$page['search']['fields']['image_id']
+ );
+ }
+
+ if (isset($page['search']['fields']['filename']))
+ {
+ if (count($page['search']['image_ids']) == 0)
+ {
+ // a clause that is always false
+ array_push($clauses, '1 = 2 ');
+ }
+ else
+ {
+ array_push(
+ $clauses,
+ 'image_id IN ('.implode(', ', $page['search']['image_ids']).')'
+ );
+ }
+ }
$clauses = prepend_append_array_items($clauses, '(', ')');
@@ -511,15 +564,6 @@ SELECT
);
}
-// $groups_string = preg_replace(
-// '/(\d+)/e',
-// "\$groups['$1']",
-// implode(
-// ', ',
-// $local_user['groups']
-// )
-// );
-
// +-----------------------------------------------------------------------+
// | navigation bar |
// +-----------------------------------------------------------------------+
@@ -577,6 +621,9 @@ if (isset($page['search']))
{
$form['user'] = null;
}
+
+ $form['image_id'] = @$page['search']['fields']['image_id'];
+ $form['filename'] = @$page['search']['fields']['filename'];
}
else
{
@@ -599,6 +646,8 @@ $template->assign_vars(
array(
'START_YEAR' => @$form['start_year'],
'END_YEAR' => @$form['end_year'],
+ 'IMAGE_ID' => @$form['image_id'],
+ 'FILENAME' => @$form['filename'],
)
);