X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Flib%2FRT%2FCustomField.pm;h=ff1eec9b3fee2a94c24af078a55ae30ba28dff86;hb=008524b8e963831999983769f7fec11f55a72f16;hp=e71bbf78adb50f1517bd59d60dbf1cf21619856b;hpb=d10fe3d48da3f3bdb423efe42d624e9d1013c958;p=freeside.git diff --git a/rt/lib/RT/CustomField.pm b/rt/lib/RT/CustomField.pm index e71bbf78a..ff1eec9b3 100644 --- a/rt/lib/RT/CustomField.pm +++ b/rt/lib/RT/CustomField.pm @@ -1547,12 +1547,6 @@ sub AddValueForObject { } } - if (my $canonicalizer = $self->can('_CanonicalizeValue'.$self->Type)) { - $canonicalizer->($self, \%args); - } - - - my $newval = RT::ObjectCustomFieldValue->new( $self->CurrentUser ); my ($val, $msg) = $newval->Create( ObjectType => ref($obj), @@ -1574,6 +1568,17 @@ sub AddValueForObject { } +sub _CanonicalizeValue { + my $self = shift; + my $args = shift; + + my $type = $self->_Value('Type'); + return 1 unless $type; + + my $method = '_CanonicalizeValue'. $type; + return 1 unless $self->can($method); + $self->$method($args); +} sub _CanonicalizeValueDateTime { my $self = shift; @@ -1582,6 +1587,7 @@ sub _CanonicalizeValueDateTime { $DateObj->Set( Format => 'unknown', Value => $args->{'Content'} ); $args->{'Content'} = $DateObj->ISO; + return 1; } # For date, we need to store Content as ISO date @@ -1596,6 +1602,33 @@ sub _CanonicalizeValueDate { Value => $args->{'Content'}, ); $args->{'Content'} = $DateObj->Date( Timezone => 'user' ); + return 1; +} + +sub _CanonicalizeValueIPAddress { + my $self = shift; + my $args = shift; + + $args->{Content} = RT::ObjectCustomFieldValue->ParseIP( $args->{Content} ); + return (0, $self->loc("Content is not a valid IP address")) + unless $args->{Content}; + return 1; +} + +sub _CanonicalizeValueIPAddressRange { + my $self = shift; + my $args = shift; + + my $content = $args->{Content}; + $content .= "-".$args->{LargeContent} if $args->{LargeContent}; + + ($args->{Content}, $args->{LargeContent}) + = RT::ObjectCustomFieldValue->ParseIPRange( $content ); + + $args->{ContentType} = 'text/plain'; + return (0, $self->loc("Content is not a valid IP address range")) + unless $args->{Content}; + return 1; } =head2 MatchPattern STRING