1 package FS::mailinglistmember;
4 use base qw( FS::Record );
5 use Scalar::Util qw( blessed );
6 use FS::Record qw( dbh qsearchs ); # qsearch );
13 FS::mailinglistmember - Object methods for mailinglistmember records
17 use FS::mailinglistmember;
19 $record = new FS::mailinglistmember \%hash;
20 $record = new FS::mailinglistmember { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::mailinglistmember object represents a mailing list member.
33 FS::mailinglistmember inherits from FS::Record. The following fields are
67 Creates a new mailing list member. To add the member to the database, see
70 Note that this stores the hash reference, not a distinct copy of the hash it
71 points to. You can ask the object for a copy with the I<hash> method.
75 # the new method can be inherited from FS::Record, if a table method is defined
77 sub table { 'mailinglistmember'; }
81 Adds this record to the database. If there is an error, returns the error,
82 otherwise returns false.
89 local $SIG{HUP} = 'IGNORE';
90 local $SIG{INT} = 'IGNORE';
91 local $SIG{QUIT} = 'IGNORE';
92 local $SIG{TERM} = 'IGNORE';
93 local $SIG{TSTP} = 'IGNORE';
94 local $SIG{PIPE} = 'IGNORE';
96 my $oldAutoCommit = $FS::UID::AutoCommit;
97 local $FS::UID::AutoCommit = 0;
100 my $error = $self->SUPER::insert
101 || $self->export('mailinglistmember_insert');
103 $dbh->rollback if $oldAutoCommit;
107 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
113 Delete this record from the database.
120 local $SIG{HUP} = 'IGNORE';
121 local $SIG{INT} = 'IGNORE';
122 local $SIG{QUIT} = 'IGNORE';
123 local $SIG{TERM} = 'IGNORE';
124 local $SIG{TSTP} = 'IGNORE';
125 local $SIG{PIPE} = 'IGNORE';
127 my $oldAutoCommit = $FS::UID::AutoCommit;
128 local $FS::UID::AutoCommit = 0;
131 my $error = $self->SUPER::delete
132 || $self->export('mailinglistmember_delete');
134 $dbh->rollback if $oldAutoCommit;
138 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
142 =item replace OLD_RECORD
144 Replaces the OLD_RECORD with this one in the database. If there is an error,
145 returns the error, otherwise returns false.
152 my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') )
156 local $SIG{HUP} = 'IGNORE';
157 local $SIG{INT} = 'IGNORE';
158 local $SIG{QUIT} = 'IGNORE';
159 local $SIG{TERM} = 'IGNORE';
160 local $SIG{TSTP} = 'IGNORE';
161 local $SIG{PIPE} = 'IGNORE';
163 my $oldAutoCommit = $FS::UID::AutoCommit;
164 local $FS::UID::AutoCommit = 0;
167 my $error = $new->SUPER::replace($old)
168 || $new->export('mailinglistmember_replace', $old);
170 $dbh->rollback if $oldAutoCommit;
174 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
180 Checks all fields to make sure this is a valid member. If there is
181 an error, returns the error, otherwise returns false. Called by the insert
186 # the check method should currently be supplied - FS::Record contains some
187 # data checking routines
193 $self->ut_numbern('membernum')
194 || $self->ut_foreign_key('listnum', 'mailinglist', 'listnum')
195 || $self->ut_foreign_keyn('svcnum', 'svc_acct', 'svcnum')
196 || $self->ut_foreign_keyn('contactemailnum', 'contact_email', 'contactemailnum')
197 || $self->ut_textn('email') #XXX ut_email! from svc_forward, cust_main_invoice
199 return $error if $error;
210 qsearchs('mailinglist', { 'listnum' => $self->listnum } );
219 #XXX svcnum, contactemailnum
228 my( $self, $method ) = ( shift, shift );
229 my $svc_mailinglist = $self->mailinglist->svc_mailinglist
231 $svc_mailinglist->export($method, $self, @_);
240 L<FS::Record>, schema.html from the base documentation.