summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Lawrence <dkl@redhat.com>2010-02-10 18:55:38 +0100
committerDave Lawrence <dkl@redhat.com>2010-02-10 18:55:38 +0100
commit80477beb472a83f6fa711358372db9edf6209c39 (patch)
treec2bfc902d85f18527462ffff83d4060b335aece1
parentc6c99bcc594d33553921ca111f05f374330d5d4d (diff)
downloadbugzilla-80477beb472a83f6fa711358372db9edf6209c39.tar.gz
bugzilla-80477beb472a83f6fa711358372db9edf6209c39.tar.xz
Bug 310450 - Bugzilla should send an email when a comment becomes private or un-private
r=mkanat, a=mkanat
-rw-r--r--Bugzilla/Bug.pm35
-rw-r--r--Bugzilla/BugMail.pm11
-rw-r--r--Bugzilla/Comment.pm22
-rw-r--r--Bugzilla/DB/Schema.pm4
-rw-r--r--Bugzilla/Install/DB.pm3
-rw-r--r--template/en/default/bug/activity/table.html.tmpl8
6 files changed, 69 insertions, 14 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 1e418aa18..37df30707 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -798,11 +798,15 @@ sub update {
Bugzilla->user->id, $delta_ts);
}
}
-
+
+ # Comment Privacy
foreach my $comment_id (keys %{$self->{comment_isprivate} || {}}) {
$dbh->do("UPDATE longdescs SET isprivate = ? WHERE comment_id = ?",
undef, $self->{comment_isprivate}->{$comment_id}, $comment_id);
- # XXX It'd be nice to track this in the bug activity.
+ my ($from, $to)
+ = $self->{comment_isprivate}->{$comment_id} ? (0, 1) : (1, 0);
+ LogActivityEntry($self->id, "longdescs.isprivate", $from, $to,
+ Bugzilla->user->id, $delta_ts, $comment_id);
}
# Insert the values into the multiselect value tables
@@ -3142,7 +3146,8 @@ sub GetBugActivity {
my $query = "SELECT fielddefs.name, bugs_activity.attach_id, " .
$dbh->sql_date_format('bugs_activity.bug_when', '%Y.%m.%d %H:%i:%s') .
- ", bugs_activity.removed, bugs_activity.added, profiles.login_name
+ ", bugs_activity.removed, bugs_activity.added, profiles.login_name,
+ bugs_activity.comment_id
FROM bugs_activity
$suppjoins
LEFT JOIN fielddefs
@@ -3163,7 +3168,7 @@ sub GetBugActivity {
my $incomplete_data = 0;
foreach my $entry (@$list) {
- my ($fieldname, $attachid, $when, $removed, $added, $who) = @$entry;
+ my ($fieldname, $attachid, $when, $removed, $added, $who, $comment_id) = @$entry;
my %change;
my $activity_visible = 1;
@@ -3174,7 +3179,14 @@ sub GetBugActivity {
|| $fieldname eq 'deadline')
{
$activity_visible = Bugzilla->user->is_timetracker;
- } else {
+ }
+ elsif ($fieldname eq 'longdescs.isprivate'
+ && !Bugzilla->user->is_insider
+ && $added)
+ {
+ $activity_visible = 0;
+ }
+ else {
$activity_visible = 1;
}
@@ -3205,6 +3217,11 @@ sub GetBugActivity {
$change{'attachid'} = $attachid;
$change{'removed'} = $removed;
$change{'added'} = $added;
+
+ if ($comment_id) {
+ $change{'comment'} = Bugzilla::Comment->new($comment_id);
+ }
+
push (@$changes, \%change);
}
}
@@ -3219,7 +3236,7 @@ sub GetBugActivity {
# Update the bugs_activity table to reflect changes made in bugs.
sub LogActivityEntry {
- my ($i, $col, $removed, $added, $whoid, $timestamp) = @_;
+ my ($i, $col, $removed, $added, $whoid, $timestamp, $comment_id) = @_;
my $dbh = Bugzilla->dbh;
# in the case of CCs, deps, and keywords, there's a possibility that someone
# might try to add or remove a lot of them at once, which might take more
@@ -3247,9 +3264,9 @@ sub LogActivityEntry {
trick_taint($removestr);
my $fieldid = get_field_id($col);
$dbh->do("INSERT INTO bugs_activity
- (bug_id, who, bug_when, fieldid, removed, added)
- VALUES (?, ?, ?, ?, ?, ?)",
- undef, ($i, $whoid, $timestamp, $fieldid, $removestr, $addstr));
+ (bug_id, who, bug_when, fieldid, removed, added, comment_id)
+ VALUES (?, ?, ?, ?, ?, ?, ?)",
+ undef, ($i, $whoid, $timestamp, $fieldid, $removestr, $addstr, $comment_id));
}
}
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index f7af921eb..7412838f7 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -238,7 +238,8 @@ sub Send {
my $diffs = $dbh->selectall_arrayref(
"SELECT profiles.login_name, profiles.realname, fielddefs.description,
bugs_activity.bug_when, bugs_activity.removed,
- bugs_activity.added, bugs_activity.attach_id, fielddefs.name
+ bugs_activity.added, bugs_activity.attach_id, fielddefs.name,
+ bugs_activity.comment_id
FROM bugs_activity
INNER JOIN fielddefs
ON fielddefs.id = bugs_activity.fieldid
@@ -256,7 +257,7 @@ sub Send {
my $fullwho;
my @changedfields;
foreach my $ref (@$diffs) {
- my ($who, $whoname, $what, $when, $old, $new, $attachid, $fieldname) = (@$ref);
+ my ($who, $whoname, $what, $when, $old, $new, $attachid, $fieldname, $comment_id) = (@$ref);
my $diffpart = {};
if ($who ne $lastwho) {
$lastwho = $who;
@@ -279,6 +280,12 @@ sub Send {
'SELECT isprivate FROM attachments WHERE attach_id = ?',
undef, ($attachid));
}
+ if ($fieldname eq 'longdescs.isprivate') {
+ my $comment = Bugzilla::Comment->new($comment_id);
+ my $comment_num = $comment->count;
+ $what =~ s/^(Comment )?/Comment #$comment_num /;
+ $diffpart->{'isprivate'} = $new;
+ }
$difftext = three_columns($what, $old, $new);
$diffpart->{'header'} = $diffheader;
$diffpart->{'fieldname'} = $fieldname;
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm
index e81819652..300357313 100644
--- a/Bugzilla/Comment.pm
+++ b/Bugzilla/Comment.pm
@@ -188,6 +188,22 @@ sub _check_type {
return $type;
}
+sub count {
+ my ($self) = @_;
+
+ return $self->{'count'} if defined $self->{'count'};
+
+ my $dbh = Bugzilla->dbh;
+ ($self->{'count'}) = $dbh->selectrow_array(
+ "SELECT COUNT(*)
+ FROM longdescs
+ WHERE bug_id = ?
+ AND bug_when <= ?",
+ undef, $self->bug_id, $self->creation_ts);
+
+ return --$self->{'count'};
+}
+
1;
__END__
@@ -243,6 +259,10 @@ C<0> otherwise.
L<Bugzilla::User> who created the comment.
+=item C<count>
+
+C<int> The position this comment is located in the full list of comments for a bug starting from 0.
+
=item C<body_full>
=over
@@ -273,8 +293,6 @@ A string, the full text of the comment as it would be displayed to an end-user.
=back
-
-
=back
=cut
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 44d224d57..27ae3be8a 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -355,6 +355,10 @@ use constant ABSTRACT_SCHEMA => {
COLUMN => 'id'}},
added => {TYPE => 'varchar(255)'},
removed => {TYPE => 'TINYTEXT'},
+ comment_id => {TYPE => 'INT3',
+ REFERENCES => { TABLE => 'longdescs',
+ COLUMN => 'comment_id',
+ DELETE => 'CASCADE'}},
],
INDEXES => [
bugs_activity_bug_id_idx => ['bug_id'],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index d150a4e9b..65137e593 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -599,6 +599,9 @@ sub update_table_definitions {
_convert_flagtypes_fks_to_set_null();
_fix_decimal_types();
+ # 2009-11-14 dkl@redhat.com - Bug 310450
+ $dbh->bz_add_column('bugs_activity', 'comment_id', {TYPE => 'INT3'});
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
diff --git a/template/en/default/bug/activity/table.html.tmpl b/template/en/default/bug/activity/table.html.tmpl
index ee276aa20..a8ad5bfa3 100644
--- a/template/en/default/bug/activity/table.html.tmpl
+++ b/template/en/default/bug/activity/table.html.tmpl
@@ -72,7 +72,13 @@
<a href="attachment.cgi?id=[% change.attachid %]">
Attachment #[% change.attachid %]</a>
[% END %]
- [%+ field_descs.${change.fieldname} FILTER html %]
+ [% IF change.comment.defined %]
+ [% comment_desc = field_descs.${change.fieldname} %]
+ [% comment_num = "Comment $change.comment.count" FILTER bug_link(bug.bug_id, comment_num => change.comment.count) %]
+ [% comment_desc.replace('^(Comment )?', "$comment_num ") FILTER none %]
+ [% ELSE %]
+ [%+ field_descs.${change.fieldname} FILTER html %]
+ [% END %]
</td>
<td>
[% IF change.removed.defined %]