X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=b476df2c0cd2f0509f28188d22a4059829ea4b3a;hp=9a532e3a068d176ce825887f9a8c205f811f370b;hb=f5266a4d07d116efd732f433d0f4f3a47b143a7d;hpb=85e59606c0b5eed9780534ffaf554aa32bcf9baf diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 9a532e3a0..b476df2c0 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -855,13 +855,30 @@ Untaints arbitrary data. Be careful. =cut sub ut_anything { - my($self,$field)=@_; + my( $self, $field ) = @_; $self->getfield($field) =~ /^(.*)$/s or return "Illegal $field: ". $self->getfield($field); $self->setfield($field,$1); ''; } +=item ut_enum COLUMN CHOICES_ARRAYREF + +Check/untaint a column, supplying all possible choices, like the "enum" type. + +=cut + +sub ut_enum { + my( $self, $field, $choices ) = @_; + foreach my $choice ( @$choices ) { + if ( $self->getfield($field) eq $choice ) { + $self->setfield($choice); + return ''; + } + } + return "Illegal (enum) field $field: ". $self->getfield($field); +} + =item fields [ TABLE ] This can be used as both a subroutine and a method call. It returns a list @@ -976,7 +993,7 @@ sub DESTROY { return; } =head1 VERSION -$Id: Record.pm,v 1.26 2001-08-31 09:20:35 ivan Exp $ +$Id: Record.pm,v 1.27 2001-09-11 00:08:18 ivan Exp $ =head1 BUGS