aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2007-03-11 14:48:17 +0000
committerplegall <plg@piwigo.org>2007-03-11 14:48:17 +0000
commitb0375226c9d5f0c2133ba8fb18b523b5077acea1 (patch)
treefee8f19eea4f380081be7b6f35f6e0e0fcb8604f
parent40ca5b508f73617da61d3cac272f527a33e0fc69 (diff)
New: history can be filtered on a user.
git-svn-id: http://piwigo.org/svn/trunk@1890 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/history.php101
-rw-r--r--template/yoga/admin/history.tpl11
2 files changed, 108 insertions, 4 deletions
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 '<pre>'; print_r($search); echo '</pre>';
@@ -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 '<pre>'; print_r($page['search']); echo '</pre>';
$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.= '&nbsp;<a href="';
+ $user_string.= PHPWG_ROOT_PATH.'admin.php?page=history';
+ $user_string.= '&amp;search_id='.$page['search_id'];
+ $user_string.= '&amp;user_id='.$line['user_id'];
+ $user_string.= '">+</a>';
$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 |
diff --git a/template/yoga/admin/history.tpl b/template/yoga/admin/history.tpl
index 64c0f9535..07978ed25 100644
--- a/template/yoga/admin/history.tpl
+++ b/template/yoga/admin/history.tpl
@@ -61,6 +61,17 @@
</select>
</label>
+ <label>
+ {lang:User}
+ <select name="user">
+ <!-- BEGIN user_option -->
+ <option value="{user_option.VALUE}" {user_option.SELECTED}>
+ {user_option.CONTENT}
+ </option>
+ <!-- END user_option -->
+ </select>
+ </label>
+
<input class="submit" type="submit" name="submit" value="{lang:submit}" />
</fieldset>
</form>