[Rt-commit] r6766 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Thu Jan 18 10:53:52 EST 2007


Author: ruz
Date: Thu Jan 18 10:53:50 2007
New Revision: 6766

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm

Log:
 r4386 at cubic-pc:  cubic | 2007-01-18 05:05:20 +0300
 * use Mail::Address to parse watchers from args,
   split by comma is not that good idea as user may input something like
   "Foo, Bar" <Bar.Foo at example.com>.


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	Thu Jan 18 10:53:50 2007
@@ -323,19 +323,6 @@
     my $starts = new RT::Date( $session{'CurrentUser'} );
     $starts->Set( Format => 'unknown', Value => $ARGS{'Starts'} );
 
-    my @Requestors = split /\s*,\s*/, ( $ARGS{'Requestors'} || '' );
-    my @Cc         = split /\s*,\s*/, ( $ARGS{'Cc'}         || '' );
-    my @AdminCc    = split /\s*,\s*/, ( $ARGS{'AdminCc'}    || '' );
-
-    my @temp_squelch;
-    push @temp_squelch, @Requestors if grep $_ eq 'Requestors', @{ $ARGS{'SkipNotification'} || [] };
-    push @temp_squelch, @Cc         if grep $_ eq 'Cc',         @{ $ARGS{'SkipNotification'} || [] };
-    push @temp_squelch, @AdminCc    if grep $_ eq 'AdminCc',    @{ $ARGS{'SkipNotification'} || [] };
-    if ( @temp_squelch ) {
-        require RT::Action::SendEmail;
-        RT::Action::SendEmail->SquelchMailTo( RT::Action::SendEmail->SquelchMailTo, @temp_squelch );
-    }
-
     my $MIMEObj = MakeMIMEEntity(
         Subject             => $ARGS{'Subject'},
         From                => $ARGS{'From'},
@@ -366,15 +353,36 @@
         TimeLeft        => $ARGS{'TimeLeft'},
         TimeEstimated   => $ARGS{'TimeEstimated'},
         TimeWorked      => $ARGS{'TimeWorked'},
-        Requestor       => \@Requestors,
-        Cc              => \@Cc,
-        AdminCc         => \@AdminCc,
         Subject         => $ARGS{'Subject'},
         Status          => $ARGS{'Status'},
         Due             => $due->ISO,
         Starts          => $starts->ISO,
         MIMEObj         => $MIMEObj
     );
+
+    my @temp_squelch;
+    foreach my $type (qw(Requestors Cc AdminCc)) {
+        my @tmp = Mail::Address->parse( $ARGS{ $type } );
+        push @temp_squelch, map $_->address, @tmp
+            if grep $_ eq $type, @{ $ARGS{'SkipNotification'} || [] };
+
+        $create_args{ $type } = [
+            grep $_, map {
+                my $user = RT::User->new( $RT::SystemUser );
+                $user->LoadOrCreateByEmail( $_ );
+                # convert to ids to avoid work later
+                $user->id;
+            } @tmp
+        ];
+    }
+    # XXX: workaround for name conflict :(
+    $create_args{'Requestor'} = delete $create_args{'Requestors'};
+
+    if ( @temp_squelch ) {
+        require RT::Action::SendEmail;
+        RT::Action::SendEmail->SquelchMailTo( RT::Action::SendEmail->SquelchMailTo, @temp_squelch );
+    }
+
     foreach my $arg (keys %ARGS) {
         next if $arg =~ /-(?:Magic|Category)$/;
 


More information about the Rt-commit mailing list