1 package FS::part_export::communigate_pro;
7 @ISA = qw(FS::part_export);
12 my( $self, $svc_acct ) = (shift, shift);
13 $self->communigate_pro_queue( $svc_acct->svcnum, 'CreateAccount',
14 'accountName' => $svc_acct->email,
15 'accountType' => $self->option('accountType'),
16 'externalFlag' => $self->option('externalFlag'),
17 'AccessModes' => $self->option('AccessModes'),
18 'RealName' => $svc_acct->finger,
19 'MaxAccountSize' => $svc_acct->quota,
24 my( $self, $new, $old ) = (shift, shift, shift);
25 return "can't (yet) change domain with CommuniGate Pro"
26 if $old->domain ne $new->domain;
27 return "can't (yet) change username with CommuniGate Pro"
28 if $old->username ne $new->username;
29 return "can't (yet) change GECOS with CommuniGate Pro"
30 if $old->finger ne $new->finger;
31 return "can't (yet) change quota with CommuniGate Pro"
32 if $old->quota ne $new->quota;
33 return '' unless $old->username ne $new->username
34 || $old->_password ne $new->_password
35 || $old->finger ne $new->finger
36 || $old->quota ne $new->quota;
38 #my $err_or_queue = $self->communigate_pro_queue( $new->svcnum,'RenameAccount',
39 # $old->email, $new->email );
40 #return $err_or_queue unless ref($err_or_queue);
41 #my $jobnum = $err_or_queue->jobnum;
43 $self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
44 $new->email, $new->_password )
45 if $new->_password ne $old->_password;
50 my( $self, $svc_acct ) = (shift, shift);
51 $self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
56 #sub _export_suspend {
59 #sub _export_unsuspend {
62 sub communigate_pro_queue {
63 my( $self, $svcnum, $method ) = (shift, shift, shift);
64 my $sub = $method eq 'CreateAccount'
66 : 'communigate_pro_command';
67 my $queue = new FS::queue {
69 'job' => "FS::part_export::communigate_pro::$sub",
73 $self->option('port'),
74 $self->option('login'),
75 $self->option('password'),
83 my( $machine, $port, $login, $password, $method, @args ) = @_;
86 my $accountName = delete $args{'accountName'};
87 my $accountType = delete $args{'accountType'};
88 my $externalFlag = delete $args{'externalFlag'};
89 $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
90 @args = ( accountName => $accountName, [ settings => \%args ],
91 accountType => $accountType, externalFlag => $externalFlag, );
93 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
97 sub communigate_pro_command { #subroutine, not method
98 my( $machine, $port, $login, $password, $method, @args ) = @_;
102 my $cli = new CGP::CLI( {
103 'PeerAddr' => $machine,
106 'password' => $password,
107 } ) or die "Can't login to CGPro: $CGP::ERR_STRING\n";
109 $cli->$method(@args) or die "CGPro error: ". $cli->getErrMessage;
111 $cli->Logout or die "Can't logout of CGPro: $CGP::ERR_STRING\n";