Commit 5b3ea4d4 authored by Reed Loden's avatar Reed Loden Committed by Frédéric Buclin

Bug 138546: Add a checkbox to add himself to the CC list when creating or editing an attachment

r/a=LpSolit
parent a4ef21ac
...@@ -3614,23 +3614,23 @@ sub user { ...@@ -3614,23 +3614,23 @@ sub user {
return {} if $self->{'error'}; return {} if $self->{'error'};
my $user = Bugzilla->user; my $user = Bugzilla->user;
my $prod_id = $self->{'product_id'}; my $prod_id = $self->{'product_id'};
my $unknown_privileges = $user->in_group('editbugs', $prod_id); my $editbugs = $user->in_group('editbugs', $prod_id);
my $canedit = $unknown_privileges my $is_reporter = $user->id == $self->{reporter_id} ? 1 : 0;
|| $user->id == $self->{'assigned_to'} my $is_assignee = $user->id == $self->{'assigned_to'} ? 1 : 0;
|| (Bugzilla->params->{'useqacontact'} my $is_qa_contact = Bugzilla->params->{'useqacontact'}
&& $self->{'qa_contact'} && $self->{'qa_contact'}
&& $user->id == $self->{'qa_contact'}); && $user->id == $self->{'qa_contact'} ? 1 : 0;
my $canconfirm = $unknown_privileges
|| $user->in_group('canconfirm', $prod_id); my $canedit = $editbugs || $is_assignee || $is_qa_contact;
my $isreporter = $user->id my $canconfirm = $editbugs || $user->in_group('canconfirm', $prod_id);
&& $user->id == $self->{reporter_id}; my $has_any_role = $is_reporter || $is_assignee || $is_qa_contact;
$self->{'user'} = {canconfirm => $canconfirm, $self->{'user'} = {canconfirm => $canconfirm,
canedit => $canedit, canedit => $canedit,
isreporter => $isreporter}; isreporter => $is_reporter,
has_any_role => $has_any_role};
return $self->{'user'}; return $self->{'user'};
} }
......
...@@ -574,6 +574,8 @@ sub insert { ...@@ -574,6 +574,8 @@ sub insert {
$owner = $bug->assigned_to->login; $owner = $bug->assigned_to->login;
$bug->set_assigned_to($user); $bug->set_assigned_to($user);
} }
$bug->add_cc($user) if $cgi->param('addselfcc');
$bug->update($timestamp); $bug->update($timestamp);
$dbh->bz_commit_transaction; $dbh->bz_commit_transaction;
...@@ -686,6 +688,8 @@ sub update { ...@@ -686,6 +688,8 @@ sub update {
extra_data => $attachment->id }); extra_data => $attachment->id });
} }
$bug->add_cc($user) if $cgi->param('addselfcc');
if ($can_edit) { if ($can_edit) {
my ($flags, $new_flags) = my ($flags, $new_flags) =
Bugzilla::Flag->extract_flags_from_cgi($bug, $attachment, $vars); Bugzilla::Flag->extract_flags_from_cgi($bug, $attachment, $vars);
......
...@@ -92,6 +92,15 @@ TUI_hide_default('attachment_text_field'); ...@@ -92,6 +92,15 @@ TUI_hide_default('attachment_text_field');
cols = constants.COMMENT_COLS cols = constants.COMMENT_COLS
wrap = 'soft' wrap = 'soft'
%] %]
[% IF NOT bug.cc || NOT bug.cc.contains(user.login) %]
<br>
<input type="checkbox" id="addselfcc" name="addselfcc"
[%~ ' checked="checked"'
IF user.settings.state_addselfcc.value == 'always'
|| (!bug.user.has_any_role
&& user.settings.state_addselfcc.value == 'cc_unless_role') %]>
<label for="addselfcc">Add me to CC list</label>
[% END %]
</td> </td>
</tr> </tr>
[% IF user.is_insider %] [% IF user.is_insider %]
......
...@@ -253,10 +253,18 @@ ...@@ -253,10 +253,18 @@
minrows = 10 minrows = 10
cols = 80 cols = 80
wrap = 'soft' wrap = 'soft'
classes = classNames classes = classNames
%] %]
[% IF NOT attachment.bug.cc || NOT attachment.bug.cc.contains(user.login) %]
<input type="checkbox" id="addselfcc" name="addselfcc"
[%~ ' checked="checked"'
IF user.settings.state_addselfcc.value == 'always'
|| (!attachment.bug.user.has_any_role
&& user.settings.state_addselfcc.value == 'cc_unless_role') %]>
<label for="addselfcc">Add me to CC list</label>
[% END %]
</div> </div>
[% END %] [% END %]
<div id="attachment_flags"> <div id="attachment_flags">
[% IF attachment.flag_types.size > 0 %] [% IF attachment.flag_types.size > 0 %]
[% PROCESS "flag/list.html.tmpl" flag_types = attachment.flag_types [% PROCESS "flag/list.html.tmpl" flag_types = attachment.flag_types
......
...@@ -722,15 +722,10 @@ ...@@ -722,15 +722,10 @@
<td> <td>
[% IF user.id %] [% IF user.id %]
[% IF NOT bug.cc || NOT bug.cc.contains(user.login) %] [% IF NOT bug.cc || NOT bug.cc.contains(user.login) %]
[% has_role = bug.user.isreporter
|| bug.assigned_to.id == user.id
|| (Param('useqacontact')
&& bug.qa_contact
&& bug.qa_contact.id == user.id) %]
<input type="checkbox" id="addselfcc" name="addselfcc" <input type="checkbox" id="addselfcc" name="addselfcc"
[% " checked=\"checked\"" [% " checked=\"checked\""
IF user.settings.state_addselfcc.value == 'always' IF user.settings.state_addselfcc.value == 'always'
|| (!has_role || (!bug.user.has_any_role
&& user.settings.state_addselfcc.value == 'cc_unless_role') %]> && user.settings.state_addselfcc.value == 'cc_unless_role') %]>
<label for="addselfcc">Add me to CC list</label> <label for="addselfcc">Add me to CC list</label>
<br> <br>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment