1 package FS::mailinglist;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs dbh );
6 use FS::mailinglistmember;
7 use FS::svc_mailinglist;
11 FS::mailinglist - Object methods for mailinglist records
17 $record = new FS::mailinglist \%hash;
18 $record = new FS::mailinglist { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::mailinglist object represents a mailing list FS::mailinglist inherits
31 from FS::Record. The following fields are currently supported:
51 Creates a new mailing list. To add the mailing list to the database, see
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to. You can ask the object for a copy with the I<hash> method.
59 # the new method can be inherited from FS::Record, if a table method is defined
61 sub table { 'mailinglist'; }
65 Adds this record to the database. If there is an error, returns the error,
66 otherwise returns false.
70 # the insert method can be inherited from FS::Record
74 Delete this record from the database.
81 local $SIG{HUP} = 'IGNORE';
82 local $SIG{INT} = 'IGNORE';
83 local $SIG{QUIT} = 'IGNORE';
84 local $SIG{TERM} = 'IGNORE';
85 local $SIG{TSTP} = 'IGNORE';
86 local $SIG{PIPE} = 'IGNORE';
88 my $oldAutoCommit = $FS::UID::AutoCommit;
89 local $FS::UID::AutoCommit = 0;
92 foreach my $member ( $self->mailinglistmember ) {
93 my $error = $member->delete;
95 $dbh->rollback if $oldAutoCommit;
100 my $error = $self->SUPER::delete;
102 $dbh->rollback if $oldAutoCommit;
106 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
111 =item replace OLD_RECORD
113 Replaces the OLD_RECORD with this one in the database. If there is an error,
114 returns the error, otherwise returns false.
118 # the replace method can be inherited from FS::Record
122 Checks all fields to make sure this is a valid mailing list. If there is
123 an error, returns the error, otherwise returns false. Called by the insert
128 # the check method should currently be supplied - FS::Record contains some
129 # data checking routines
135 $self->ut_numbern('listnum')
136 || $self->ut_text('listname')
138 return $error if $error;
143 =item mailinglistmember
147 sub mailinglistmember {
149 qsearch('mailinglistmember', { 'listnum' => $self->listnum } );
152 =item svc_mailinglist
156 sub svc_mailinglist {
158 qsearchs('svc_mailinglist', { 'listnum' => $self->listnum } );
167 L<FS::mailinglistmember>, L<FS::svc_mailinglist>, L<FS::Record>, schema.html
168 from the base documentation.