X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fbanned_pay.pm;h=b93f67bbe714095585726dffae53c6dc6cf6185f;hb=dafdfc24616b04a5ff594da31e2cdd03f58634b6;hp=1ad87f508777f92c0381c050f9c2232f3df6bf27;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/FS/FS/banned_pay.pm b/FS/FS/banned_pay.pm index 1ad87f508..b93f67bbe 100644 --- a/FS/FS/banned_pay.pm +++ b/FS/FS/banned_pay.pm @@ -1,11 +1,11 @@ package FS::banned_pay; use strict; -use vars qw( @ISA ); +use base qw( FS::otaker_Mixin FS::Record ); +use Digest::MD5 qw(md5_base64); use FS::Record qw( qsearch qsearchs ); use FS::UID qw( getotaker ); - -@ISA = qw(FS::Record); +use FS::CurrentUser; =head1 NAME @@ -43,7 +43,11 @@ supported: =item _date - specified as a UNIX timestamp; see L. Also see L and L for conversion functions. -=item otaker - order taker (assigned automatically, see L) +=item end_date - optional end date, also specified as a UNIX timestamp. + +=item usernum - order taker (assigned automatically, see L) + +=item bantype - Ban type: "" or null (regular ban), "warn" (warning) =item reason - reason (text) @@ -111,19 +115,52 @@ sub check { || $self->ut_enum('payby', [ 'CARD', 'CHEK' ] ) || $self->ut_text('payinfo') || $self->ut_numbern('_date') + || $self->ut_numbern('end_date') + || $self->ut_enum('bantype', [ '', 'warn' ] ) || $self->ut_textn('reason') ; return $error if $error; $self->_date(time) unless $self->_date; - $self->otaker(getotaker); + $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; $self->SUPER::check; } =back +=head1 CLASS METHODS + +=item ban_search OPTION => VALUE ... + +Takes two parameters: payby and payinfo, and searches for an (un-expired) ban +matching those items. + +Returns the ban, or false if no ban was found. + +=cut + +sub ban_search { + my( $class, %opt ) = @_; + qsearchs({ + 'table' => 'banned_pay', + 'hashref' => { + 'payby' => $opt{payby}, + 'payinfo' => md5_base64($opt{payinfo}), + }, + 'extra_sql' => 'AND ( end_date IS NULL OR end_date >= '. time. ' ) ', + }); +} + +# Used by FS::Upgrade to migrate to a new database. +sub _upgrade_data { # class method + my ($class, %opts) = @_; + $class->_upgrade_otaker(%opts); +} + +=back + =head1 BUGS =head1 SEE ALSO