1 package FS::mailinglist;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch dbh ); # qsearchs );
6 use FS::mailinglistmember;
10 FS::mailinglist - Object methods for mailinglist records
16 $record = new FS::mailinglist \%hash;
17 $record = new FS::mailinglist { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::mailinglist object represents a mailing list FS::mailinglist inherits
30 from FS::Record. The following fields are currently supported:
50 Creates a new mailing list. To add the mailing list to the database, see
53 Note that this stores the hash reference, not a distinct copy of the hash it
54 points to. You can ask the object for a copy with the I<hash> method.
58 # the new method can be inherited from FS::Record, if a table method is defined
60 sub table { 'mailinglist'; }
64 Adds this record to the database. If there is an error, returns the error,
65 otherwise returns false.
69 # the insert method can be inherited from FS::Record
73 Delete this record from the database.
80 local $SIG{HUP} = 'IGNORE';
81 local $SIG{INT} = 'IGNORE';
82 local $SIG{QUIT} = 'IGNORE';
83 local $SIG{TERM} = 'IGNORE';
84 local $SIG{TSTP} = 'IGNORE';
85 local $SIG{PIPE} = 'IGNORE';
87 my $oldAutoCommit = $FS::UID::AutoCommit;
88 local $FS::UID::AutoCommit = 0;
91 foreach my $member ( $self->mailinglistmember ) {
92 my $error = $member->delete;
94 $dbh->rollback if $oldAutoCommit;
99 my $error = $self->SUPER::delete;
101 $dbh->rollback if $oldAutoCommit;
105 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
110 =item replace OLD_RECORD
112 Replaces the OLD_RECORD with this one in the database. If there is an error,
113 returns the error, otherwise returns false.
117 # the replace method can be inherited from FS::Record
121 Checks all fields to make sure this is a valid mailing list. If there is
122 an error, returns the error, otherwise returns false. Called by the insert
127 # the check method should currently be supplied - FS::Record contains some
128 # data checking routines
134 $self->ut_numbern('listnum')
135 || $self->ut_text('listname')
137 return $error if $error;
142 =item mailinglistmember
146 sub mailinglistmember {
148 qsearch('mailinglistmember', { 'listnum' => $self->listnum } );
157 L<FS::mailinglistmember>, L<FS::svc_mailinglist>, L<FS::Record>, schema.html
158 from the base documentation.