X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FObjectCustomFieldValue.pm;h=af740e967716f667680704bcbdcf9611b29a0222;hb=ed1f84b4e8f626245995ecda5afcf83092c153b2;hp=de4bc748dd9d6423cdae0b85547c222bf8087d48;hpb=e9e0cf0989259b94d9758eceff448666a2e5a5cc;p=freeside.git diff --git a/rt/lib/RT/ObjectCustomFieldValue.pm b/rt/lib/RT/ObjectCustomFieldValue.pm index de4bc748d..af740e967 100644 --- a/rt/lib/RT/ObjectCustomFieldValue.pm +++ b/rt/lib/RT/ObjectCustomFieldValue.pm @@ -84,38 +84,14 @@ 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'}); + my ($val, $msg) = $cf->_CanonicalizeValue(\%args); + return ($val, $msg) unless $val; - 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; - } - } - - if ( defined $args{'Content'} && length( Encode::encode_utf8($args{'Content'}) ) > 255 ) { + my $encoded = Encode::encode("UTF-8", $args{'Content'}); + if ( defined $args{'Content'} && length( $encoded ) > 255 ) { if ( defined $args{'LargeContent'} && length $args{'LargeContent'} ) { $RT::Logger->error("Content is longer than 255 bytes and LargeContent specified"); } @@ -164,16 +140,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); }