summaryrefslogtreecommitdiff
path: root/FS/FS/banned_pay.pm
diff options
context:
space:
mode:
authorivan <ivan>2011-07-15 21:10:40 +0000
committerivan <ivan>2011-07-15 21:10:40 +0000
commit0e7c29b192fff137d3b9167b29633a94f94b995f (patch)
tree7bf403bd486c7266d533c1f5d7af0bdb80eb07d3 /FS/FS/banned_pay.pm
parent945580551410383965a86beadb095a760fa4ce5b (diff)
add signup-duplicate_cc-warn_hours to warn about duplicate signups in a time span, RT#12011
Diffstat (limited to 'FS/FS/banned_pay.pm')
-rw-r--r--FS/FS/banned_pay.pm32
1 files changed, 32 insertions, 0 deletions
diff --git a/FS/FS/banned_pay.pm b/FS/FS/banned_pay.pm
index 3379653..9df04d1 100644
--- a/FS/FS/banned_pay.pm
+++ b/FS/FS/banned_pay.pm
@@ -2,6 +2,7 @@ package FS::banned_pay;
use strict;
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 );
use FS::CurrentUser;
@@ -42,8 +43,12 @@ supported:
=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
L<Time::Local> and L<Date::Parse> for conversion functions.
+=item end_date - optional end date, also specified as a UNIX timestamp.
+
=item usernum - order taker (assigned automatically, see L<FS::access_user>)
+=item bantype - Ban type: "" or null (regular ban), "warn" (warning)
+
=item reason - reason (text)
=back
@@ -110,6 +115,8 @@ 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;
@@ -121,6 +128,31 @@ sub check {
$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) = @_;