1 package FS::acct_snarf;
6 use FS::Record qw( qsearchs );
9 @ISA = qw( FS::Record );
13 FS::acct_snarf - Object methods for acct_snarf records
19 $record = new FS::acct_snarf \%hash;
20 $record = new FS::acct_snarf { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::svc_acct object represents an external mail account, typically for
33 download of mail. FS::acct_snarf inherits from FS::Record. The following
34 fields are currently supported:
38 =item snarfnum - primary key
40 =item snarfname - Label
42 =item svcnum - Account (see L<FS::svc_acct>)
44 =item machine - external machine to download mail from
46 =item protocol - protocol (pop3, imap, etc.)
48 =item username - external login username
50 =item _password - external login password
60 Creates a new record. To add the record to the database, see L<"insert">.
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to. You can ask the object for a copy with the I<hash> method.
67 sub table { 'acct_snarf'; }
71 Adds this record to the database. If there is an error, returns the error,
72 otherwise returns false.
76 # the insert method can be inherited from FS::Record
80 Delete this record from the database.
84 # the delete method can be inherited from FS::Record
86 =item replace OLD_RECORD
88 Replaces the OLD_RECORD with this one in the database. If there is an error,
89 returns the error, otherwise returns false.
93 # the replace method can be inherited from FS::Record
101 qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
107 Calls the replace export for any communigate exports attached to this rule's
115 my $cust_svc = $self->cust_svc;
116 my $svc_x = $cust_svc->svc_x;
119 my @exports = $cust_svc->part_svc->part_export('communigate_pro');
120 my @errors = map $_->export_replace($svc_x, $svc_x), @exports;
122 @errors ? join(' / ', @errors) : '';
128 Checks all fields to make sure this is a valid external mail account. If
129 there is an error, returns the error, otherwise returns false. Called by the
130 insert and replace methods.
137 $self->ut_numbern('snarfnum')
138 || $self->ut_textn('snarfname') #alphasn?
139 || $self->ut_number('svcnum')
140 || $self->ut_foreign_key('svcnum', 'svc_acct', 'svcnum')
141 || $self->ut_domain('machine')
142 || $self->ut_alphan('protocol')
143 || $self->ut_textn('username')
144 || $self->ut_numbern('check_freq')
145 || $self->ut_enum('leavemail', [ '', 'Y' ])
146 || $self->ut_enum('apop', [ '', 'Y' ])
147 || $self->ut_enum('tls', [ '', 'Y' ])
148 || $self->ut_alphan('mailbox')
150 return $error if $error;
152 $self->_password =~ /^[^\t\n]*$/ or return "illegal password";
153 $self->_password($1);
158 sub check_freq_labels {
160 tie my %hash, 'Tie::IxHash',
168 1800 => '30 minutes',
178 1000000000 => 'Disabled',
186 Returns a hashref representing this external mail account, suitable for
187 Communigate Pro API commands:
194 'authName' => $self->username,
195 'domain' => $self->machine,
196 'password' => $self->_password,
197 'period' => $self->check_freq.'s',
198 'APOP' => ( $self->apop eq 'Y' ? 'YES' : 'NO' ),
199 'TLS' => ( $self->tls eq 'Y' ? 'YES' : 'NO' ),
200 'Leave' => ( $self->leavemail eq 'Y' ? 'YES' : 'NO' ), #XXX leave??
210 L<FS::Record>, schema.html from the base documentation.