From 091b30247b63966eb7ce77986f10ca40c461fd7d Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 11 Mar 2007 15:53:25 +0000 Subject: 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 --- admin/history.php | 71 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 11 deletions(-) (limited to 'admin') 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 '
'; print_r($search); echo '
'; @@ -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 '
'; print_r($page['search']); echo '
'; $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'], ) ); -- cgit v1.2.3