[Rt-commit] r2258 - in rt/branches/3.4-RELEASE: . lib/RT lib/t/regression

jesse at bestpractical.com jesse at bestpractical.com
Thu Feb 24 17:01:00 EST 2005


Author: jesse
Date: Thu Feb 24 17:00:58 2005
New Revision: 2258

Modified:
   rt/branches/3.4-RELEASE/   (props changed)
   rt/branches/3.4-RELEASE/lib/RT/Record.pm
   rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm
   rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm
   rt/branches/3.4-RELEASE/lib/t/regression/16-transaction_cf_tests.t
Log:
 r5943 at hualien:  jesse | 2005-02-24 16:42:01 -0500
 Upgraded a private _LookupTypes method to a public CustomFieldUpdateTypes method to make it easier to ad  custom fields to other objects
 


Modified: rt/branches/3.4-RELEASE/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Record.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/Record.pm	Thu Feb 24 17:00:58 2005
@@ -1443,14 +1443,14 @@
     $cfs->UnLimit;
 
     # XXX handle multiple types properly
-    foreach my $lookup ($self->_LookupTypes) {
-	$cfs->LimitToLookupType($lookup);
-	$cfs->LimitToGlobalOrObjectId($self->_LookupId($lookup));
-    }
+	$cfs->LimitToLookupType($self->CustomFieldLookupType);
+	$cfs->LimitToGlobalOrObjectId($self->_LookupId($self->CustomFieldLookupType));
 
     return $cfs;
 }
 
+# TODO: This _only_ works for RT::Class classes. it doesn't work, for example, for RT::FM classes. 
+
 sub _LookupId {
     my $self = shift;
     my $lookup = shift;
@@ -1464,7 +1464,27 @@
     return $self->Id;
 }
 
-sub _LookupTypes { ref($_[0]) }
+
+=head2 CustomFieldLookupType 
+
+Returns the path RT uses to figure out which custom fields apply to this object.
+
+=cut
+
+sub CustomFieldLookupType {
+    my $self = shift;
+    return ref($self);
+}
+
+#TODO Deprecated API. Destroy in 3.6
+sub _LookupTypes { 
+    my  $self = shift;
+    $RT::Logger->warning("_LookupTypes call is deprecated. Replace with CustomFieldLookupType");
+    $RT::Logger->warning("Besides, it was a private API. Were you doing using it?");
+
+    return($self->CustomFieldLookupType);
+
+}
 
 # {{{ AddCustomFieldValue
 
@@ -1754,7 +1774,7 @@
         # Look up the field ID.
         my $cfs = RT::CustomFields->new( $self->CurrentUser );
         $cfs->LimitToGlobalOrObjectId( $self->Id() );
-        $cfs->LimitToLookupType($self->_LookupTypes);
+        $cfs->LimitToLookupType($self->CustomFieldLookupType);
         $cfs->Limit( FIELD => 'Name', OPERATOR => '=', VALUE => $field );
 
         if ( $cfs->First ) {

Modified: rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm	Thu Feb 24 17:00:58 2005
@@ -3660,7 +3660,7 @@
 
 # }}}
 
-sub _LookupTypes {
+sub CustomFieldLookupType {
     "RT::Queue-RT::Ticket";
 }
 

Modified: rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm	Thu Feb 24 17:00:58 2005
@@ -989,7 +989,7 @@
         unless ( $field =~ /^\d+$/o ) {
             my $CFs = RT::CustomFields->new( $self->CurrentUser );
              $CFs->Limit( FIELD => 'Name', VALUE => $field);
-            $CFs->LimitToLookupType($self->_LookupTypes);
+            $CFs->LimitToLookupType($self->CustomFieldLookupType);
             $CFs->LimitToGlobalOrObjectId($self->Object->QueueObj->id);
             $field = $CFs->First->id if $CFs->First;
         }
@@ -999,7 +999,7 @@
 
 # }}}
 
-sub _LookupTypes {
+sub CustomFieldLookupType {
     "RT::Queue-RT::Ticket-RT::Transaction";
 }
 

Modified: rt/branches/3.4-RELEASE/lib/t/regression/16-transaction_cf_tests.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/16-transaction_cf_tests.t	(original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/16-transaction_cf_tests.t	Thu Feb 24 17:00:58 2005
@@ -15,7 +15,7 @@
 ok($id,$msg);
 
 my $cf = RT::CustomField->new($RT::SystemUser);
-($id,$msg) = $cf->Create(Name => 'Txnfreeform-'.$$, Type => 'Freeform', MaxValues => '0', LookupType => RT::Transaction->_LookupTypes );
+($id,$msg) = $cf->Create(Name => 'Txnfreeform-'.$$, Type => 'Freeform', MaxValues => '0', LookupType => RT::Transaction->CustomFieldLookupType );
 
 ok($id,$msg);
 


More information about the Rt-commit mailing list