[Rt-commit] [svn] r1957 - in rt/branches/3.3-TESTING: . lib/RT
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Sun Dec 5 16:58:32 EST 2004
Author: jesse
Date: Sun Dec 5 16:58:31 2004
New Revision: 1957
Modified:
rt/branches/3.3-TESTING/ (props changed)
rt/branches/3.3-TESTING/lib/RT/Record.pm
Log:
r9495 at tinbook: jesse | 2004-12-05T21:57:36.434513Z
Refactored RT::Record->CustomFieldValues to accept cf names and convert them to ids. (Based on a patch by Tara Andrews)
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 Sun Dec 5 16:58:31 2004
@@ -1723,7 +1723,8 @@
=item CustomFieldValues FIELD
-Return a ObjectCustomFieldValues object of all values of the CustomField whose id is FIELD for this ticket.
+Return a ObjectCustomFieldValues object of all values of the CustomField whose
+id or Name is FIELD for this ticket.
Returns an RT::ObjectCustomFieldValues object
@@ -1737,11 +1738,24 @@
$cf_values->LimitToObject($self);
$cf_values->OrderBy( FIELD => 'id', ORDER => 'ASC' );
- if ( length $field ) {
- $field =~ /^\d+$/ or die "LoadByNameAndQueue impossible for Record.pm";
- my $cf = RT::CustomField->new( $self->CurrentUser );
- $cf_values->LimitToCustomField( $field);
+ # If we've been handed a value that contains a non-digit, it's a name. \
+ # Resolve it into an id.
+ if ( $field =~ /\D/ ) {
+
+ # Look up the field ID.
+ my $cfs = RT::CustomFields->new( $self->CurrentUser );
+ $cfs->LimitToGlobalOrObjectId( $self->Id() );
+ $cfs->Limit( FIELD => 'Name', OPERATOR => '=', VALUE => $field );
+
+ if ( $cfs->First ) {
+ $field = $cfs->First->id;
+ }
+ else {
+ $field = undef;
+ }
}
+
+ $cf_values->LimitToCustomField($field) if ( $field =~ /^\d+$/o);
return ($cf_values);
}
More information about the Rt-commit
mailing list