X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=db940034d85fabcd9e4078639191496318d0b73c;hb=d49cc12aee7462cb3f0cc1073777f1e5c3dbb7f4;hp=0480a397f3f2e44bb057146aed8452169a712772;hpb=327fbdcae418952049c9a8cb5b93165cd03f649a;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 0480a397f..db940034d 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1555,6 +1555,20 @@ sub ut_alphan { ''; } +=item ut_alpha_lower COLUMN + +Check/untaint lowercase alphanumeric strings (no spaces). May not be null. If +there is an error, returns the error, otherwise returns false. + +=cut + +sub ut_alpha_lower { + my($self,$field)=@_; + $self->getfield($field) =~ /[[:upper:]]/ + and return "Uppercase characters are not permitted in $field"; + $self->ut_alpha($field); +} + =item ut_phonen COLUMN [ COUNTRY ] Check/untaint phone numbers. May be null. If there is an error, returns @@ -2131,6 +2145,19 @@ sub h_search { } +=item h_date ACTION + +Given an ACTION, either "insert", or "delete", returns the timestamp of the +appropriate history record corresponding to this record, if any. + +=cut + +sub h_date { + my($self, $action) = @_; + my $h = $self->h_search($action); + $h ? $h->history_date : ''; +} + =back =head1 SUBROUTINES @@ -2225,9 +2252,9 @@ sub DESTROY { return; } =item str2time_sql [ DRIVER_NAME ] Returns a function to convert to unix time based on database type, such as -"EXTRACT( EPOCH FROM" for Pg or "UNIX_TIMESTAMP(" for mysql. You are -responsible for the closing parenthesis yourself. Don't let it down. It's a -sensitive parenthesis. +"EXTRACT( EPOCH FROM" for Pg or "UNIX_TIMESTAMP(" for mysql. See +the str2time_sql_closing method to return a closing string rather than just +using a closing parenthesis as previously suggested. You can pass an optional driver name such as "Pg", "mysql" or $dbh->{Driver}->{Name} to return a function for that database instead of @@ -2247,6 +2274,24 @@ sub str2time_sql { } +=item str2time_sql_closing [ DRIVER_NAME ] + +Returns the closing suffix of a function to convert to unix time based on +database type, such as ")::integer" for Pg or ")" for mysql. + +You can pass an optional driver name such as "Pg", "mysql" or +$dbh->{Driver}->{Name} to return a function for that database instead of +the current database. + +=cut + +sub str2time_sql_closing { + my $driver = shift || driver_name; + + return ' )::INTEGER ' if $driver =~ /^Pg/i; + return ' ) '; +} + =back =head1 BUGS