summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorivan <ivan>2010-08-07 10:11:43 +0000
committerivan <ivan>2010-08-07 10:11:43 +0000
commit96bcb3256650a35d57c2ac487e990b78a2f88a74 (patch)
treed1904b8798608c73c57c7dadb9f013cc478203ab /FS/FS
parentb3205ddf480401284a5fc4ccbcb45d9c42b0bcf9 (diff)
communigate phase 3: RPOP/acct_snarf, RT#7515
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/acct_snarf.pm54
-rw-r--r--FS/FS/part_export/communigate_pro.pm41
-rw-r--r--FS/FS/svc_acct.pm23
3 files changed, 111 insertions, 7 deletions
diff --git a/FS/FS/acct_snarf.pm b/FS/FS/acct_snarf.pm
index fb26cea06..480a632bb 100644
--- a/FS/FS/acct_snarf.pm
+++ b/FS/FS/acct_snarf.pm
@@ -3,7 +3,8 @@ package FS::acct_snarf;
use strict;
use vars qw( @ISA );
use Tie::IxHash;
-use FS::Record;
+use FS::Record qw( qsearchs );
+use FS::cust_svc;
@ISA = qw( FS::Record );
@@ -91,6 +92,37 @@ returns the error, otherwise returns false.
# the replace method can be inherited from FS::Record
+=item cust_svc
+
+=cut
+
+sub cust_svc {
+ my $self = shift;
+ qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
+}
+
+
+=item svc_export
+
+Calls the replace export for any communigate exports attached to this rule's
+service.
+
+=cut
+
+sub svc_export {
+ my $self = shift;
+
+ my $cust_svc = $self->cust_svc;
+ my $svc_x = $cust_svc->svc_x;
+
+ #_singledomain too
+ my @exports = $cust_svc->part_svc->part_export('communigate_pro');
+ my @errors = map $_->export_replace($svc_x, $svc_x), @exports;
+
+ @errors ? join(' / ', @errors) : '';
+
+}
+
=item check
Checks all fields to make sure this is a valid external mail account. If
@@ -149,6 +181,26 @@ sub check_freq_labels {
\%hash;
}
+=item cgp_hashref
+
+Returns a hashref representing this external mail account, suitable for
+Communigate Pro API commands:
+
+=cut
+
+sub cgp_hashref {
+ my $self = shift;
+ {
+ 'authName' => $self->username,
+ 'domain' => $self->machine,
+ 'password' => $self->_password,
+ 'period' => $self->check_freq.'s',
+ 'APOP' => ( $self->apop eq 'Y' ? 'YES' : 'NO' ),
+ 'TLS' => ( $self->tls eq 'Y' ? 'YES' : 'NO' ),
+ 'Leave' => ( $self->leave eq 'Y' ? 'YES' : 'NO' ), #XXX leave??
+ };
+}
+
=back
=head1 BUGS
diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm
index 3e1213e84..cc96086b1 100644
--- a/FS/FS/part_export/communigate_pro.pm
+++ b/FS/FS/part_export/communigate_pro.pm
@@ -146,6 +146,15 @@ sub _export_insert_svc_acct {
warn "WARNING: error queueing SetAccountMailRules job: $rule_error"
if $rule_error;
+ my $rpop_error = $self->communigate_pro_queue(
+ $svc_acct->svcnum,
+ 'SetAccountRPOPs',
+ $self->export_username($svc_acct),
+ $svc_acct->cgp_rpop_hashref,
+ );
+ warn "WARNING: error queueing SetAccountMailRPOPs job: $rpop_error"
+ if $rpop_error;
+
'';
}
@@ -381,6 +390,15 @@ sub _export_replace_svc_acct {
warn "WARNING: error queueing SetAccountMailRules job: $rule_error"
if $rule_error;
+ my $rpop_error = $self->communigate_pro_queue(
+ $new->svcnum,
+ 'SetAccountRPOPs',
+ $self->export_username($new),
+ $new->cgp_rpop_hashref,
+ );
+ warn "WARNING: error queueing SetAccountMailRPOPs job: $rpop_error"
+ if $rpop_error;
+
'';
}
@@ -801,6 +819,20 @@ sub export_getsettings_svc_acct {
map _rule2string($_), @$rules
);
+# #rpops too
+# my $rpops = eval { $self->communigate_pro_runcommand(
+# 'GetAccountRPOPs',
+# $svc_acct->email
+# ) };
+# return $@ if $@;
+#
+# %$effective_settings = ( %$effective_settings,
+# map _rpop2string($_), %$rpops
+# );
+# %$settings = ( %$settings,
+# map _rpop2string($_), %rpops
+# );
+
#aliases too
my $aliases = eval { $self->communigate_pro_runcommand(
'GetAccountAliases',
@@ -870,6 +902,14 @@ sub _rule2string {
("Mail rule $name" => "$priority IF $conditions THEN $actions ($comment)");
}
+#sub _rpop2string {
+# my $rpop = shift;
+# my($priority, $name, $conditions, $actions, $comment) = @$rule;
+# $conditions = join(', ', map { my $a = $_; join(' ', @$a); } @$conditions);
+# $actions = join(', ', map { my $a = $_; join(' ', @$a); } @$actions);
+# ("Mail rule $name" => "$priority IF $conditions THEN $actions ($comment)");
+#}
+
sub export_getsettings_svc_mailinglist {
my($self, $svc_mailinglist, $settingsref, $defaultref ) = @_;
@@ -907,6 +947,7 @@ sub communigate_pro_queue_dep {
'UpdateAccountDefaults' => 'cp_Scalar_settingsHash',
'SetAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
'UpdateAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
+ 'SetAccountRPOPs' => 'cp_Scalar_Hash',
);
my $sub = exists($kludge_methods{$method})
? $kludge_methods{$method}
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 801c46533..c301bcd87 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -47,6 +47,7 @@ use FS::part_export;
use FS::svc_forward;
use FS::svc_www;
use FS::cdr;
+use FS::acct_snarf;
$DEBUG = 0;
$me = '[FS::svc_acct]';
@@ -1929,17 +1930,27 @@ sub email {
=item acct_snarf
Returns an array of FS::acct_snarf records associated with the account.
-If the acct_snarf table does not exist or there are no associated records,
-an empty list is returned
=cut
sub acct_snarf {
my $self = shift;
- return () unless dbdef->table('acct_snarf');
- eval "use FS::acct_snarf;";
- die $@ if $@;
- qsearch('acct_snarf', { 'svcnum' => $self->svcnum } );
+ qsearch({
+ 'table' => 'acct_snarf',
+ 'hashref' => { 'svcnum' => $self->svcnum },
+ #'order_by' => 'ORDER BY priority ASC',
+ });
+}
+
+=item cgp_rpop_hashref
+
+Returns an arrayref of RPOP data suitable for Communigate Pro API commands.
+
+=cut
+
+sub cgp_rpop_hashref {
+ my $self = shift;
+ { map { $_->snarfname => $_->cgp_hashref } $self->acct_snarf };
}
=item decrement_upbytes OCTETS