[Rt-commit] r2386 - in rt/branches/PLATANO-EXPERIMENTAL: . lib/RT
jesse at bestpractical.com
jesse at bestpractical.com
Mon Mar 14 02:34:12 EST 2005
Author: jesse
Date: Mon Mar 14 02:34:12 2005
New Revision: 2386
Modified:
rt/branches/PLATANO-EXPERIMENTAL/ (props changed)
rt/branches/PLATANO-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm
Log:
r8490 at hualien: jesse | 2005-03-14 02:27:53 -0500
r5948 at hualien: jesse | 2005-02-24 16:47:52 -0500
Custom Field API extension and cleanup to allow new objects to use custom fields. (No backwards-incompat changes)
Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm Mon Mar 14 02:34:12 2005
@@ -48,30 +48,28 @@
use strict;
no warnings qw(redefine);
-use vars qw(@TYPES %TYPES $RIGHTS %FRIENDLY_OBJECT_TYPES);
+use vars qw(%TYPES $RIGHTS %FRIENDLY_OBJECT_TYPES);
use RT::CustomFieldValues;
use RT::ObjectCustomFieldValues;
# Enumerate all valid types for this custom field
- at TYPES = (
- 'Freeform', # loc
- 'Select', # loc
- 'Text', # loc
- 'Image', # loc
- 'Binary', # loc
+%TYPES = (
+ Freeform => 1, # loc
+ Select => 1, # loc
+ Text => 1, # loc
+ Image => 1, # loc
+ Binary => 1, # loc
);
-# Populate a hash of types of easier validation
-for (@TYPES) { $TYPES{$_} = 1};
+%FRIENDLY_OBJECT_TYPES = ();
-%FRIENDLY_OBJECT_TYPES = (
- 'RT::Queue-RT::Ticket' => "Tickets", # loc
- 'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions", # loc
- 'RT::User' => "Users", # loc
- 'RT::Group' => "Groups", # loc
-);
+RT::CustomField->_ForObjectType( 'RT::Queue-RT::Ticket' => "Tickets", ); #loc
+RT::CustomField->_ForObjectType(
+ 'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions", ); #loc
+RT::CustomField->_ForObjectType( 'RT::User' => "Users", ); #loc
+RT::CustomField->_ForObjectType( 'RT::Group' => "Groups", ); #loc
$RIGHTS = {
SeeCustomField => 'See custom fields', # loc_pair
@@ -506,7 +504,7 @@
=cut
sub Types {
- return (@TYPES);
+ return (keys %TYPES);
}
# }}}
@@ -1048,6 +1046,30 @@
}
+=head2 _ForObjectType PATH FRIENDLYNAME
+
+Tell RT that a certain object accepts custom fields
+
+Examples:
+
+ 'RT::Queue-RT::Ticket' => "Tickets", # loc
+ 'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions", # loc
+ 'RT::User' => "Users", # loc
+ 'RT::Group' => "Groups", # loc
+
+This is a class method.
+
+=cut
+
+sub _ForObjectType {
+ my $self = shift;
+ my $path = shift;
+ my $friendly_name = shift;
+
+ $FRIENDLY_OBJECT_TYPES{$path} = $friendly_name;
+
+}
+
# }}}
1;
More information about the Rt-commit
mailing list