diff options
Diffstat (limited to 'extensions/Needinfo')
6 files changed, 311 insertions, 0 deletions
diff --git a/extensions/Needinfo/Config.pm b/extensions/Needinfo/Config.pm new file mode 100644 index 000000000..86c99ec59 --- /dev/null +++ b/extensions/Needinfo/Config.pm @@ -0,0 +1,18 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. +package Bugzilla::Extension::Needinfo; +use strict; + +use constant NAME => 'Needinfo'; + +use constant REQUIRED_MODULES => [ +]; + +use constant OPTIONAL_MODULES => [ +]; + +__PACKAGE__->NAME; diff --git a/extensions/Needinfo/Extension.pm b/extensions/Needinfo/Extension.pm new file mode 100644 index 000000000..98644f997 --- /dev/null +++ b/extensions/Needinfo/Extension.pm @@ -0,0 +1,155 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. +package Bugzilla::Extension::Needinfo; + +use strict; + +use base qw(Bugzilla::Extension); + +use Bugzilla::User; +use Bugzilla::Flag; +use Bugzilla::FlagType; + +our $VERSION = '0.01'; + +sub install_update_db { + my ($self, $args) = @_; + my $dbh = Bugzilla->dbh; + + if (@{ Bugzilla::FlagType::match({ name => 'needinfo' }) }) { + return; + } + + print "Creating needinfo flag ... " . + "enable the Needinfo feature by editing the flag's properties.\n"; + + # Initially populate the list of exclusions as __Any__:__Any__ to + # allow admin to decide which products to enable the flag for. + my $flagtype = Bugzilla::FlagType->create({ + name => 'needinfo', + description => "Set this flag when the bug is in need of additional information", + target_type => 'bug', + cc_list => '', + sortkey => 1, + is_active => 1, + is_requestable => 1, + is_requesteeble => 1, + is_multiplicable => 0, + request_group => '', + grant_group => '', + inclusions => [], + exclusions => ['0:0'], + }); +} + +# Clear the needinfo? flag if comment is being given by +# requestee or someone used the override flag. +sub bug_start_of_update { + my ($self, $args) = @_; + my $bug = $args->{bug}; + my $old_bug = $args->{old_bug}; + + my $user = Bugzilla->user; + my $cgi = Bugzilla->cgi; + my $params = Bugzilla->input_params; + + # Set needinfo_done param to true so as to not loop back here + return if $params->{needinfo_done}; + $params->{needinfo_done} = 1; + Bugzilla->input_params($params); + + # do a match if applicable + Bugzilla::User::match_field({ + 'needinfo_from' => { 'type' => 'single' } + }); + + my $needinfo = delete $params->{needinfo}; + my $needinfo_from = delete $params->{needinfo_from}; + my $needinfo_role = delete $params->{needinfo_role}; + my $is_private = $params->{'comment_is_private'}; + + my @needinfo_overrides; + foreach my $key (grep(/^needinfo_override_/, keys %$params)) { + my ($id) = $key =~ /(\d+)$/; + # Should always be true if key exists (checkbox) but better to be sure + push(@needinfo_overrides, $id) if $id && $params->{$key}; + } + + # Set the needinfo flag if user is requesting more information + my @new_flags; + my $needinfo_requestee; + + if ($user->in_group('canconfirm') && $needinfo) { + foreach my $type (@{ $bug->flag_types }) { + next if $type->name ne 'needinfo'; + + my $needinfo_flag = { type_id => $type->id, status => '?' }; + + # Use assigned_to as requestee + if ($needinfo_role eq 'assigned_to') { + $needinfo_flag->{requestee} = $bug->assigned_to->login; + } + # Use reporter as requestee + elsif ( $needinfo_role eq 'reporter') { + $needinfo_flag->{requestee} = $bug->reporter->login; + } + # Use qa_contact as requestee + elsif ($needinfo_role eq 'qa_contact') { + $needinfo_flag->{requestee} = $bug->qa_contact->login; + } + # Use user specified requestee + elsif ($needinfo_role eq 'other' && $needinfo_from) { + Bugzilla::User->check($needinfo_from); + $needinfo_flag->{requestee} = $needinfo_from; + } + + if ($needinfo) { + push(@new_flags, $needinfo_flag); + last; + } + } + } + + # Clear the flag if bug is being closed or if additional + # information was given as requested + my @flags; + foreach my $flag (@{ $bug->flags }) { + next if $flag->type->name ne 'needinfo'; + my $clear_needinfo = 0; + + # Clear if somehow the flag has been set to +/- + $clear_needinfo = 1 if $flag->status ne '?'; + + # Clear if current user has selected override + $clear_needinfo = 1 if grep($_ == $flag->id, @needinfo_overrides); + + # Clear if bug is being closed + if (($bug->bug_status ne $old_bug->bug_status) + && !$old_bug->status->is_open) + { + $clear_needinfo = 1; + } + + # Clear if comment provided by the proper requestee + if ($bug->{added_comments} + && (!$flag->requestee || $flag->requestee->login eq Bugzilla->user->login) + && (!$is_private || $flag->setter->is_insider)) + { + $clear_needinfo = 1; + } + + if ($clear_needinfo) { + push(@flags, { id => $flag->id, status => 'X' }); + } + } + + if (@flags || @new_flags) { + $bug->set_flags(\@flags, \@new_flags); + } +} + +__PACKAGE__->NAME; diff --git a/extensions/Needinfo/template/en/default/bug/needinfo.html.tmpl b/extensions/Needinfo/template/en/default/bug/needinfo.html.tmpl new file mode 100644 index 000000000..db02df79b --- /dev/null +++ b/extensions/Needinfo/template/en/default/bug/needinfo.html.tmpl @@ -0,0 +1,98 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% needinfo_flagtype = "" %] +[% needinfo_flags = [] %] +[% can_create_needinfo = 0 %] + +[% FOREACH type = bug.flag_types %] + [% IF type.name == 'needinfo' %] + [% needinfo_flagtype = type %] + [% FOREACH flag = type.flags %] + [% IF flag.status == '?' %] + [% needinfo_flags.push(flag) %] + [% END %] + [% END %] + [% LAST IF needinfo_flagtype %] + [% END %] +[% END %] + +[% IF user.in_group('canconfirm') %] + [% IF bug.status.is_open %] + [% can_create_needinfo = 1 %] + [% ELSE %] + [% FOREACH field = Bugzilla.active_custom_fields(product=>bug.product_obj, component=>bug.component_obj, type=>2) %] + [% IF field.description.match('^status-firefox') && bug.${field.name} == 'affected' %] + [% can_create_needinfo = 1 %] + [% LAST %] + [% END %] + [% END %] + [% END %] +[% END %] + +[% IF needinfo_flagtype %] + <div id="needinfo_container"> + [% IF needinfo_flags.size > 0 %] + [%# Displays NEEDINFO tag in bug header %] + <script> + var summary_container = document.getElementById('static_bug_status'); + summary_container.appendChild(document.createTextNode('[NEEDINFO]')); + </script> + + [% FOREACH flag = needinfo_flags %] + [% IF !flag.requestee || flag.requestee.id == user.id %] + Adding a comment will automatically clear needinfo the request for + <em>[% IF !flag.requestee %]anyone[% ELSE %][% flag.requestee.login FILTER html %][% END %]</em>. + [% ELSE %] + <input type="checkbox" id="needinfo_override_[% flag.id FILTER html %]" + name="needinfo_override_[% flag.id FILTER html %]" value="1"> + <label for="needinfo_override_[% flag.id FILTER html %]"> + I am providing the requested information for <em>[% flag.requestee.login FILTER html %]</em> + (will clear the needinfo request). + </label> + [% END %] + <br> + [% END %] + [% END %] + + [% IF can_create_needinfo && (needinfo_flags.size == 0 || needinfo_flagtype.is_multiplicable) %] + <script> + function needinfoRole (select) { + YAHOO.util.Dom.get('needinfo').checked = true; + if (select.value == 'other') { + YAHOO.util.Dom.removeClass('needinfo_from_container', 'bz_default_hidden'); + YAHOO.util.Dom.get('needinfo_from').focus(); + } + else { + YAHOO.util.Dom.addClass('needinfo_from_container', 'bz_default_hidden'); + } + } + </script> + <input type="checkbox" name="needinfo" value="1" id="needinfo"> + <label for="needinfo">Need additional information from</label> + <select name="needinfo_role" id="needinfo_role" onchange="needinfoRole(this);"> + <option value="">anyone</option> + <option value="reporter">reporter</option> + <option value="assigned_to">assignee</option> + [% IF Param('useqacontact') && bug.qa_contact.login != "" %] + <option value="qa_contact">qa contact</option> + [% END %] + <option value="other">other</option> + </select> + <span id="needinfo_from_container" class="bz_default_hidden"> + [%+ INCLUDE global/userselect.html.tmpl + id => "needinfo_from" + name => "needinfo_from" + size => 30 + value => "" + %] + </span> + <br> + [% END %] + </div> +[% END %] diff --git a/extensions/Needinfo/template/en/default/hook/attachment/create-form_before_submit.html.tmpl b/extensions/Needinfo/template/en/default/hook/attachment/create-form_before_submit.html.tmpl new file mode 100644 index 000000000..ea9c17bd5 --- /dev/null +++ b/extensions/Needinfo/template/en/default/hook/attachment/create-form_before_submit.html.tmpl @@ -0,0 +1,17 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +<tr> + <td> </td> + <td> + [% PROCESS bug/needinfo.html.tmpl + bug => bug + is_attachment => 1 + %] + </td> +</tr> diff --git a/extensions/Needinfo/template/en/default/hook/attachment/edit-after_comment_textarea.html.tmpl b/extensions/Needinfo/template/en/default/hook/attachment/edit-after_comment_textarea.html.tmpl new file mode 100644 index 000000000..8f03fc752 --- /dev/null +++ b/extensions/Needinfo/template/en/default/hook/attachment/edit-after_comment_textarea.html.tmpl @@ -0,0 +1,12 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% PROCESS bug/needinfo.html.tmpl + bug => attachment.bug + is_attachment => 1 +%] diff --git a/extensions/Needinfo/template/en/default/hook/bug/edit-after_comment_commit_button.html.tmpl b/extensions/Needinfo/template/en/default/hook/bug/edit-after_comment_commit_button.html.tmpl new file mode 100644 index 000000000..90f0cc584 --- /dev/null +++ b/extensions/Needinfo/template/en/default/hook/bug/edit-after_comment_commit_button.html.tmpl @@ -0,0 +1,11 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% PROCESS bug/needinfo.html.tmpl + bug = bug +%] |