[rt-commit] [svn] r655 - rt/branches/rt-3.3/lib/RT

jesse at fsck.com jesse at fsck.com
Thu Apr 1 16:53:29 EST 2004


Author: jesse
Date: Thu Apr  1 16:53:29 2004
New Revision: 655

Modified:
   rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm
Log:
Updated how RT generates friendly name for which object a Custom Field applies to



Modified: rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm	(original)
+++ rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm	Thu Apr  1 16:53:29 2004
@@ -24,7 +24,7 @@
 use strict;
 no warnings qw(redefine);
 
-use vars qw(@TYPES %TYPES $RIGHTS);
+use vars qw(@TYPES %TYPES $RIGHTS %FRIENDLY_OBJECT_TYPES);
 
 use RT::CustomFieldValues;
 use RT::ObjectCustomFieldValues;
@@ -41,8 +41,16 @@
 # Populate a hash of types of easier validation
 for (@TYPES) { $TYPES{$_} = 1};
 
+
+%FRIENDLY_OBJECT_TYPES =  (
+    'RT::Queue-RT::Ticket'                 => "Tickets",
+    'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions",
+    'RT::User'                             => "Users",
+    'RT::Group'                            => "Groups",
+);
+
 $RIGHTS = {
-    SeeCustomField            => 'Can this principal see this custom field',       # loc_pair
+    SeeCustomField            => 'See custom fields',       # loc_pair
     AdminCustomField          => 'Create, delete and modify custom fields',        # loc_pair
 };
 
@@ -104,6 +112,10 @@
     if ($args{TypeComposite}) {
 	@args{'Type', 'MaxValues'} = split(/-/, $args{TypeComposite}, 2);
     }
+    elsif ($args{Type} =~ s/(?:(Single)|Multiple)$//) {
+	# old style Type string
+	$args{'MaxValues'} = $1 ? 1 : 0;
+    }
     
     if ( !exists $args{'Queue'}) {
 	# do nothing -- things below are strictly backward compat
@@ -722,10 +734,15 @@
 
 sub FriendlyLookupType {
     my $self = shift;
-    my $lookup = shift;
+    my $lookup = shift || $self->LookupType;
+   
+    return ($self->loc( $FRIENDLY_OBJECT_TYPES{$lookup} ))
+      	           if (defined  $FRIENDLY_OBJECT_TYPES{$lookup} );
+
     my @types = map { s/^RT::// ? $self->loc($_) : $_ }
-		grep {defined and length}
-		split(/-/, $lookup || $self->LookupType) or return;
+      grep { defined and length }
+      split( /-/, $lookup )
+      or return;
     return ( $self->loc( $FriendlyObjectTypes[$#types], @types ) );
 }
 



More information about the Rt-commit mailing list