summaryrefslogtreecommitdiff
path: root/rt/lib/RT/ObjectCustomFieldValue.pm
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/ObjectCustomFieldValue.pm')
-rw-r--r--rt/lib/RT/ObjectCustomFieldValue.pm45
1 files changed, 42 insertions, 3 deletions
diff --git a/rt/lib/RT/ObjectCustomFieldValue.pm b/rt/lib/RT/ObjectCustomFieldValue.pm
index 9af328a..6bb0934 100644
--- a/rt/lib/RT/ObjectCustomFieldValue.pm
+++ b/rt/lib/RT/ObjectCustomFieldValue.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -107,7 +107,7 @@ sub Create {
$self->_EncodeLOB( $args{'LargeContent'}, $args{'ContentType'} )
if defined $args{'LargeContent'};
- return $self->SUPER::Create(
+ ( my $id, $msg ) = $self->SUPER::Create(
CustomField => $args{'CustomField'},
ObjectType => $args{'ObjectType'},
ObjectId => $args{'ObjectId'},
@@ -117,6 +117,23 @@ sub Create {
ContentType => $args{'ContentType'},
ContentEncoding => $args{'ContentEncoding'},
);
+
+ if ( $id ) {
+ my $new_value = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
+ $new_value->Load( $id );
+ my $ocfv_key = $new_value->GetOCFVCacheKey();
+ if ( $RT::ObjectCustomFieldValues::_OCFV_CACHE->{$ocfv_key} ) {
+ push @{ $RT::ObjectCustomFieldValues::_OCFV_CACHE->{$ocfv_key} },
+ {
+ 'ObjectId' => $new_value->Id,
+ 'CustomFieldObj' => $new_value->CustomFieldObj,
+ 'Content' => $new_value->_Value('Content'),
+ 'LargeContent' => $new_value->LargeContent,
+ };
+ }
+ }
+
+ return wantarray ? ( $id, $msg ) : $id;
}
@@ -288,7 +305,15 @@ Disable this value. Used to remove "current" values from records while leaving t
sub Delete {
my $self = shift;
- return $self->SetDisabled(1);
+ my ( $ret, $msg ) = $self->SetDisabled( 1 );
+ if ( $ret ) {
+ my $ocfv_key = $self->GetOCFVCacheKey();
+ if ( $RT::ObjectCustomFieldValues::_OCFV_CACHE->{$ocfv_key} ) {
+ @{ $RT::ObjectCustomFieldValues::_OCFV_CACHE->{$ocfv_key} } =
+ grep { $_->{'ObjectId'} != $self->Id } @{ $RT::ObjectCustomFieldValues::_OCFV_CACHE->{$ocfv_key} };
+ }
+ }
+ return wantarray ? ( $ret, $msg ) : $ret;
}
=head2 _FillInTemplateURL URL
@@ -481,6 +506,20 @@ sub ParseIP {
}
+=head2 GetOCFVCacheKey
+
+Get the OCFV cache key for this object
+
+=cut
+
+sub GetOCFVCacheKey {
+ my $self = shift;
+ my $ocfv_key = "CustomField-" . $self->CustomField
+ . '-ObjectType-' . $self->ObjectType
+ . '-ObjectId-' . $self->ObjectId;
+ return $ocfv_key;
+}
+
=head2 id
Returns the current value of id.