X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fcommunigate_pro.pm;h=6da201799a4ce2ee78363d8b0d372db637a634cb;hb=6217d43dfc7345ec7f89be7fb90211fea458efde;hp=4240618ac44d5ac0b25704a6d56529bdd6b28c97;hpb=79dcffa66be02e3ddb342d36dcded01888c3d841;p=freeside.git
diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm
index 4240618ac..6da201799 100644
--- a/FS/FS/part_export/communigate_pro.pm
+++ b/FS/FS/part_export/communigate_pro.pm
@@ -1,17 +1,53 @@
package FS::part_export::communigate_pro;
-use vars qw(@ISA);
+use vars qw(@ISA %info %options);
+use Tie::IxHash;
use FS::part_export;
use FS::queue;
@ISA = qw(FS::part_export);
+tie %options, 'Tie::IxHash',
+ 'port' => { label=>'Port number', default=>'106', },
+ 'login' => { label=>'The administrator account name. The name can contain a domain part.', },
+ 'password' => { label=>'The administrator account password.', },
+ 'accountType' => { label=>'Type for newly-created accounts',
+ type=>'select',
+ options=>[qw( MultiMailbox TextMailbox MailDirMailbox )],
+ default=>'MultiMailbox',
+ },
+ 'externalFlag' => { label=> 'Create accounts with an external (visible for legacy mailers) INBOX.',
+ type=>'checkbox',
+ },
+ 'AccessModes' => { label=>'Access modes',
+ default=>'Mail POP IMAP PWD WebMail WebSite',
+ },
+;
+
+%info = (
+ 'svc' => 'svc_acct',
+ 'desc' => 'Real-time export to a CommuniGate Pro mail server',
+ 'options' => \%options,
+ 'notes' => <<'END'
+Real time export to a
+CommuniGate Pro
+mail server. The
+CommuniGate Pro Perl Interface
+must be installed as CGP::CLI.
+END
+);
+
sub rebless { shift; }
+sub export_username {
+ my($self, $svc_acct) = (shift, shift);
+ $svc_acct->email;
+}
+
sub _export_insert {
my( $self, $svc_acct ) = (shift, shift);
my @options = ( $svc_acct->svcnum, 'CreateAccount',
- 'accountName' => $svc_acct->email,
+ 'accountName' => $self->export_username($svc_acct),
'accountType' => $self->option('accountType'),
'AccessModes' => $self->option('AccessModes'),
'RealName' => $svc_acct->finger,
@@ -26,10 +62,10 @@ sub _export_insert {
sub _export_replace {
my( $self, $new, $old ) = (shift, shift, shift);
- return "can't (yet) change domain with CommuniGate Pro"
- if $old->domain ne $new->domain;
return "can't (yet) change username with CommuniGate Pro"
if $old->username ne $new->username;
+ return "can't (yet) change domain with CommuniGate Pro"
+ if $self->export_username($old) ne $self->export_username($new);
return "can't (yet) change GECOS with CommuniGate Pro"
if $old->finger ne $new->finger;
return "can't (yet) change quota with CommuniGate Pro"
@@ -47,7 +83,7 @@ sub _export_replace {
#my $jobnum = $err_or_queue->jobnum;
$self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
- $new->email, $new->_password )
+ $self->export_username($new), $new->_password )
if $new->_password ne $old->_password;
}
@@ -55,14 +91,14 @@ sub _export_replace {
sub _export_delete {
my( $self, $svc_acct ) = (shift, shift);
$self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
- $svc_acct->email,
+ $self->export_username($svc_acct),
);
}
sub _export_suspend {
my( $self, $svc_acct ) = (shift, shift);
$self->communigate_pro_queue( $svc_acct->svcnum, 'UpdateAccountSettings',
- 'accountName' => $svc_acct->email,
+ 'accountName' => $self->export_username($svc_acct),
'AccessModes' => 'Mail',
);
}
@@ -70,7 +106,7 @@ sub _export_suspend {
sub _export_unsuspend {
my( $self, $svc_acct ) = (shift, shift);
$self->communigate_pro_queue( $svc_acct->svcnum, 'UpdateAccountSettings',
- 'accountName' => $svc_acct->email,
+ 'accountName' => $self->export_username($svc_acct),
'AccessModes' => $self->option('AccessModes'),
);
}
@@ -78,9 +114,8 @@ sub _export_unsuspend {
sub communigate_pro_queue {
my( $self, $svcnum, $method ) = (shift, shift, shift);
my @kludge_methods = qw(CreateAccount UpdateAccountSettings);
- my $sub = grep { $method eq $_ } @kludge_methods
- ? $method
- : 'communigate_pro_command';
+ my $sub = 'communigate_pro_command';
+ $sub = $method if grep { $method eq $_ } @kludge_methods;
my $queue = new FS::queue {
'svcnum' => $svcnum,
'job' => "FS::part_export::communigate_pro::$sub",
@@ -109,7 +144,7 @@ sub CreateAccount {
#externalFlag => $externalFlag,
push @args, externalFlag => $externalFlag if $externalFlag;
- &communigate_pro_command( $machine, $port, $login, $password, $method, @args);
+ communigate_pro_command( $machine, $port, $login, $password, $method, @args );
}
@@ -118,7 +153,7 @@ sub UpdateAccountSettings {
my $accountName = delete $args{'accountName'};
$args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
@args = ( $accountName, \%args );
- &communigate_pro_command( $machine, $port, $login, $password, $method, @args);
+ communigate_pro_command( $machine, $port, $login, $password, $method, @args );
}
sub communigate_pro_command { #subroutine, not method
@@ -138,3 +173,6 @@ sub communigate_pro_command { #subroutine, not method
$cli->Logout or die "Can't logout of CGPro: $CGP::ERR_STRING\n";
}
+
+1;
+