diff options
author | ivan <ivan> | 2000-06-27 12:15:37 +0000 |
---|---|---|
committer | ivan <ivan> | 2000-06-27 12:15:37 +0000 |
commit | b84f789033eba9a0fc74bca5a071cfefd87f3c69 (patch) | |
tree | 174281a8636262a2fb4bb0d0d834a26e76121b64 | |
parent | 064b854f445b96607bb1193bb277f44a5b84b00a (diff) |
i18
-rw-r--r-- | FS/FS/Record.pm | 16 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 14 |
2 files changed, 20 insertions, 10 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 69913c18d..12cc77ebf 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -8,7 +8,6 @@ use Carp qw(carp cluck croak confess); use File::CounterFile; use FS::UID qw(dbh checkruid swapuid getotaker datasrc driver_name); use FS::dbdef; -use diagnostics; @ISA = qw(Exporter); @EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef); @@ -694,25 +693,32 @@ sub ut_alphan { ''; } -=item ut_phonen COLUMN +=item ut_phonen COLUMN [ COUNTRY ] Check/untaint phone numbers. May be null. If there is an error, returns the error, otherwise returns false. +Takes an optional two-letter ISO country code; without it or with unsupported +countries, ut_phonen simply calls ut_alphan. + =cut sub ut_phonen { - my($self,$field)=@_; + my( $self, $field, $country ) = @_; + return $self->ut_alphan($field) unless defined $country; my $phonen = $self->getfield($field); if ( $phonen eq '' ) { $self->setfield($field,''); - } else { + } elsif ( $country eq 'US' ) { $phonen =~ s/\D//g; $phonen =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ or return "Illegal (phone) $field: ". $self->getfield($field); $phonen = "$1-$2-$3"; $phonen .= " x$4" if $4; $self->setfield($field,$phonen); + } else { + warn "don't know how to check phone numbers for country $country"; + return $self->ut_alphan($field); } ''; } @@ -841,7 +847,7 @@ sub hfields { =head1 VERSION -$Id: Record.pm,v 1.6 2000-06-27 11:29:52 ivan Exp $ +$Id: Record.pm,v 1.7 2000-06-27 12:15:37 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 2a8a8b7ee..b863748a0 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -312,9 +312,6 @@ sub check { || $self->ut_text('city') || $self->ut_textn('county') || $self->ut_textn('state') - || $self->ut_phonen('daytime') - || $self->ut_phonen('night') - || $self->ut_phonen('fax') ; return $error if $error; @@ -357,7 +354,14 @@ sub check { } ); } - $self->zip =~ /^\s*(\w[\w\-\s]{3,8}\w)\s*$/ + $error = + $self->ut_phonen('daytime', $self->country) + || $self->ut_phonen('night', $self->country) + || $self->ut_phonen('fax', $self->country) + ; + return $error if $error; + + $self->zip =~ /^\s*(\w[\w\-\s]{2,8}\w)\s*$/ or return "Illegal zip: ". $self->zip; $self->zip($1); @@ -995,7 +999,7 @@ sub check_invoicing_list { =head1 VERSION -$Id: cust_main.pm,v 1.6 2000-06-24 00:28:30 ivan Exp $ +$Id: cust_main.pm,v 1.7 2000-06-27 12:15:37 ivan Exp $ =head1 BUGS |