X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FCustomFieldValue.pm;h=e4a6a96efc3e57eb6f6649588b4ae13ff9ec2fba;hp=26df55ae45e62de5a9eca6fe81f17e536333a0c4;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=43a06151e47d2c59b833cbd8c26d97865ee850b6 diff --git a/rt/lib/RT/CustomFieldValue.pm b/rt/lib/RT/CustomFieldValue.pm index 26df55ae4..e4a6a96ef 100644 --- a/rt/lib/RT/CustomFieldValue.pm +++ b/rt/lib/RT/CustomFieldValue.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -54,8 +54,8 @@ package RT::CustomFieldValue; no warnings qw/redefine/; -use RT::CustomField; use base 'RT::Record'; +use RT::CustomField; sub Table {'CustomFieldValues'} @@ -100,37 +100,6 @@ sub ValidateName { return defined $_[1] && length $_[1]; }; -=head2 DeleteCategory - -Deletes the category associated with this value -Returns -1 if there is no Category - -=cut - -sub DeleteCategory { - my $self = shift; - my $attr = $self->FirstAttribute('Category') or return (-1,'No Category Set'); - return $attr->Delete; -} - -=head2 Delete - -Make sure we delete our Category when we're deleted - -=cut - -sub Delete { - my $self = shift; - - my ($result, $msg) = $self->DeleteCategory; - - unless ($result) { - return ($result, $msg); - } - - return $self->SUPER::Delete(@_); -} - sub _Set { my $self = shift; @@ -175,18 +144,37 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, CustomField will be stored as a int(11).) +=head2 SetCustomFieldObj + +Store the CustomField object which loaded this CustomFieldValue. +Passed down from the CustomFieldValues collection in AddRecord. + +This object will be transparently returned from CustomFieldObj rather +than loading from the database. + =cut +sub SetCustomFieldObj { + my $self = shift; + return $self->{'custom_field'} = shift; +} =head2 CustomFieldObj -Returns the CustomField Object which has the id returned by CustomField +If a CustomField object was stored using SetCustomFieldObj and it is +the same CustomField stored in the CustomField column, then the stored +CustomField object (likely passed down from CustomField->Values) will be returned. +Otherwise returns the CustomField Object which has the id returned by CustomField =cut sub CustomFieldObj { my $self = shift; + + return $self->{custom_field} if $self->{custom_field} + and $self->{custom_field}->id == $self->__Value('CustomField'); + my $CustomField = RT::CustomField->new($self->CurrentUser); $CustomField->Load($self->__Value('CustomField')); return($CustomField); @@ -329,7 +317,14 @@ sub _CoreAccessible { }; +sub FindDependencies { + my $self = shift; + my ($walker, $deps) = @_; + + $self->SUPER::FindDependencies($walker, $deps); + $deps->Add( out => $self->CustomFieldObj ); +} RT::Base->_ImportOverlays();