X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=4937347296c60effc9369fd08e76c670d39791f4;hb=d4cdc4db87f1b6a373398b7ab33e791bd0527dda;hp=35240d4525cb27ca1bb417aeefec71e81f8bd1a3;hpb=b8fdc26451c2ed4149d667c835f80add626dd4e1;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 35240d452..493734729 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1,22 +1,18 @@ package FS::Record; +use base qw( Exporter ); use strict; -use vars qw( $AUTOLOAD @ISA @EXPORT_OK $DEBUG +use vars qw( $AUTOLOAD %virtual_fields_cache - $conf $conf_encryption $money_char $lat_lower $lon_upper - $me - $nowarn_identical $nowarn_classload - $no_update_diff $no_check_foreign - @encrypt_payby + $money_char $lat_lower $lon_upper ); -use Exporter; use Carp qw(carp cluck croak confess); use Scalar::Util qw( blessed ); use File::Slurp qw( slurp ); use File::CounterFile; use Text::CSV_XS; use DBI qw(:sql_types); -use DBIx::DBSchema 0.38; +use DBIx::DBSchema 0.43; #0.43 for foreign keys use Locale::Country; use Locale::Currency; use NetAddr::IP; # for validation @@ -31,32 +27,32 @@ use FS::part_virtual_field; use Tie::IxHash; -@ISA = qw(Exporter); - -@encrypt_payby = qw( CARD DCRD CHEK DCHK ); +our @encrypt_payby = qw( CARD DCRD CHEK DCHK ); #export dbdef for now... everything else expects to find it here -@EXPORT_OK = qw( +our @EXPORT_OK = qw( dbh fields hfields qsearch qsearchs dbdef jsearch str2time_sql str2time_sql_closing regexp_sql not_regexp_sql concat_sql midnight_sql ); -$DEBUG = 0; -$me = '[FS::Record]'; +our $DEBUG = 0; +our $me = '[FS::Record]'; + +our $nowarn_identical = 0; +our $nowarn_classload = 0; +our $no_update_diff = 0; +our $no_history = 0; -$nowarn_identical = 0; -$nowarn_classload = 0; -$no_update_diff = 0; -$no_check_foreign = 0; +our $no_check_foreign = 1; #well, not inefficiently in perl by default anymore my $rsa_module; my $rsa_loaded; my $rsa_encrypt; my $rsa_decrypt; -$conf = ''; -$conf_encryption = ''; +our $conf = ''; +our $conf_encryption = ''; FS::UID->install_callback( sub { eval "use FS::Conf;"; @@ -506,7 +502,7 @@ sub qsearch { # Check for encrypted fields and decrypt them. ## only in the local copy, not the cached object if ( $conf_encryption - && eval 'defined(@FS::'. $table . '::encrypted_fields)' ) { + && eval '@FS::'. $table . '::encrypted_fields' ) { foreach my $record (@return) { foreach my $field (eval '@FS::'. $table . '::encrypted_fields') { next if $field eq 'payinfo' @@ -715,7 +711,7 @@ sub _from_hashref { # Check for encrypted fields and decrypt them. ## only in the local copy, not the cached object if ( $conf_encryption - && eval 'defined(@FS::'. $table . '::encrypted_fields)' ) { + && eval '@FS::'. $table . '::encrypted_fields' ) { foreach my $record (@return) { foreach my $field (eval '@FS::'. $table . '::encrypted_fields') { next if $field eq 'payinfo' @@ -1255,7 +1251,7 @@ sub insert { } my $h_sth; - if ( defined dbdef->table('h_'. $table) ) { + if ( defined( dbdef->table('h_'. $table) ) && ! $no_history ) { my $h_statement = $self->_h_statement('insert'); warn "[debug]$me $h_statement\n" if $DEBUG > 2; $h_sth = dbh->prepare($h_statement) or do { @@ -3008,7 +3004,7 @@ You should generally not have to worry about calling this, as the system handles sub encrypt { my ($self, $value) = @_; - my $encrypted; + my $encrypted = $value; if ($conf->exists('encryption')) { if ($self->is_encrypted($value)) { @@ -3038,13 +3034,8 @@ Checks to see if the string is encrypted and returns true or false (1/0) to indi sub is_encrypted { my ($self, $value) = @_; - # Possible Bug - Some work may be required here.... - - if ($value =~ /^M/ && length($value) > 80) { - return 1; - } else { - return 0; - } + # could be more precise about it, but this will do for now + $value =~ /^M/ && length($value) > 80; } =item decrypt($value)