[Rt-commit] r13069 - in rt/branches/3.8-TESTING: .

sartak at bestpractical.com sartak at bestpractical.com
Mon Jun 9 15:41:59 EDT 2008


Author: sartak
Date: Mon Jun  9 15:41:58 2008
New Revision: 13069

Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/lib/RT/Test.pm

Log:
 r61877 at onn:  sartak | 2008-06-09 14:34:17 -0400
 Add load_or_create_custom_field


Modified: rt/branches/3.8-TESTING/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Test.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Test.pm	Mon Jun  9 15:41:58 2008
@@ -344,6 +344,27 @@
     return $obj;
 }
 
+=head2 load_or_create_custom_field
+
+=cut
+
+sub load_or_create_custom_field {
+    my $self = shift;
+    my %args = ( Disabled => 0, @_ );
+    my $obj = RT::CustomField->new( $RT::SystemUser );
+    if ( $args{'Name'} ) {
+        $obj->LoadByCols( Name => $args{'Name'} );
+    } else {
+        die "Name is required";
+    }
+    unless ( $obj->id ) {
+        my ($val, $msg) = $obj->Create( %args );
+        die "$msg" unless $val;
+    }
+
+    return $obj;
+}
+
 sub store_rights {
     my $self = shift;
 


More information about the Rt-commit mailing list