From b0375226c9d5f0c2133ba8fb18b523b5077acea1 Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 11 Mar 2007 14:48:17 +0000 Subject: New: history can be filtered on a user. git-svn-id: http://piwigo.org/svn/trunk@1890 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/history.php | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 4 deletions(-) (limited to 'admin/history.php') diff --git a/admin/history.php b/admin/history.php index 07ecd2885..e1e3d604c 100644 --- a/admin/history.php +++ b/admin/history.php @@ -98,6 +98,8 @@ if (isset($_POST['submit'])) } $search['fields']['types'] = $_POST['types']; + + $search['fields']['user'] = $_POST['user']; // echo '
'; print_r($search); echo '
'; @@ -169,6 +171,30 @@ SELECT rules $page['search'] = unserialize($serialized_rules); + if (isset($_GET['user_id'])) + { + if (!is_numeric($_GET['user_id'])) + { + die('user_id GET parameter must be an integer value'); + } + + $page['search']['fields']['user'] = $_GET['user_id']; + + $query =' +INSERT INTO '.SEARCH_TABLE.' + (rules) + VALUES + (\''.serialize($page['search']).'\') +;'; + pwg_query($query); + + $search_id = mysql_insert_id(); + + redirect( + PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id + ); + } + // echo '
'; print_r($page['search']); echo '
'; $clauses = array(); @@ -217,6 +243,15 @@ SELECT rules ); } } + + if (isset($page['search']['fields']['user']) + and $page['search']['fields']['user'] != -1) + { + array_push( + $clauses, + 'user_id = '.$page['search']['fields']['user'] + ); + } $clauses = prepend_append_array_items($clauses, '(', ')'); @@ -377,16 +412,28 @@ SELECT { continue; } + + $user_string = ''; + if (isset($username_of[$line['user_id']])) + { + $user_string.= $username_of[$line['user_id']]; + } + else + { + $user_string.= $line['user_id']; + } + $user_string.= ' +'; $template->assign_block_vars( 'detail', array( 'DATE' => $line['date'], 'TIME' => $line['time'], - 'USER' => isset($username_of[$line['user_id']]) - ? $username_of[$line['user_id']] - : $line['user_id'] - , + 'USER' => $user_string, 'IP' => $line['IP'], 'IMAGE' => isset($line['image_id']) ? ( isset($label_of_image[$line['image_id']]) @@ -479,6 +526,15 @@ if (isset($page['search'])) } $form['types'] = $page['search']['fields']['types']; + + if (isset($page['search']['fields']['user'])) + { + $form['user'] = $page['search']['fields']['user']; + } + else + { + $form['user'] = null; + } } else { @@ -522,6 +578,43 @@ foreach ($types as $option) ) ); } + +$template->assign_block_vars( + 'user_option', + array( + 'VALUE'=> -1, + 'CONTENT' => '------------', + 'SELECTED' => '' + ) + ); + +$query = ' +SELECT + '.$conf['user_fields']['id'].' AS id, + '.$conf['user_fields']['username'].' AS username + FROM '.USERS_TABLE.' + ORDER BY username ASC +;'; +$result = pwg_query($query); + +while ($row = mysql_fetch_array($result)) +{ + $selected = ''; + + if ($row['id'] == $form['user']) + { + $selected = 'selected="selected"'; + } + + $template->assign_block_vars( + 'user_option', + array( + 'VALUE' => $row['id'], + 'CONTENT' => $row['username'], + 'SELECTED' => $selected, + ) + ); +} // +-----------------------------------------------------------------------+ // | html code display | -- cgit v1.2.3