summaryrefslogtreecommitdiff
path: root/rt/lib/RT/CustomFieldValues.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-07-09 22:18:55 -0700
committerIvan Kohler <ivan@freeside.biz>2015-07-09 22:18:55 -0700
commit1c538bfabc2cd31f27067505f0c3d1a46cba6ef0 (patch)
tree96922ad4459eda1e649327fd391d60c58d454c53 /rt/lib/RT/CustomFieldValues.pm
parent4f5619288413a185e9933088d9dd8c5afbc55dfa (diff)
RT 4.2.11, ticket#13852
Diffstat (limited to 'rt/lib/RT/CustomFieldValues.pm')
-rw-r--r--rt/lib/RT/CustomFieldValues.pm61
1 files changed, 45 insertions, 16 deletions
diff --git a/rt/lib/RT/CustomFieldValues.pm b/rt/lib/RT/CustomFieldValues.pm
index 193cd66..7188689 100644
--- a/rt/lib/RT/CustomFieldValues.pm
+++ b/rt/lib/RT/CustomFieldValues.pm
@@ -51,12 +51,10 @@ package RT::CustomFieldValues;
use strict;
use warnings;
-
+use base 'RT::SearchBuilder';
use RT::CustomFieldValue;
-use base 'RT::SearchBuilder';
-
sub Table { 'CustomFieldValues'}
sub _Init {
@@ -64,15 +62,15 @@ 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(@_) );
@@ -95,19 +93,50 @@ sub LimitToCustomField {
);
}
+=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;