[whups] Patch for notification

Mike Baptiste mike@msbnetworks.net
Tue Nov 12 19:29:44 2002


This is a multi-part message in MIME format.
---------------------- multipart/mixed attachment
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

As we've been ramping up our use of Whups, I've been opening up most of
the tickets (basically brain dumping all the "Oh by the way" requests
I've had over the past few weeks)  We're over 150 and counting and since
I am an owner of most of the modules, my Inbox has been flooded with
emails that I know the contents of - since I changed the ticket.

I've written a patch to let a user exclude themselves from notification
emails for changes they make to a ticket.  This is inline with what
Bugzilla does.  Now I have to admit, Bugzilla recently added VERY
flexible notification settings.  Its a matrix of Actions vs what role
you are and do you want notifications for a given combo (i.e. I am the
Reporter and the ticket goes to a resolved state).  I think we should
implement something like this at some point.  But until then, this is a
huge start.

Any questions, let me know.

Mike

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE90Vantbf8BjvL+3ERAqjeAJ4lplh+5g5SFNsatgFaPuyRvgqt8ACgmgb2
p7/pdY5xO0HPGt9HXiEhBjI=
=1zgG
-----END PGP SIGNATURE-----

---------------------- multipart/mixed attachment
Index: Driver.php
===================================================================
RCS file: /repository/whups/lib/Driver.php,v
retrieving revision 1.27
diff -u -r1.27 Driver.php
--- Driver.php  12 Nov 2002 01:40:31 -0000      1.27
+++ Driver.php  12 Nov 2002 19:24:25 -0000
@@ -210,7 +210,7 @@
      */
     function _mail($ticket_id, $recipients, $subject, $message, $from)
     {
-        global $conf, $registry, $backend;
+        global $conf, $registry, $backend, $prefs;

         require_once 'Mail.php';
         require_once HORDE_BASE . '/lib/MIME.php';
@@ -232,6 +232,9 @@
             $recipients = array($recipients);
         }
         foreach ($recipients as $user) {
+            if (($user == $from) && $prefs->getValue('email_others_only')) {
+                continue;
+            }
             $details = Whups::getUserAttributes($user);
             if (!empty($details['email'])) {
                 $email = Whups::formatUser($user);
@@ -243,12 +246,16 @@
             }
         }

-        $headers['To'] = MIME::encodeAddress(implode(', ', $to));
+        // We may have no recipients due to users excluding themselves frrom notifies
+        if (count($to)) {
+
+            $headers['To'] = MIME::encodeAddress(implode(', ', $to));

-        $mailer = &Mail::factory($conf['mailer']['type'], $conf['mailer']['params']);
+            $mailer = &Mail::factory($conf['mailer']['type'], $conf['mailer']['params']);

-        foreach ($mails as $key => $addresses) {
-            $result = $mailer->send(MIME::encodeAddress(implode(', ', $addresses), null, $conf['server']['name']), $headers, $messages[$key]);
+            foreach ($mails as $key => $addresses) {
+                $result = $mailer->send(MIME::encodeAddress(implode(', ', $addresses), null, $conf['server']['name']), $headers, $messages[$key]);
+            }
         }
     }

---------------------- multipart/mixed attachment
Index: prefs.php.dist
===================================================================
RCS file: /repository/whups/config/prefs.php.dist,v
retrieving revision 1.8
diff -u -r1.8 prefs.php.dist
--- prefs.php.dist      12 Nov 2002 01:34:44 -0000      1.8
+++ prefs.php.dist      12 Nov 2002 19:22:41 -0000
@@ -15,6 +15,12 @@
     'members' => array('sortby', 'sortdir', 'theme', 'whups_default_view', 'summary_show_requested', 'summary_show_ticket_numbers', 'report_time_format', 'show_days_ago')
 );

+$prefGroups['notification'] = array(
+    'column' => _("Other Options"),
+    'label' => _("Notification Options"),
+    'desc' => _("Change options for email notifications of ticket activity."),
+    'members' => array('email_others_only'));
+
 // user language
 $_prefs['language'] = array(
     'value' => '',
@@ -124,4 +130,13 @@
     'shared' => false,
     'type' => 'checkbox',
     'desc' => _("Show \"(X Days Ago)\" in Date field of search results?")
+);
+
+// Skip notification of changes you added?
+$_prefs['email_others_only'] = array(
+    'value' => 1,
+    'locked' => false,
+    'shared' => false,
+    'type' => 'checkbox',
+    'desc' => _("Only notify me of ticket changes from other users")
 );
---------------------- multipart/mixed attachment--



More information about the whups mailing list