X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=7e9a2e090963c8a1fa3c3c7ed952f7d0cf1585bf;hb=dd9a0ea1c8351841c8d41ab46e94abbdb0c75db4;hp=b1e4a381c4054ed5e6a3404a839a92d4e9c2c7a5;hpb=529c23d58c97eca1d71df865988def671bfbd2cb;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index b1e4a381c..7e9a2e090 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1,6 +1,7 @@ package FS::Record; use strict; +use charnames ':full'; use vars qw( $AUTOLOAD @ISA @EXPORT_OK $DEBUG %virtual_fields_cache $money_char $lat_lower $lon_upper @@ -73,8 +74,8 @@ FS::UID->install_callback( sub { $conf = FS::Conf->new; $conf_encryption = $conf->exists('encryption'); $conf_encryptionmodule = $conf->config('encryptionmodule'); - $conf_encryptionpublickey = $conf->config('encryptionpublickey'); - $conf_encryptionprivatekey = $conf->config('encryptionprivatekey'); + $conf_encryptionpublickey = join("\n",$conf->config('encryptionpublickey')); + $conf_encryptionprivatekey = join("\n",$conf->config('encryptionprivatekey')); $money_char = $conf->config('money_char') || '$'; my $nw_coords = $conf->exists('geocode-require_nw_coordinates'); $lat_lower = $nw_coords ? 1 : -90; @@ -204,6 +205,7 @@ sub new { $self->{'modified'} = 0; + $self->_simplecache($self->{'Hash'}) if $self->can('_simplecache'); $self->_cache($self->{'Hash'}, shift) if $self->can('_cache') && @_; $self; @@ -519,6 +521,7 @@ sub qsearch { # Check for encrypted fields and decrypt them. ## only in the local copy, not the cached object + no warnings 'deprecated'; # XXX silence the warning for now if ( $conf_encryption && eval 'defined(@FS::'. $table . '::encrypted_fields)' ) { foreach my $record (@return) { @@ -1162,8 +1165,7 @@ sub insert { my $table = $self->table; # Encrypt before the database - if ( defined(eval '@FS::'. $table . '::encrypted_fields') - && scalar( eval '@FS::'. $table . '::encrypted_fields') + if ( scalar( eval '@FS::'. $table . '::encrypted_fields') && $conf_encryption ) { foreach my $field (eval '@FS::'. $table . '::encrypted_fields') { @@ -1405,9 +1407,8 @@ sub replace { # Encrypt for replace my $saved = {}; - if ( $conf_encryption - && defined(eval '@FS::'. $new->table . '::encrypted_fields') - && scalar( eval '@FS::'. $new->table . '::encrypted_fields') + if ( scalar( eval '@FS::'. $new->table . '::encrypted_fields') + && $conf_encryption ) { foreach my $field (eval '@FS::'. $new->table . '::encrypted_fields') { next if $field eq 'payinfo' @@ -2721,6 +2722,10 @@ sub ut_coord { my $coord = $self->getfield($field); my $neg = $coord =~ s/^(-)//; + # ignore degree symbol at the end, + # but not otherwise supporting degree/minutes/seconds symbols + $coord =~ s/\N{DEGREE SIGN}\s*$//; + my ($d, $m, $s) = (0, 0, 0); if ( @@ -3029,6 +3034,22 @@ sub ut_agentnum_acl { } +=item trim_whitespace FIELD[, FIELD ... ] + +Strip leading and trailing spaces from the value in the named FIELD(s). + +=cut + +sub trim_whitespace { + my $self = shift; + foreach my $field (@_) { + my $value = $self->get($field); + $value =~ s/^\s+//; + $value =~ s/\s+$//; + $self->set($field, $value); + } +} + =item fields [ TABLE ] This is a wrapper for real_fields. Code that called @@ -3137,14 +3158,12 @@ sub loadRSA { } # Initialize Encryption if ($conf_encryptionpublickey && $conf_encryptionpublickey ne '') { - my $public_key = join("\n",$conf_encryptionpublickey); - $rsa_encrypt = $rsa_module->new_public_key($public_key); + $rsa_encrypt = $rsa_module->new_public_key($conf_encryptionpublickey); } # Intitalize Decryption if ($conf_encryptionprivatekey && $conf_encryptionprivatekey ne '') { - my $private_key = join("\n",$conf_encryptionprivatekey); - $rsa_decrypt = $rsa_module->new_private_key($private_key); + $rsa_decrypt = $rsa_module->new_private_key($conf_encryptionprivatekey); } }