~bestpractical/rt/master

« back to all changes in this revision

Viewing changes to lib/RT/ObjectCustomFieldValue.pm

  • Committer: sunnavy
  • Date: 2023-10-19 19:45:11 UTC
  • mfrom: (8471.1.577)
  • Revision ID: git-v1:9fca83d11d15fb8034308194b9c9052d5df7d454
Merge branch '5.0-trunk'

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
 
214
214
=head2 CustomFieldObj
215
215
 
216
 
Returns the CustomField Object which has the id returned by CustomField
 
216
Returns the CustomField Object which has the id returned by CustomField.
 
217
 
 
218
CAVEAT: the returned object is cached, reload it to get the latest data.
217
219
 
218
220
=cut
219
221
 
220
222
sub CustomFieldObj {
221
223
    my $self = shift;
222
 
    my $CustomField = RT::CustomField->new( $self->CurrentUser );
223
 
    $CustomField->SetContextObject( $self->Object );
224
 
    $CustomField->Load( $self->__Value('CustomField') );
225
 
    return $CustomField;
 
224
    unless ( $self->{_cached}{CustomFieldObj} ) {
 
225
        $self->{_cached}{CustomFieldObj} = RT::CustomField->new( $self->CurrentUser );
 
226
        $self->{_cached}{CustomFieldObj}->SetContextObject( $self->Object );
 
227
        $self->{_cached}{CustomFieldObj}->Load( $self->__Value('CustomField') );
 
228
    }
 
229
    return $self->{_cached}{CustomFieldObj};
226
230
}
227
231
 
228
232
 
292
296
 
293
297
=head2 Object
294
298
 
295
 
Returns the object this value applies to
 
299
Returns the object this value applies to.
 
300
 
 
301
CAVEAT: the returned object is cached, reload it to get the latest data.
296
302
 
297
303
=cut
298
304
 
299
305
sub Object {
300
306
    my $self  = shift;
301
 
    my $Object = $self->__Value('ObjectType')->new( $self->CurrentUser );
302
 
    $Object->LoadById( $self->__Value('ObjectId') );
303
 
    return $Object;
 
307
    unless ( $self->{_cached}{Object} ) {
 
308
        $self->{_cached}{Object} = $self->__Value('ObjectType')->new( $self->CurrentUser );
 
309
        $self->{_cached}{Object}->LoadById( $self->__Value('ObjectId') );
 
310
    }
 
311
    return $self->{_cached}{Object};
304
312
}
305
313
 
306
314
 
815
823
 
816
824
sub CurrentUserCanSee {
817
825
    my $self = shift;
 
826
    return undef unless $self->Id;
818
827
    return $self->CustomFieldObj->CurrentUserHasRight('SeeCustomField');
819
828
}
820
829