summaryrefslogtreecommitdiff
path: root/rt/lib/RT/CustomFieldValues.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-07-26 15:41:26 -0700
committerIvan Kohler <ivan@freeside.biz>2015-07-26 15:41:26 -0700
commit9aee669886202be7035e6c6049fc71bc99dd3013 (patch)
tree2fd5bf6de74f3d99270587ffb1833e4188a6373d /rt/lib/RT/CustomFieldValues.pm
parentac20214d38d9af00430423f147b5a0e50751b050 (diff)
parent1add633372bdca3cc7163c2ce48363fed3984437 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'rt/lib/RT/CustomFieldValues.pm')
-rw-r--r--rt/lib/RT/CustomFieldValues.pm63
1 files changed, 46 insertions, 17 deletions
diff --git a/rt/lib/RT/CustomFieldValues.pm b/rt/lib/RT/CustomFieldValues.pm
index 18bc6b4b0..718868932 100644
--- a/rt/lib/RT/CustomFieldValues.pm
+++ b/rt/lib/RT/CustomFieldValues.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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;