1 package FS::mailinglistmember;
4 use base qw( FS::Record );
5 use Scalar::Util qw( blessed );
6 use FS::Record qw( dbh qsearchs ); # qsearch );
12 FS::mailinglistmember - Object methods for mailinglistmember records
16 use FS::mailinglistmember;
18 $record = new FS::mailinglistmember \%hash;
19 $record = new FS::mailinglistmember { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::mailinglistmember object represents a mailing list member.
32 FS::mailinglistmember inherits from FS::Record. The following fields are
62 Creates a new mailing list member. To add the member to the database, see
65 Note that this stores the hash reference, not a distinct copy of the hash it
66 points to. You can ask the object for a copy with the I<hash> method.
70 # the new method can be inherited from FS::Record, if a table method is defined
72 sub table { 'mailinglistmember'; }
76 Adds this record to the database. If there is an error, returns the error,
77 otherwise returns false.
84 local $SIG{HUP} = 'IGNORE';
85 local $SIG{INT} = 'IGNORE';
86 local $SIG{QUIT} = 'IGNORE';
87 local $SIG{TERM} = 'IGNORE';
88 local $SIG{TSTP} = 'IGNORE';
89 local $SIG{PIPE} = 'IGNORE';
91 my $oldAutoCommit = $FS::UID::AutoCommit;
92 local $FS::UID::AutoCommit = 0;
95 my $error = $self->SUPER::insert
96 || $self->export('mailinglistmember_insert');
98 $dbh->rollback if $oldAutoCommit;
102 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
108 Delete this record from the database.
115 local $SIG{HUP} = 'IGNORE';
116 local $SIG{INT} = 'IGNORE';
117 local $SIG{QUIT} = 'IGNORE';
118 local $SIG{TERM} = 'IGNORE';
119 local $SIG{TSTP} = 'IGNORE';
120 local $SIG{PIPE} = 'IGNORE';
122 my $oldAutoCommit = $FS::UID::AutoCommit;
123 local $FS::UID::AutoCommit = 0;
126 my $error = $self->SUPER::delete
127 || $self->export('mailinglistmember_delete');
129 $dbh->rollback if $oldAutoCommit;
133 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
137 =item replace OLD_RECORD
139 Replaces the OLD_RECORD with this one in the database. If there is an error,
140 returns the error, otherwise returns false.
147 my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') )
151 local $SIG{HUP} = 'IGNORE';
152 local $SIG{INT} = 'IGNORE';
153 local $SIG{QUIT} = 'IGNORE';
154 local $SIG{TERM} = 'IGNORE';
155 local $SIG{TSTP} = 'IGNORE';
156 local $SIG{PIPE} = 'IGNORE';
158 my $oldAutoCommit = $FS::UID::AutoCommit;
159 local $FS::UID::AutoCommit = 0;
162 my $error = $new->SUPER::replace($old)
163 || $new->export('mailinglistmember_replace', $old);
165 $dbh->rollback if $oldAutoCommit;
169 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
175 Checks all fields to make sure this is a valid member. If there is
176 an error, returns the error, otherwise returns false. Called by the insert
181 # the check method should currently be supplied - FS::Record contains some
182 # data checking routines
188 $self->ut_numbern('membernum')
189 || $self->ut_foreign_key('listnum', 'mailinglist', 'listnum')
190 || $self->ut_foreign_keyn('svcnum', 'svc_acct', 'svcnum')
191 || $self->ut_textn('email') #XXX ut_email! from svc_forward, cust_main_invoice
193 return $error if $error;
204 qsearchs('mailinglist', { 'listnum' => $self->listnum } );
222 my( $self, $method ) = ( shift, shift );
223 my $svc_mailinglist = $self->mailinglist->svc_mailinglist
225 $svc_mailinglist->export($method, $self, @_);
234 L<FS::Record>, schema.html from the base documentation.