diff options
Diffstat (limited to 'rt/lib/RT/ObjectCustomFieldValue.pm')
-rw-r--r-- | rt/lib/RT/ObjectCustomFieldValue.pm | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/rt/lib/RT/ObjectCustomFieldValue.pm b/rt/lib/RT/ObjectCustomFieldValue.pm index de4bc748d..0e63ced1b 100644 --- a/rt/lib/RT/ObjectCustomFieldValue.pm +++ b/rt/lib/RT/ObjectCustomFieldValue.pm @@ -84,36 +84,11 @@ sub Create { @_, ); + my $cf = RT::CustomField->new( $self->CurrentUser ); + $cf->Load( $args{CustomField} ); - my $cf_as_sys = RT::CustomField->new(RT->SystemUser); - $cf_as_sys->Load($args{'CustomField'}); - - if($cf_as_sys->Type eq 'IPAddress') { - if ( $args{'Content'} ) { - $args{'Content'} = $self->ParseIP( $args{'Content'} ); - } - - unless ( defined $args{'Content'} ) { - return - wantarray - ? ( 0, $self->loc("Content is an invalid IP address") ) - : 0; - } - } - - if($cf_as_sys->Type eq 'IPAddressRange') { - if ($args{'Content'}) { - ($args{'Content'}, $args{'LargeContent'}) = $self->ParseIPRange( $args{'Content'} ); - } - $args{'ContentType'} = 'text/plain'; - - unless ( defined $args{'Content'} ) { - return - wantarray - ? ( 0, $self->loc("Content is an invalid IP address range") ) - : 0; - } - } + my ($val, $msg) = $cf->_CanonicalizeValue(\%args); + return ($val, $msg) unless $val; if ( defined $args{'Content'} && length( Encode::encode_utf8($args{'Content'}) ) > 255 ) { if ( defined $args{'LargeContent'} && length $args{'LargeContent'} ) { @@ -164,16 +139,9 @@ sub LoadByCols { if ( $args{CustomField} ) { $cf = RT::CustomField->new( $self->CurrentUser ); $cf->Load( $args{CustomField} ); - if ( $cf->Type && $cf->Type eq 'IPAddressRange' ) { - - my ( $sIP, $eIP ) = $cf->ParseIPRange( $args{'Content'} ); - if ( $sIP && $eIP ) { - $self->SUPER::LoadByCols( %args, - Content => $sIP, - LargeContent => $eIP - ); - } - } + + my ($ok, $msg) = $cf->_CanonicalizeValue(\%args); + return ($ok, $msg) unless $ok; } return $self->SUPER::LoadByCols(%args); } |