[Rt-commit] r13944 - in rt/3.8/trunk: . sbin

sartak at bestpractical.com sartak at bestpractical.com
Thu Jul 10 12:04:01 EDT 2008


Author: sartak
Date: Thu Jul 10 12:04:01 2008
New Revision: 13944

Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/sbin/rt-email-dashboards.in
   rt/3.8/trunk/share/html/Dashboards/Subscription.html

Log:
 r64034 at onn:  sartak | 2008-07-10 12:03:30 -0400
 Allow setting a different recipient for an individual subscription


Modified: rt/3.8/trunk/sbin/rt-email-dashboards.in
==============================================================================
--- rt/3.8/trunk/sbin/rt-email-dashboards.in	(original)
+++ rt/3.8/trunk/sbin/rt-email-dashboards.in	Thu Jul 10 12:04:01 2008
@@ -137,13 +137,6 @@
         next;
     }
 
-    unless (email_of($user)) {
-        debug "Skipping over "
-            . $user->Name
-            . " due to lack of EmailAddress.";
-        next;
-    }
-
     my ($hour, $dow, $dom) = hour_dow_dom_in($user->Timezone || RT->Config->Get('Timezone'));
     $hour .= ':00';
     debug "Checking [_1]'s subscriptions: hour [_2], dow [_3], dom [_4]",
@@ -175,13 +168,16 @@
             }
         }
 
-        eval { send_dashboard($currentuser, $subscription) };
+        my $email = $subscription->SubValue('Recipient')
+                 || email_of($user);
+
+        eval { send_dashboard($currentuser, $email, $subscription) };
         error 'Caught exception: ' . $@ if $@;
     }
 }
 
 sub send_dashboard {
-    my ($currentuser, $subscription) = @_;
+    my ($currentuser, $email, $subscription) = @_;
 
     my $rows = $subscription->SubValue('Rows');
 
@@ -199,7 +195,7 @@
 
         my $ok = RT::Interface::Email::SendEmailUsingTemplate(
             From      => $from,
-            To        => email_of($currentuser),
+            To        => $email,
             Template  => 'Error: Missing dashboard',
             Arguments => {
                 SubscriptionObj => $subscription,
@@ -230,7 +226,7 @@
     if ($opts{'dryrun'}) {
         print << "SUMMARY";
     Dashboard: @{[ $dashboard->Name ]}
-    User:   @{[ $currentuser->Name ]} <@{[ email_of($currentuser) ]}>
+    User:   @{[ $currentuser->Name ]} <$email>
 SUMMARY
         return;
     }
@@ -253,36 +249,34 @@
         RT->Config->Get('WebURL') . '/Dashboards/Render.html',
     );
 
-    email_dashboard($currentuser, $dashboard, $subscription, $contents);
+    email_dashboard($currentuser, $email, $dashboard, $subscription, $contents);
 }
 
 sub email_dashboard {
-    my ($currentuser, $dashboard, $subscription, $content) = @_;
+    my ($currentuser, $email, $dashboard, $subscription, $content) = @_;
 
     verbose 'Sending dashboard "[_1]" to user [_2] <[_3]>',
             $dashboard->Name,
             $currentuser->Name,
-            email_of($currentuser);
+            $email;
 
     my $subject = sprintf '[%s] ' .  RT->Config->Get('DashboardSubject'),
         RT->Config->Get('rtname'),
         ucfirst($subscription->SubValue('Frequency')),
         $dashboard->Name;
 
-    my $entity = build_email(
-        $content, $from, email_of($currentuser), $subject,
-    );
+    my $entity = build_email($content, $from, $email, $subject);
 
     my $ok = RT::Interface::Email::SendEmail(
         Entity => $entity,
     );
 
     debug "Done sending dashboard to [_1] <[_2]>",
-          $currentuser->Name, email_of($currentuser)
+          $currentuser->Name, $email
               and return if $ok;
 
     error 'Failed to email dashboard to user [_1] <[_2]>',
-          $currentuser->Name, email_of($currentuser);
+          $currentuser->Name, $email;
 }
 
 sub build_email {

Modified: rt/3.8/trunk/share/html/Dashboards/Subscription.html
==============================================================================
--- rt/3.8/trunk/share/html/Dashboards/Subscription.html	(original)
+++ rt/3.8/trunk/share/html/Dashboards/Subscription.html	Thu Jul 10 12:04:01 2008
@@ -151,6 +151,13 @@
 %   }
 </select>
 </td></tr>
+
+<tr><td class="label">
+<&|/l&>Recipient</&>:
+</td><td class="value">
+<input name="Recipient" id="Recipient" size="30" value="<%$fields{Recipient} ? $fields{Recipient} : ''%>" />
+<div class="hints">Leave blank to send to your current email address with RT</div>
+</td></tr>
 </table>
 </&>
 </td>
@@ -199,6 +206,7 @@
     Dow         => 'Monday',
     Dom         => 1,
     Rows        => 20,
+    Recipient   => '',
 );
 
 # update any fields with the values from the subscription object
@@ -215,7 +223,6 @@
         if defined($ARGS{$field});
 }
 
-
 # this'll be defined on submit
 if (defined $ARGS{Save}) {
     # update
@@ -246,7 +253,7 @@
         if ($val) {
             push @results, loc("Subscribed to dashboard [_1]", $DashboardObj->Name);
             push @results, loc("Warning: you have no email address set, so you will not receive this dashboard until you have it set")
-                unless $session{'CurrentUser'}->EmailAddress;
+                unless $session{'CurrentUser'}->EmailAddress || $fields{Recipient};
         }
         else {
             push @results, loc('Subscription could not be created: [_1]', $msg);
@@ -269,5 +276,6 @@
 $Dow         => undef
 $Dom         => undef
 $Rows        => undef
+$Recipient   => undef
 </%ARGS>
 


More information about the Rt-commit mailing list