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

jesse at bestpractical.com jesse at bestpractical.com
Thu Dec 16 14:47:00 EST 2004


Author: jesse
Date: Mon Dec 13 21:42:15 2004
New Revision: 1988

Modified:
   rt/branches/3.3-TESTING/   (props changed)
   rt/branches/3.3-TESTING/lib/RT/Record.pm
   rt/branches/3.3-TESTING/lib/RT/Transaction_Overlay.pm
Log:
 r2413 at hualien:  jesse | 2004-12-14T02:38:06.428282Z
 RT::Transaction->CustomFieldValues can now accept named arguments


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	Mon Dec 13 21:42:15 2004
@@ -1774,6 +1774,7 @@
         # Look up the field ID.
         my $cfs = RT::CustomFields->new( $self->CurrentUser );
         $cfs->LimitToGlobalOrObjectId( $self->Id() );
+        $cfs->LimitToLookupType($self->_LookupTypes);
         $cfs->Limit( FIELD => 'Name', OPERATOR => '=', VALUE => $field );
 
         if ( $cfs->First ) {
@@ -1794,6 +1795,7 @@
     $cf_values->LimitToObject($self);
     $cf_values->OrderBy( FIELD => 'id', ORDER => 'ASC' );
 
+
     return ($cf_values);
 }
 

Modified: rt/branches/3.3-TESTING/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/3.3-TESTING/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/3.3-TESTING/lib/RT/Transaction_Overlay.pm	Mon Dec 13 21:42:15 2004
@@ -944,6 +944,39 @@
     }
 }
 
+
+
+=head2 CustomFieldValues
+
+ Do name => id mapping (if needed) before falling back to RT::Record's CustomFieldValues
+
+ See L<RT::Record>
+
+=cut
+
+sub CustomFieldValues {
+    my $self  = shift;
+    my $field = shift;
+
+    if ( UNIVERSAL::can( $self->Object, 'QueueObj' ) ) {
+
+        unless ( $field =~ /^\d+$/ ) {
+            my $cf = RT::CustomField->new( $self->CurrentUser );
+            $cf->LoadByName(
+                Name  => $field,
+                Queue => $self->Object->QueueObj->Id
+            );
+            unless ( $cf->id ) {
+                $cf->LoadByName( Name => $field, Queue => '0' );
+            }
+            $field = $cf->id;
+        }
+    }
+    return $self->SUPER::CustomFieldValues($field);
+}
+
+# }}}
+
 sub _LookupTypes {
     "RT::Queue-RT::Ticket-RT::Transaction";
 }


More information about the Rt-commit mailing list