summaryrefslogtreecommitdiffstats
path: root/extensions/REMO/Extension.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2015-02-10 02:00:55 +0100
committerDylan William Hardison <dylan@hardison.net>2015-02-24 03:56:34 +0100
commitf193116a4f38a4d3c8a9e5f7da3006a6f006448d (patch)
tree301bd63c396dc9ded15de2f1f7c34938729d82a9 /extensions/REMO/Extension.pm
parentfab5c126b317996c6802d175e196ac11f0171d73 (diff)
downloadbugzilla-f193116a4f38a4d3c8a9e5f7da3006a6f006448d.tar.gz
bugzilla-f193116a4f38a4d3c8a9e5f7da3006a6f006448d.tar.xz
Bug 1123275 - Changes to form.reps.mentorship (DRAFT)
Diffstat (limited to 'extensions/REMO/Extension.pm')
-rw-r--r--extensions/REMO/Extension.pm30
1 files changed, 27 insertions, 3 deletions
diff --git a/extensions/REMO/Extension.pm b/extensions/REMO/Extension.pm
index b436d09d3..ab39a45dc 100644
--- a/extensions/REMO/Extension.pm
+++ b/extensions/REMO/Extension.pm
@@ -28,6 +28,7 @@ use Bugzilla::Constants;
use Bugzilla::Util qw(trick_taint trim detaint_natural);
use Bugzilla::Token;
use Bugzilla::Error;
+use List::Util qw(first);
our $VERSION = '0.01';
@@ -243,9 +244,11 @@ sub post_bug_after_creation {
my $bug = $vars->{bug};
my $template = Bugzilla->template;
- if (Bugzilla->input_params->{format}
- && Bugzilla->input_params->{format} eq 'remo-swag')
- {
+ my $format = Bugzilla->input_params->{format};
+
+ return unless defined $format;
+
+ if ($format eq 'remo-swag') {
# If the attachment cannot be successfully added to the bug,
# we notify the user, but we don't interrupt the bug creation process.
my $error_mode_cache = Bugzilla->error_mode;
@@ -304,6 +307,27 @@ sub post_bug_after_creation {
Bugzilla->error_mode($error_mode_cache);
}
+
+ elsif ($format eq 'mozreps') {
+ my $needinfo_type = first { $_->name eq 'needinfo' } @{$bug->flag_types};
+ return unless $needinfo_type;
+ my %original_cc = map { $_ => 1 } Bugzilla->cgi->param('cc');
+ my @cc_users = grep { $_->is_enabled && $original_cc{$_->login}} @{$bug->cc_users};
+ my @new_flags = map {
+ { type_id => $needinfo_type->id,
+ status => '?',
+ requestee => $_->login }
+ } @cc_users;
+
+ $bug->set_flags(\@new_flags, []) if @new_flags;
+ $bug->add_comment(
+ join(", ", map { $_->realname || $_->login_name } @cc_users) .
+ ": You have been added as supporter to this Reps application, please comment why do you endorse their application. Thanks!"
+ );
+
+ $bug->update($bug->creation_ts);
+ Bugzilla::BugMail::Send($bug->id, { changer => Bugzilla->user });
+ }
}
__PACKAGE__->NAME;