X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fcommunigate_pro.pm;h=557aad91dd93ae0cd70ff67fa01f6b4c4070ba9f;hb=57be672860c23f6c856328941fb37f2a9038620a;hp=bce7f301f8367c7888db6e1821d84d1262d5a9d8;hpb=1db61c35afc546c51de4931ced48330c19af21eb;p=freeside.git diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm index bce7f301f..557aad91d 100644 --- a/FS/FS/part_export/communigate_pro.pm +++ b/FS/FS/part_export/communigate_pro.pm @@ -8,24 +8,33 @@ use FS::queue; sub rebless { shift; } +sub export_username { + my($self, $svc_acct) = (shift, shift); + $svc_acct->email; +} + sub _export_insert { my( $self, $svc_acct ) = (shift, shift); - $self->communigate_pro_queue( $svc_acct->svcnum, 'CreateAccount', - 'accountName' => $svc_acct->email, + my @options = ( $svc_acct->svcnum, 'CreateAccount', + 'accountName' => $self->export_username($svc_acct), 'accountType' => $self->option('accountType'), - 'externalFlag' => $self->option('externalFlag'), 'AccessModes' => $self->option('AccessModes'), 'RealName' => $svc_acct->finger, - 'MaxAccountSize' => $svc_acct->quota, + 'Password' => $svc_acct->_password, ); + push @options, 'MaxAccountSize' => $svc_acct->quota if $svc_acct->quota; + push @options, 'externalFlag' => $self->option('externalFlag') + if $self->option('externalFlag'); + + $self->communigate_pro_queue( @options ); } 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" @@ -35,13 +44,15 @@ sub _export_replace { || $old->finger ne $new->finger || $old->quota ne $new->quota; + return '' if '*SUSPENDED* '. $old->_password eq $new->_password; + #my $err_or_queue = $self->communigate_pro_queue( $new->svcnum,'RenameAccount', # $old->email, $new->email ); #return $err_or_queue unless ref($err_or_queue); #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; } @@ -49,21 +60,31 @@ 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 { -#} +sub _export_suspend { + my( $self, $svc_acct ) = (shift, shift); + $self->communigate_pro_queue( $svc_acct->svcnum, 'UpdateAccountSettings', + 'accountName' => $self->export_username($svc_acct), + 'AccessModes' => 'Mail', + ); +} -#sub _export_unsuspend { -#} +sub _export_unsuspend { + my( $self, $svc_acct ) = (shift, shift); + $self->communigate_pro_queue( $svc_acct->svcnum, 'UpdateAccountSettings', + 'accountName' => $self->export_username($svc_acct), + 'AccessModes' => $self->option('AccessModes'), + ); +} sub communigate_pro_queue { my( $self, $svcnum, $method ) = (shift, shift, shift); - my $sub = $method eq 'CreateAccount' - ? 'CreateAccount' - : 'communigate_pro_command'; + my @kludge_methods = qw(CreateAccount UpdateAccountSettings); + 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", @@ -80,20 +101,30 @@ sub communigate_pro_queue { } sub CreateAccount { - my( $machine, $port, $login, $password, $method, @args ) = @_; - - my %args = @args; + my( $machine, $port, $login, $password, $method, %args ) = @_; my $accountName = delete $args{'accountName'}; my $accountType = delete $args{'accountType'}; my $externalFlag = delete $args{'externalFlag'}; $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ]; - @args = ( accountName => $accountName, [ settings => \%args ], - accountType => $accountType, externalFlag => $externalFlag, ); + my @args = ( accountName => $accountName, + accountType => $accountType, + settings => \%args, + ); + #externalFlag => $externalFlag, + push @args, externalFlag => $externalFlag if $externalFlag; communigate_pro_command( $machine, $port, $login, $password, $method, @args ); } +sub UpdateAccountSettings { + my( $machine, $port, $login, $password, $method, %args ) = @_; + my $accountName = delete $args{'accountName'}; + $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ]; + @args = ( $accountName, \%args ); + communigate_pro_command( $machine, $port, $login, $password, $method, @args ); +} + sub communigate_pro_command { #subroutine, not method my( $machine, $port, $login, $password, $method, @args ) = @_; @@ -108,6 +139,6 @@ sub communigate_pro_command { #subroutine, not method $cli->$method(@args) or die "CGPro error: ". $cli->getErrMessage; - $cli->Logout or die "Can't logout of CGPro: $CGP:ERR_STRING\n"; + $cli->Logout or die "Can't logout of CGPro: $CGP::ERR_STRING\n"; }