[Rt-commit] r17911 - in rt/3.999/branches/merge_to_3.8.2: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Jan 25 21:38:27 EST 2009


Author: sunnavy
Date: Sun Jan 25 21:38:26 2009
New Revision: 17911

Modified:
   rt/3.999/branches/merge_to_3.8.2/   (props changed)
   rt/3.999/branches/merge_to_3.8.2/lib/RT/Model/User.pm

Log:
 r19013 at sunnavys-mb:  sunnavy | 2009-01-26 10:35:58 +0800
 merged lib/RT/Model/User.pm


Modified: rt/3.999/branches/merge_to_3.8.2/lib/RT/Model/User.pm
==============================================================================
--- rt/3.999/branches/merge_to_3.8.2/lib/RT/Model/User.pm	(original)
+++ rt/3.999/branches/merge_to_3.8.2/lib/RT/Model/User.pm	Sun Jan 25 21:38:26 2009
@@ -607,6 +607,51 @@
     }
 }
 
+=head2 email_frequency
+
+Takes optional Ticket argument in paramhash. Returns 'no email',
+'squelched', 'daily', 'weekly' or empty string depending on
+user preferences.
+
+=over 4
+
+=item 'no email' - user has no email, so can not recieve notifications.
+
+=item 'squelched' - returned only when Ticket argument is provided and
+notifications to the user has been supressed for this ticket.
+
+=item 'daily' - retruned when user recieve daily messages digest instead
+of immediate delivery.
+
+=item 'weekly' - previous, but weekly.
+
+=item empty string returned otherwise.
+
+=back
+
+=cut
+
+sub email_frequency {
+    my $self = shift;
+    my %args = (
+        ticket => undef,
+        @_
+    );
+    return ''
+      unless $self->id
+          && $self->id != $RT::Nobody->id
+          && $self->id != RT->system_user->id;
+    return 'no email' unless my $email = $self->email;
+    return 'squelched'
+      if $args{'ticket'}
+          && grep lc $email eq lc $_->content, $args{'ticket'}->squelch_mail_to;
+    my $frequency = RT->config->get( 'EmailFrequency', $self ) || '';
+    return 'daily'  if $frequency =~ /daily/i;
+    return 'weekly' if $frequency =~ /weekly/i;
+    return '';
+}
+
+
 
 =head2 canonicalize_email ADDRESS
 


More information about the Rt-commit mailing list