]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 277370: Ability to specify an email address to which notification about all bugs...
authorolav%bkor.dhs.org <>
Tue, 14 Nov 2006 07:32:28 +0000 (07:32 +0000)
committerolav%bkor.dhs.org <>
Tue, 14 Nov 2006 07:32:28 +0000 (07:32 +0000)
Patch by Guillaume Rousse <guillomovitch@zarb.org> r=bkor a=myk

Bugzilla/BugMail.pm
Bugzilla/Config/MTA.pm
Bugzilla/Constants.pm
Bugzilla/User.pm
docs/xml/administration.xml
editparams.cgi
template/en/default/admin/params/mta.html.tmpl
template/en/default/email/newchangedmail.txt.tmpl

index f5ad7c095f6d4f24196417a796a06cb83188f893..9a83b1cd3da7916169e1a278bb1f5720c8929645 100644 (file)
@@ -50,11 +50,12 @@ use constant BIT_WATCHING  => 2;
 # We need these strings for the X-Bugzilla-Reasons header
 # Note: this hash uses "," rather than "=>" to avoid auto-quoting of the LHS.
 use constant REL_NAMES => {
-    REL_ASSIGNEE, "AssignedTo", 
-    REL_REPORTER, "Reporter",
-    REL_QA      , "QAcontact",
-    REL_CC      , "CC",
-    REL_VOTER   , "Voter"
+    REL_ASSIGNEE      , "AssignedTo", 
+    REL_REPORTER      , "Reporter",
+    REL_QA            , "QAcontact",
+    REL_CC            , "CC",
+    REL_VOTER         , "Voter",
+    REL_GLOBAL_WATCHER, "GlobalWatcher"
 };
 
 sub FormatTriple {
@@ -392,7 +393,15 @@ sub Send {
             push (@{$watching{$watch->[0]}}, $watch->[1]);
         }
     }
-        
+
+    # Global watcher
+    my @watchers = split(/[,\s]+/, Bugzilla->params->{'globalwatchers'});
+    foreach (@watchers) {
+        my $watcher_id = login_to_id($_);
+        next unless $watcher_id;
+        $recipients{$watcher_id}->{+REL_GLOBAL_WATCHER} = BIT_DIRECT;
+    }
+
     # We now have a complete set of all the users, and their relationships to
     # the bug in question. However, we are not necessarily going to mail them
     # all - there are preferences, permissions checks and all sorts to do yet.
index a9bc4619c892c21412e3cae4e83c691a010289c2..27d03462acb59a71c2c8fb0ef69775accbd6d560 100644 (file)
@@ -72,7 +72,13 @@ sub get_param_list {
    type => 't',
    default => 7,
    checker => \&check_numeric
-  } );
+  },
+  
+  {
+   name => 'globalwatchers',
+   type => 't',
+   default => '',
+  }, );
   return @param_list;
 }
 
index 9c2cf77b4ce37e3fbe60997fda16486c96956a85..ec1467136597eedcfc5c426d646c541a62de06da 100644 (file)
@@ -85,7 +85,7 @@ use File::Basename;
     THROW_ERROR
     
     RELATIONSHIPS
-    REL_ASSIGNEE REL_QA REL_REPORTER REL_CC REL_VOTER 
+    REL_ASSIGNEE REL_QA REL_REPORTER REL_CC REL_VOTER REL_GLOBAL_WATCHER
     REL_ANY
     
     POS_EVENTS
@@ -244,9 +244,10 @@ use constant REL_QA                 => 1;
 use constant REL_REPORTER           => 2;
 use constant REL_CC                 => 3;
 use constant REL_VOTER              => 4;
+use constant REL_GLOBAL_WATCHER     => 5;
 
 use constant RELATIONSHIPS => REL_ASSIGNEE, REL_QA, REL_REPORTER, REL_CC, 
-                              REL_VOTER;
+                              REL_VOTER, REL_GLOBAL_WATCHER;
                               
 # Used for global events like EVT_FLAG_REQUESTED
 use constant REL_ANY                => 100;
index ff61034ddd3aaf27bdb070f33ef22b4afa894bd4..3c18f190820bb4661dddeec9d016ed3190e6260c 100644 (file)
@@ -1460,6 +1460,9 @@ sub wants_mail {
     
     # No mail if there are no events
     return 0 if !scalar(@$events);
+
+    # Skip DB query if relationship is explicit
+    return 1 if $relationship == REL_GLOBAL_WATCHER;
     
     my $dbh = Bugzilla->dbh;
     
index 17ffacc4463d699d492a1a17303881a50910fc46..f22523026aba2e6490e5d868d497d725ee5484cd 100644 (file)
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term>
+          globalwatcher
+        </term>
+        <listitem>
+          <para>
+            This allows to define specific users that will
+            receive notification each time a new bug in entered, or when
+            an existing bug changes, according to the normal groupset
+            permissions. It may be useful for sending notifications to a
+            mailing-list, for instance.
+          </para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term>
           usestatuswhiteboard
index cbce6405f0aff2634014796a9eb9b132eb450707..80b458d909a77e57123c3cb61795dc72af6c87f4 100755 (executable)
@@ -32,6 +32,7 @@ use Bugzilla::Config::Common;
 use Bugzilla::Util;
 use Bugzilla::Error;
 use Bugzilla::Token;
+use Bugzilla::User;
 
 my $user = Bugzilla->login(LOGIN_REQUIRED);
 my $cgi = Bugzilla->cgi;
@@ -116,6 +117,15 @@ if ($action eq 'save' && $current_module) {
                 if ($ok ne "") {
                     ThrowUserError('invalid_parameter', { name => $name, err => $ok });
                 }
+            } elsif ($name eq 'globalwatchers') {
+                # can't check this as others, as Bugzilla::Config::Common
+                # can not use Bugzilla::User
+                foreach my $watcher (split(/[,\s]+/, $value)) {
+                    ThrowUserError(
+                        'invalid_parameter',
+                        { name => $name, err => "no such user $watcher" }
+                    ) unless login_to_id($watcher);
+                }
             }
             push(@changes, $name);
             SetParam($name, $value);
index 224d215447ba2921b3315865fcdfabc60193c7b7..778f81d0aadce3333011677d20145014fc916a22 100644 (file)
@@ -58,6 +58,9 @@
 
   whinedays => "The number of days that we'll let a $terms.bug sit untouched in a NEW " _
                "state before our cronjob will whine at the owner.<br> " _
-               "Set to 0 to disable whining." }
+               "Set to 0 to disable whining.",
+
+  globalwatchers => "A comma-separated list of users who should receive a " _
+                    "copy of every notification mail the system sends." }
 
 %]
index ad7d564b4cf968974e0ba28db15b29f3c7c7c8a3..d9962496b956449bfc0972a5ce7f9f8b34c5d392 100644 (file)
@@ -57,6 +57,8 @@ You are the QA contact for the [% terms.bug %].
 You are on the CC list for the [% terms.bug %].
     [% CASE constants.REL_VOTER %]
 You are a voter for the [% terms.bug %].
+    [% CASE constants.REL_GLOBAL_WATCHER %]
+You are watching all [% terms.bug %] changes.
   [% END %]
 [% END %]
 [% FOREACH relationship = reasons_watch %]