Watcher assignment bug - was Re: [rt-users] support with folks with phone #s but not e-mail

Phil Homewood pdh at snapgear.com
Wed Jan 22 17:50:09 EST 2003


Mark Stosberg wrote:
>  - In the "Create a new Ticket" screen, user ids as well as
>    e-mails need to be accepted in the "Requestors" box. I just tried
>    this, and found what appeared to be a bug in RT 2.0.15: It silently
>    ignored my input and set the Requestor field to "none".

Yes, that looks like a bug.
RT::Ticket::Create() is documented as taking "A reference to a list of
RT::User objects, email addresses or RT user Names", but it really
seems to take "RT::User objects, email addresses or RT user IDs."

Try the attached patch to make it take any of the above. :-)
-- 
Phil Homewood, Systems Janitor, www.SnapGear.com
pdh at snapgear.com Ph: +61 7 3435 2810 Fx: +61 7 3891 3630
SnapGear - Custom Embedded Solutions and Security Appliances
-------------- next part --------------
Index: lib/RT/Ticket.pm
===================================================================
RCS file: /cvs/local/rt/lib/RT/Ticket.pm,v
retrieving revision 1.5
retrieving revision 1.5.2.2
diff -u -r1.5 -r1.5.2.2
--- lib/RT/Ticket.pm	15 Jul 2002 01:30:27 -0000	1.5
+++ lib/RT/Ticket.pm	22 Jan 2003 22:48:18 -0000	1.5.2.2
@@ -703,12 +703,21 @@
 	    $args{'Owner'} = $args{'Person'};
 	}
 	#if it's an email address, shove it in Email
-       else {
-	   $args{'Email'} = $args{'Person'};
-       }	
+	elsif ($args{'Person'} =~ /@/) {
+	    $args{'Email'} = $args{'Person'};
+	}
+	#else, try to load by username
+	else {
+	         my $watcher = new RT::User($self->CurrentUser);
+	         $watcher->Load($args{'Person'});
+	         if ($watcher->Id) {
+	                 $args{'Owner'} = $watcher->Id;
+	         }
+	 }
+        
     }	
 
-    # Turn an email address int a watcher if we possibly can.
+    # Turn an email address into a watcher if we possibly can.
     if ($args{'Email'}) {
 	my $watcher = new RT::User($self->CurrentUser);
 	$watcher->LoadByEmail($args{'Email'});


More information about the rt-users mailing list