X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=4937347296c60effc9369fd08e76c670d39791f4;hb=d4cdc4db87f1b6a373398b7ab33e791bd0527dda;hp=3e3af524cf1c7174ec540023e3d4841c45907f39;hpb=fdbee9ee821385bfbd9578f940eeb8ca74cb9eff;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 3e3af524c..493734729 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1,22 +1,22 @@ package FS::Record; +use base qw( Exporter ); use strict; -use vars qw( $AUTOLOAD @ISA @EXPORT_OK $DEBUG - $conf $conf_encryption $me +use vars qw( $AUTOLOAD %virtual_fields_cache - $nowarn_identical $nowarn_classload - $no_update_diff $no_check_foreign + $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 Locale::Country; use Text::CSV_XS; -use File::Slurp qw( slurp ); use DBI qw(:sql_types); -use DBIx::DBSchema 0.33; -use FS::UID qw(dbh getotaker datasrc driver_name); +use DBIx::DBSchema 0.43; #0.43 for foreign keys +use Locale::Country; +use Locale::Currency; +use NetAddr::IP; # for validation +use FS::UID qw(dbh datasrc driver_name); use FS::CurrentUser; use FS::Schema qw(dbdef); use FS::SearchCache; @@ -27,35 +27,53 @@ use FS::part_virtual_field; use Tie::IxHash; -@ISA = qw(Exporter); +our @encrypt_payby = qw( CARD DCRD CHEK DCHK ); #export dbdef for now... everything else expects to find it here -@EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef jsearch - str2time_sql str2time_sql_closing ); +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]'; -$nowarn_identical = 0; -$nowarn_classload = 0; -$no_update_diff = 0; -$no_check_foreign = 0; +our $nowarn_identical = 0; +our $nowarn_classload = 0; +our $no_update_diff = 0; +our $no_history = 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;"; die $@ if $@; $conf = FS::Conf->new; $conf_encryption = $conf->exists('encryption'); + $money_char = $conf->config('money_char') || '$'; + my $nw_coords = $conf->exists('geocode-require_nw_coordinates'); + $lat_lower = $nw_coords ? 1 : -90; + $lon_upper = $nw_coords ? -1 : 180; + $File::CounterFile::DEFAULT_DIR = $conf->base_dir . "/counters.". datasrc; -} ); + if ( driver_name eq 'Pg' ) { + eval "use DBD::Pg ':pg_types'"; + die $@ if $@; + } else { + eval "sub PG_BYTEA { die 'guru meditation #9: calling PG_BYTEA when not running Pg?'; }"; + } + +} ); =head1 NAME @@ -239,6 +257,9 @@ fine in the common case where there are only two parameters: my @records = qsearch( 'table', { 'field' => 'value' } ); +Also possible is an experimental LISTREF of PARAMS_HASHREFs for a UNION of +the individual PARAMS_HASHREF queries + ###oops, argh, FS::Record::new only lets us create database fields. #Normal behaviour if SELECT is not specified is `*', as in #C