X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FCustomFieldValues.pm;h=d8706f601aa08f61aa0cbd948f9ade7aae8d3f58;hb=5372897f367498972c96f5494e142e6e11b29eb8;hp=18bc6b4b0bff336d9aec7bd777bea714276f1d8d;hpb=e9e0cf0989259b94d9758eceff448666a2e5a5cc;p=freeside.git diff --git a/rt/lib/RT/CustomFieldValues.pm b/rt/lib/RT/CustomFieldValues.pm index 18bc6b4b0..d8706f601 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-2017 Best Practical Solutions, LLC # # # (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;