diff options
author | ivan <ivan> | 2010-01-17 02:34:33 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-01-17 02:34:33 +0000 |
commit | 2d8321656d02dd61851dd15afc32ba679eccb410 (patch) | |
tree | 23c72607d5d4bbd93015c6fc1634bbf86af3653f | |
parent | 8c6abf72b58d9f24c659f3543d0a3071d9907824 (diff) |
strip non-digits and 1- when searching for phone numbers, RT#7000
-rw-r--r-- | FS/FS/svc_phone.pm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 11a5a0ee0..88582d393 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -120,6 +120,22 @@ Class method which returns an SQL fragment to search for the given string. sub search_sql { my( $class, $string ) = @_; + + if ( $conf->exists('svc_phone-allow_alpha_phonenum') ) { + $string =~ s/\W//g; + } else { + $string =~ s/\D//g; + } + + my $conf = new FS::Conf; + my $ccode = ( $conf->exists('default_phone_countrycode') + && $conf->config('default_phone_countrycode') + ) + ? $conf->config('default_phone_countrycode') + : '1'; + + $string =~ s/^$ccode//; + $class->search_sql_field('phonenum', $string ); } |