[Rt-commit] rt branch, 4.4/skip-rights-check-on-setting-ocf-default-values, created. rt-4.4.3-200-g57f024551
? sunnavy
sunnavy at bestpractical.com
Wed Feb 27 14:09:58 EST 2019
The branch, 4.4/skip-rights-check-on-setting-ocf-default-values has been created
at 57f024551e1417980189f561ccd9a3aef481a946 (commit)
- Log -----------------------------------------------------------------
commit 57f024551e1417980189f561ccd9a3aef481a946
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Feb 28 02:56:00 2019 +0800
Skip rights check when setting default object custom field values
Default values are fallbacks and we should fall back to them
unconditionally on object create, even if current user doesn't have
rights to see/modify them.
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 0cc188463..81c068ca0 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2117,19 +2117,23 @@ Add default values to object's empty custom fields.
sub AddCustomFieldDefaultValues {
my $self = shift;
- my $cfs = $self->CustomFields;
+
+ my $object = ( ref $self )->new( RT->SystemUser );
+ $object->Load( $self->id );
+
+ my $cfs = $object->CustomFields;
my @msgs;
while ( my $cf = $cfs->Next ) {
- next if $self->CustomFieldValues($cf->id)->Count || !$cf->SupportDefaultValues;
+ next if $object->CustomFieldValues($cf->id)->Count || !$cf->SupportDefaultValues;
my ( $on ) = grep { $_->isa( $cf->RecordClassFromLookupType ) } $cf->ACLEquivalenceObjects;
my $values = $cf->DefaultValues( Object => $on || RT->System );
foreach my $value ( UNIVERSAL::isa( $values => 'ARRAY' ) ? @$values : $values ) {
- next if $self->CustomFieldValueIsEmpty(
+ next if $object->CustomFieldValueIsEmpty(
Field => $cf,
Value => $value,
);
- my ( $status, $msg ) = $self->_AddCustomFieldValue(
+ my ( $status, $msg ) = $object->_AddCustomFieldValue(
Field => $cf->id,
Value => $value,
RecordTransaction => 0,
-----------------------------------------------------------------------
More information about the rt-commit
mailing list