summaryrefslogtreecommitdiffstats
path: root/editusers.cgi
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-08-17 06:11:48 +0200
committerByron Jones <glob@mozilla.com>2015-08-17 06:11:48 +0200
commit3431a53797bc024dab0b2db201e863460c908db0 (patch)
treee3e8ad5261207e87cd9e8383497ef9bd7c11394e /editusers.cgi
parent6f08830062695fbb7c2e1db6cad451e2fb8efd94 (diff)
downloadbugzilla-3431a53797bc024dab0b2db201e863460c908db0.tar.gz
bugzilla-3431a53797bc024dab0b2db201e863460c908db0.tar.xz
Bug 1193190 - 'view account history' on edituser should include audit_log entries
Diffstat (limited to 'editusers.cgi')
-rwxr-xr-xeditusers.cgi66
1 files changed, 53 insertions, 13 deletions
diff --git a/editusers.cgi b/editusers.cgi
index b6f5a6c52..e153cfbbc 100755
--- a/editusers.cgi
+++ b/editusers.cgi
@@ -672,20 +672,60 @@ if ($action eq 'search') {
($activity_userid, $activity_who) = ($activity_who, $activity_userid);
}
- $vars->{'profile_changes'} = $dbh->selectall_arrayref(
- "SELECT profiles.login_name AS who, " .
- $dbh->sql_date_format('profiles_activity.profiles_when') . " AS activity_when,
- fielddefs.name AS what,
- profiles_activity.oldvalue AS removed,
- profiles_activity.newvalue AS added
- FROM profiles_activity
- INNER JOIN profiles ON $activity_who = profiles.userid
- INNER JOIN fielddefs ON fielddefs.id = profiles_activity.fieldid
- WHERE $activity_userid = ?
- ORDER BY profiles_activity.profiles_when",
- {'Slice' => {}},
- $otherUser->id);
+ my $sql = "
+ SELECT
+ profiles.login_name AS who,
+ " . $dbh->sql_date_format('profiles_activity.profiles_when') . " AS activity_when,
+ fielddefs.name AS what,
+ profiles_activity.oldvalue AS removed,
+ profiles_activity.newvalue AS added
+ FROM
+ profiles_activity
+ INNER JOIN profiles ON $activity_who = profiles.userid
+ INNER JOIN fielddefs ON fielddefs.id = profiles_activity.fieldid
+ WHERE
+ $activity_userid = ?
+ ";
+ my @values = ($otherUser->id);
+
+ if ($action ne 'admin_activity') {
+ $sql .= "
+ UNION ALL
+
+ SELECT
+ COALESCE(profiles.login_name, '-') AS who,
+ " . $dbh->sql_date_format('audit_log.at_time') . " AS activity_when,
+ field AS what,
+ removed,
+ added
+ FROM
+ audit_log
+ LEFT JOIN profiles ON profiles.userid = audit_log.user_id
+ WHERE
+ audit_log.object_id = ?
+ AND audit_log.class = 'Bugzilla::User'
+ AND audit_log.field != 'last_activity_ts'
+ ";
+ push @values, $otherUser->id;
+ }
+
+ $sql .= " ORDER BY activity_when";
+
+ # massage some fields to improve readability
+ my $profile_changes = $dbh->selectall_arrayref($sql, { Slice => {} }, @values);
+ foreach my $change (@$profile_changes) {
+ if ($change->{what} eq 'cryptpassword') {
+ $change->{what} = 'password';
+ $change->{removed} = '';
+ $change->{added} = '(updated)';
+ }
+ elsif ($change->{what} eq 'public_key') {
+ $change->{removed} = '(updated)' if $change->{removed} ne '';
+ $change->{added} = '(updated)' if $change->{added} ne '';
+ }
+ }
+ $vars->{'profile_changes'} = $profile_changes;
$vars->{'otheruser'} = $otherUser;
$vars->{'action'} = $action;