[Rt-commit] [svn] r1678 - in rt/branches/3.3-TESTING: . lib/RT

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Wed Oct 20 19:27:14 EDT 2004


Author: jesse
Date: Wed Oct 20 19:27:13 2004
New Revision: 1678

Modified:
   rt/branches/3.3-TESTING/   (props changed)
   rt/branches/3.3-TESTING/lib/RT/Queue_Overlay.pm
   rt/branches/3.3-TESTING/lib/RT/Record.pm
Log:
 r6074 at tinbook:  jesse | 2004-10-20T23:26:48.112240Z
 RT-Ticket: 5701
 RT-Status: resolved
 RT-Update: correspond
 
 RT now prevents users from creating objects with 'Name' attributes that are numreric.
 


Modified: rt/branches/3.3-TESTING/lib/RT/Queue_Overlay.pm
==============================================================================
--- rt/branches/3.3-TESTING/lib/RT/Queue_Overlay.pm	(original)
+++ rt/branches/3.3-TESTING/lib/RT/Queue_Overlay.pm	Wed Oct 20 19:27:13 2004
@@ -301,11 +301,27 @@
 
 # {{{ sub Create
 
+
+
+
 =head2 Create
 
 Create takes the name of the new queue 
 If you pass the ACL check, it creates the queue and returns its queue id.
 
+=begin testing
+
+my $queue = RT::Queue->new($RT::SystemUser);
+my ($id, $val) = $queue->Create( Name => 'Test1');
+ok($id, $val);
+
+($id, $val) = $queue->Create( Name => '66');
+ok(!$id, $val);
+
+
+=end testing
+
+
 =cut
 
 sub Create {
@@ -418,20 +434,14 @@
     my $tempqueue = new RT::Queue($RT::SystemUser);
     $tempqueue->Load($name);
 
-    #If we couldn't load it :)
-    unless ( $tempqueue->id() ) {
-        return (1);
-    }
-
     #If this queue exists, return undef
-    #Avoid the ACL check.
     if ( $tempqueue->Name() ) {
         return (undef);
     }
 
     #If the queue doesn't exist, return 1
     else {
-        return (1);
+        return ($self->SUPER::ValidateName($name));
     }
 
 }

Modified: rt/branches/3.3-TESTING/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.3-TESTING/lib/RT/Record.pm	(original)
+++ rt/branches/3.3-TESTING/lib/RT/Record.pm	Wed Oct 20 19:27:13 2004
@@ -549,8 +549,22 @@
 }
 
 # }}}
- 
 
+=head2 ValidateName NAME
+
+Validate the name of the record we're creating. Mostly, just make sure it's not a numeric ID, which is invalid for Name
+
+=cut
+
+sub ValidateName {
+    my $self = shift;
+    my $value = shift;
+    if ($value =~ /^\d+$/) {
+        return(0);
+    } else  {
+         return (1);
+    }
+}
 
 
 


More information about the Rt-commit mailing list