X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fmailinglistmember.pm;h=5986bba6439cbca539e5114975874ad16b69af7a;hb=3cbdd85a96348a287623e3b97c937c7749e99392;hp=ca73b888b194195411fc94b10eb0f24dfc05c0a9;hpb=7167be4668e6187ac55126791ca9b74cd5fb27e8;p=freeside.git diff --git a/FS/FS/mailinglistmember.pm b/FS/FS/mailinglistmember.pm index ca73b888b..5986bba64 100644 --- a/FS/FS/mailinglistmember.pm +++ b/FS/FS/mailinglistmember.pm @@ -1,11 +1,9 @@ package FS::mailinglistmember; +use base qw(FS::Record); use strict; -use base qw( FS::Record ); -use FS::Record qw( qsearchs ); # qsearch ); -use FS::mailinglist; -use FS::svc_acct; -use FS::contact_email; +use Scalar::Util qw( blessed ); +use FS::Record qw( dbh ); # qsearch qsearchs dbh ); =head1 NAME @@ -82,7 +80,30 @@ otherwise returns false. =cut -# the insert method can be inherited from FS::Record +sub insert { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $error = $self->SUPER::insert + || $self->export('mailinglistmember_insert'); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} =item delete @@ -90,7 +111,30 @@ Delete this record from the database. =cut -# the delete method can be inherited from FS::Record +sub delete { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $error = $self->SUPER::delete + || $self->export('mailinglistmember_delete'); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} =item replace OLD_RECORD @@ -99,7 +143,34 @@ returns the error, otherwise returns false. =cut -# the replace method can be inherited from FS::Record +sub replace { + my $new = shift; + + my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') ) + ? shift + : $new->replace_old; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $error = $new->SUPER::replace($old) + || $new->export('mailinglistmember_replace', $old); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} =item check @@ -129,11 +200,25 @@ sub check { =item mailinglist +=item email_address + =cut -sub mailinglist { +sub email_address { my $self = shift; - qsearchs('mailinglist', { 'listnum' => $self->listnum } ); + #XXX svcnum, contactemailnum + $self->email; +} + +=item export + +=cut + +sub export { + my( $self, $method ) = ( shift, shift ); + my $svc_mailinglist = $self->mailinglist->svc_mailinglist + or return ''; + $svc_mailinglist->export($method, $self, @_); } =back