#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
use strict;
use warnings;
-
+use base 'RT::SearchBuilder';
use RT::CustomFieldValue;
-use base 'RT::SearchBuilder';
-
sub Table { 'CustomFieldValues'}
sub _Init {
# By default, order by SortOrder
$self->OrderByCols(
- { ALIAS => 'main',
- FIELD => 'SortOrder',
- ORDER => 'ASC' },
- { ALIAS => 'main',
- FIELD => 'Name',
- ORDER => 'ASC' },
- { ALIAS => 'main',
- FIELD => 'id',
- ORDER => 'ASC' },
+ { ALIAS => 'main',
+ FIELD => 'SortOrder',
+ ORDER => 'ASC' },
+ { ALIAS => 'main',
+ FIELD => 'Name',
+ ORDER => 'ASC' },
+ { ALIAS => 'main',
+ FIELD => 'id',
+ ORDER => 'ASC' },
);
return ( $self->SUPER::_Init(@_) );
);
}
+=head2 SetCustomFieldObject
+
+Store the CustomField object which loaded this CustomFieldValues collection.
+Consumers of CustomFieldValues collection (such as External Custom Fields)
+can now work out how they were loaded (off a Queue or Ticket or something else)
+by inspecting the CustomField.
+=cut
+sub SetCustomFieldObject {
+ my $self = shift;
+ return $self->{'custom_field'} = shift;
+}
-=head2 NewItem
+=head2 CustomFieldObject
-Returns an empty new RT::CustomFieldValue item
+Returns the CustomField object used to load this CustomFieldValues collection.
+Relies on $CustomField->Values having been called, is not set on manual loads.
=cut
-sub NewItem {
+sub CustomFieldObject {
my $self = shift;
- return(RT::CustomFieldValue->new($self->CurrentUser));
+ return $self->{'custom_field'};
}
+
+=head2 AddRecord
+
+Propagates the CustomField object from the Collection
+down to individual CustomFieldValue objects.
+
+=cut
+
+sub AddRecord {
+ my $self = shift;
+ my $CFV = shift;
+
+ $CFV->SetCustomFieldObj($self->CustomFieldObject);
+
+ push @{$self->{'items'}}, $CFV;
+ $self->{'rows'}++;
+}
+
+
RT::Base->_ImportOverlays();
1;