[Rt-commit] r4361 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Sun Dec 25 04:10:31 EST 2005
Author: ruz
Date: Sun Dec 25 03:20:35 2005
New Revision: 4361
Added:
rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues/
rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues/External.pm
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
Log:
r1583 at cubic-pc: cubic | 2005-12-25 11:23:41 +0300
r1573 at cubic-pc: cubic | 2005-12-25 11:17:03 +0300
* prototype of the base class for external CF values
Added: rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues/External.pm
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues/External.pm Sun Dec 25 03:20:35 2005
@@ -0,0 +1,69 @@
+package RT::CustomFieldValues::External;
+
+use strict;
+use warnings;
+
+use base qw(RT::CustomFieldValues);
+
+sub _Init {
+ my $self = shift;
+ $self->Table( 'Groups' );
+ return ( $self->SUPER::_Init(@_) );
+}
+
+sub Limit {
+ my $self = shift;
+ my %args = (@_);
+ $self->{'__external_limits'} ||= [];
+ push @{ $self->{'__external_limits'} }, \%args;
+ return $self->SUPER::Limit( %args );
+}
+
+sub _DoSearch {
+ my $self = shift;
+
+ delete $self->{'items'};
+
+ my %defaults = (
+ id => 1,
+ name => '',
+ customfield => $self->{'__external_custom_field'},
+ sortorder => 0,
+ description => '',
+ creator => $RT::SystemUser->id,
+ created => undef,
+ lastupdatedby => $RT::SystemUser->id,
+ lastupdated => undef,
+ );
+
+ my $i = 0;
+
+ my $groups = RT::Groups->new( $self->CurrentUser );
+ $groups->LimitToUserDefinedGroups;
+ $groups->OrderByCols( { FIELD => 'Name' } );
+ foreach( @{ $self->ExternalValues } ) {
+ my $value = $self->NewItem;
+ $value->LoadFromHash( { %defaults, %$_ } );
+ $self->AddRecord( $value );
+ }
+ $self->{'must_redo_search'} = 0;
+ return $self->_RecordCount;
+}
+
+sub _DoCount {
+ my $self = shift;
+
+ my $count;
+ $count = $self->_DoSearch if $self->{'must_redo_search'};
+ $count = $self->_RecordCount unless defined $count;
+
+ return $self->{'count_all'} = $self->{'raw_rows'} = $count;
+}
+
+sub LimitToCustomField {
+ my $self = shift;
+ $self->{'__external_custom_field'} = $_[0];
+ return $self->SUPER::LimitToCustomField( @_ );
+}
+
+1;
More information about the Rt-commit
mailing list