summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDexter Morgan <dmorgan@mageia.org>2013-03-15 21:00:11 +0000
committerDexter Morgan <dmorgan@mageia.org>2013-03-15 21:00:11 +0000
commit13c9410efa21716979c01358ae9b81473fa970e4 (patch)
tree0481558a480d782d4fdbe1bf7db35051b10ed2d8
parent549bd6b0e3fa182d3eff47e67d4f1ab2729dd21d (diff)
downloadbugzilla-13c9410efa21716979c01358ae9b81473fa970e4.tar
bugzilla-13c9410efa21716979c01358ae9b81473fa970e4.tar.gz
bugzilla-13c9410efa21716979c01358ae9b81473fa970e4.tar.bz2
bugzilla-13c9410efa21716979c01358ae9b81473fa970e4.tar.xz
bugzilla-13c9410efa21716979c01358ae9b81473fa970e4.zip
Update extension to fix bu 2225 ( from Frédéric Buclin)
-rw-r--r--Extension.pm64
1 files changed, 63 insertions, 1 deletions
diff --git a/Extension.pm b/Extension.pm
index 1ebd30b..4141e7c 100644
--- a/Extension.pm
+++ b/Extension.pm
@@ -9,12 +9,74 @@ package Bugzilla::Extension::Mageia;
use strict;
use base qw(Bugzilla::Extension);
+use Bugzilla::Bug;
+use Bugzilla::Field;
use Bugzilla::User;
use Bugzilla::Extension::Mageia::Util;
use Email::Address;
-our $VERSION = '0.02';
+our $VERSION = '0.10';
+
+# sysadmin-bugs@ml.mageia.org user ID = 175.
+use constant SYSADMIN_USER_ID => 175;
+
+sub bug_end_of_create_validators {
+ my ($self, $args) = @_;
+
+ # If a user enters 'validated_update' as keyword,
+ # automatically CC sysadmin-bugs@ml.mageia.org.
+ my $keywords = $args->{params}->{keywords};
+
+ if (grep { $_->name eq 'validated_update' } @$keywords) {
+ my $cc_list = $args->{params}->{cc};
+ if (!grep { $_ == SYSADMIN_USER_ID } @$cc_list) {
+ push(@$cc_list, SYSADMIN_USER_ID);
+ }
+ }
+}
+
+sub bug_end_of_update {
+ my ($self, $args) = @_;
+ my $bug = $args->{bug};
+ my $dbh = Bugzilla->dbh;
+
+ # If a user enters 'validated_update' as keyword,
+ # automatically CC sysadmin-bugs@ml.mageia.org.
+ my $new_keywords_str = $args->{changes}->{keywords}->[1];
+
+ if ($new_keywords_str) {
+ my @new_keywords = split(/[,\s]+/, $new_keywords_str);
+ if (grep { $_ eq 'validated_update' } @new_keywords) {
+ if (!grep { $_->id == SYSADMIN_USER_ID } @{$bug->cc_users}) {
+ # Safer to clear the cache and let Bugzilla regenerate them if needed.
+ delete $bug->{cc_users};
+ delete $bug->{cc};
+ $dbh->do('INSERT INTO cc (bug_id, who) VALUES (?, ?)',
+ undef, ($bug->id, SYSADMIN_USER_ID));
+
+ # We also have to update the bug history to reflect this change.
+ my $changed_cc = $args->{changes}->{cc};
+ my $sysadmin_login = user_id_to_login(SYSADMIN_USER_ID);
+
+ if ($changed_cc->[1]) {
+ $changed_cc->[1] .= ", $sysadmin_login";
+ }
+ else {
+ $changed_cc->[1] = $sysadmin_login;
+ }
+
+ my $field_id = get_field_id('cc');
+ $dbh->do('DELETE FROM bugs_activity
+ WHERE bug_id = ? AND bug_when = ? AND fieldid = ?',
+ undef, ($bug->id, $args->{timestamp}, $field_id));
+
+ LogActivityEntry($bug->id, 'cc', $changed_cc->[0] || '', $changed_cc->[1],
+ Bugzilla->user->id, $args->{timestamp});
+ }
+ }
+ }
+}
sub mailer_before_send {
my ($self, $args) = @_;