1 package FS::mailinglistmember;
2 use base qw(FS::Record);
5 use Scalar::Util qw( blessed );
6 use FS::Record qw( dbh ); # qsearch qsearchs dbh );
10 FS::mailinglistmember - Object methods for mailinglistmember records
14 use FS::mailinglistmember;
16 $record = new FS::mailinglistmember \%hash;
17 $record = new FS::mailinglistmember { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::mailinglistmember object represents a mailing list member.
30 FS::mailinglistmember inherits from FS::Record. The following fields are
64 Creates a new mailing list member. To add the member to the database, see
67 Note that this stores the hash reference, not a distinct copy of the hash it
68 points to. You can ask the object for a copy with the I<hash> method.
72 # the new method can be inherited from FS::Record, if a table method is defined
74 sub table { 'mailinglistmember'; }
78 Adds this record to the database. If there is an error, returns the error,
79 otherwise returns false.
86 local $SIG{HUP} = 'IGNORE';
87 local $SIG{INT} = 'IGNORE';
88 local $SIG{QUIT} = 'IGNORE';
89 local $SIG{TERM} = 'IGNORE';
90 local $SIG{TSTP} = 'IGNORE';
91 local $SIG{PIPE} = 'IGNORE';
93 my $oldAutoCommit = $FS::UID::AutoCommit;
94 local $FS::UID::AutoCommit = 0;
97 my $error = $self->SUPER::insert
98 || $self->export('mailinglistmember_insert');
100 $dbh->rollback if $oldAutoCommit;
104 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
110 Delete this record from the database.
117 local $SIG{HUP} = 'IGNORE';
118 local $SIG{INT} = 'IGNORE';
119 local $SIG{QUIT} = 'IGNORE';
120 local $SIG{TERM} = 'IGNORE';
121 local $SIG{TSTP} = 'IGNORE';
122 local $SIG{PIPE} = 'IGNORE';
124 my $oldAutoCommit = $FS::UID::AutoCommit;
125 local $FS::UID::AutoCommit = 0;
128 my $error = $self->SUPER::delete
129 || $self->export('mailinglistmember_delete');
131 $dbh->rollback if $oldAutoCommit;
135 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
139 =item replace OLD_RECORD
141 Replaces the OLD_RECORD with this one in the database. If there is an error,
142 returns the error, otherwise returns false.
149 my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') )
153 local $SIG{HUP} = 'IGNORE';
154 local $SIG{INT} = 'IGNORE';
155 local $SIG{QUIT} = 'IGNORE';
156 local $SIG{TERM} = 'IGNORE';
157 local $SIG{TSTP} = 'IGNORE';
158 local $SIG{PIPE} = 'IGNORE';
160 my $oldAutoCommit = $FS::UID::AutoCommit;
161 local $FS::UID::AutoCommit = 0;
164 my $error = $new->SUPER::replace($old)
165 || $new->export('mailinglistmember_replace', $old);
167 $dbh->rollback if $oldAutoCommit;
171 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
177 Checks all fields to make sure this is a valid member. If there is
178 an error, returns the error, otherwise returns false. Called by the insert
183 # the check method should currently be supplied - FS::Record contains some
184 # data checking routines
190 $self->ut_numbern('membernum')
191 || $self->ut_foreign_key('listnum', 'mailinglist', 'listnum')
192 || $self->ut_foreign_keyn('svcnum', 'svc_acct', 'svcnum')
193 || $self->ut_foreign_keyn('contactemailnum', 'contact_email', 'contactemailnum')
194 || $self->ut_textn('email') #XXX ut_email! from svc_forward, cust_main_invoice
196 return $error if $error;
209 #XXX svcnum, contactemailnum
218 my( $self, $method ) = ( shift, shift );
219 my $svc_mailinglist = $self->mailinglist->svc_mailinglist
221 $svc_mailinglist->export($method, $self, @_);
230 L<FS::Record>, schema.html from the base documentation.