[Rt-commit] r5791 - in RT-Extension-CommandByEmail: .

kevinr at bestpractical.com kevinr at bestpractical.com
Tue Aug 22 00:43:07 EDT 2006


Author: kevinr
Date: Tue Aug 22 00:43:06 2006
New Revision: 5791

Modified:
   RT-Extension-CommandByEmail/   (props changed)
   RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm

Log:
 r25589 at SAD-GIRL-IN-SNOW:  kevinr | 2006-08-22 00:37:51 -0400
 * Allow Owner to be specified as an e-mail address


Modified: RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm
==============================================================================
--- RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm	(original)
+++ RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm	Tue Aug 22 00:43:06 2006
@@ -226,6 +226,13 @@
             next unless defined $cmds{ lc $attribute };
             next if $ticket_as_user->$attribute() eq $cmds{ lc $attribute };
 
+            # canonicalize owner -- accept an e-mail address
+            if ( $attribute eq 'Owner' && $cmds{ lc $attribute } =~ /\@/ ) {
+                my $user = RT::User->new($RT::SystemUser);
+                $user->LoadByEmail( $cmds{ lc $attribute } );
+                $cmds{ lc $attribute } = $user->Name if $user->id;
+            }
+
             _SetAttribute(
                 $ticket_as_user,        $attribute,
                 $cmds{ lc $attribute }, \%results
@@ -405,9 +412,17 @@
     } else {
 
         my %create_args = ();
-        foreach my $attr (@REGULAR_ATTRIBUTES, @TIME_ATTRIBUTES) {
-            next unless exists $cmds{ lc $attr };
-            $create_args{$attr} = $cmds{ lc $attr };
+        foreach my $attribute (@REGULAR_ATTRIBUTES, @TIME_ATTRIBUTES) {
+            next unless exists $cmds{ lc $attribute };
+
+            # canonicalize owner -- accept an e-mail address
+            if ( $attribute eq 'Owner' && $cmds{ lc $attribute } =~ /\@/ ) {
+                my $user = RT::User->new($RT::SystemUser);
+                $user->LoadByEmail( $cmds{ lc $attribute } );
+                $cmds{ lc $attribute } = $user->Name if $user->id;
+            }
+
+            $create_args{$attribute} = $cmds{ lc $attribute };
         }
         foreach my $attr (@DATE_ATTRIBUTES) {
             next unless exists $cmds{ lc $attr };


More information about the Rt-commit mailing list