]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 138546: Add a checkbox to add himself to the CC list when creating or editing...
authorReed Loden <reed@reedloden.com>
Tue, 26 Jun 2012 15:20:26 +0000 (17:20 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 26 Jun 2012 15:20:26 +0000 (17:20 +0200)
r/a=LpSolit

Bugzilla/Bug.pm
attachment.cgi
template/en/default/attachment/create.html.tmpl
template/en/default/attachment/edit.html.tmpl
template/en/default/bug/edit.html.tmpl

index 1bf5a11cd5f4e7d08660ba6fee25d1780a58c490..3d9689acaaf9d4e8b4e3f267aec64fc39a2cfbcd 100644 (file)
@@ -3614,23 +3614,23 @@ sub user {
     return {} if $self->{'error'};
 
     my $user = Bugzilla->user;
-
     my $prod_id = $self->{'product_id'};
 
-    my $unknown_privileges = $user->in_group('editbugs', $prod_id);
-    my $canedit = $unknown_privileges
-                  || $user->id == $self->{'assigned_to'}
-                  || (Bugzilla->params->{'useqacontact'}
-                      && $self->{'qa_contact'}
-                      && $user->id == $self->{'qa_contact'});
-    my $canconfirm = $unknown_privileges
-                     || $user->in_group('canconfirm', $prod_id);
-    my $isreporter = $user->id
-                     && $user->id == $self->{reporter_id};
+    my $editbugs = $user->in_group('editbugs', $prod_id);
+    my $is_reporter = $user->id == $self->{reporter_id} ? 1 : 0;
+    my $is_assignee = $user->id == $self->{'assigned_to'} ? 1 : 0;
+    my $is_qa_contact = Bugzilla->params->{'useqacontact'}
+                        && $self->{'qa_contact'}
+                        && $user->id == $self->{'qa_contact'} ? 1 : 0;
+
+    my $canedit = $editbugs || $is_assignee || $is_qa_contact;
+    my $canconfirm = $editbugs || $user->in_group('canconfirm', $prod_id);
+    my $has_any_role = $is_reporter || $is_assignee || $is_qa_contact;
 
     $self->{'user'} = {canconfirm => $canconfirm,
                        canedit    => $canedit,
-                       isreporter => $isreporter};
+                       isreporter => $is_reporter,
+                       has_any_role => $has_any_role};
     return $self->{'user'};
 }
 
index 92f48d05d52f94deea017a96f14915f620b5d5fa..16c964e477d4942f09a47758557db5c4c89bf6fb 100755 (executable)
@@ -574,6 +574,8 @@ sub insert {
       $owner = $bug->assigned_to->login;
       $bug->set_assigned_to($user);
   }
+
+  $bug->add_cc($user) if $cgi->param('addselfcc');
   $bug->update($timestamp);
 
   $dbh->bz_commit_transaction;
@@ -686,6 +688,8 @@ sub update {
                                       extra_data => $attachment->id });
     }
 
+    $bug->add_cc($user) if $cgi->param('addselfcc');
+
     if ($can_edit) {
         my ($flags, $new_flags) =
           Bugzilla::Flag->extract_flags_from_cgi($bug, $attachment, $vars);
index 97408deac5c7c8458bea86f55de73b2f6c7e6a57..8f5477e2302e78a3c507e5000f863bc2d8ac54e8 100644 (file)
@@ -92,6 +92,15 @@ TUI_hide_default('attachment_text_field');
           cols    = constants.COMMENT_COLS
           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>
     </tr>
     [% IF user.is_insider %]
index c6ee527a50dbd46cc75034c2b998af6fd932eaaa..2062e6d6cc458a9253845bee269468bc7957352f 100644 (file)
               minrows = 10
               cols    = 80
               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>
-        [% END %]             
+        [% END %]
         <div id="attachment_flags">
           [% IF attachment.flag_types.size > 0 %]
               [% PROCESS "flag/list.html.tmpl" flag_types = attachment.flag_types
index ba36d0a2f34132b32161f79db454a6c9d3a2f8e0..9295e178ca318eac1cabc8d2c30153c69b5a6eb9 100644 (file)
       <td>
         [% IF user.id %]
           [% 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"
               [% " checked=\"checked\""
                    IF user.settings.state_addselfcc.value == 'always'
-                      || (!has_role
+                      || (!bug.user.has_any_role
                           && user.settings.state_addselfcc.value == 'cc_unless_role') %]>
             <label for="addselfcc">Add me to CC list</label>
             <br>