1 package FS::part_export::cp;
3 use vars qw(@ISA %info);
7 @ISA = qw(FS::part_export);
9 tie my %options, 'Tie::IxHash',
10 'port' => { label=>'Port number' },
11 'username' => { label=>'Username' },
12 'password' => { label=>'Password' },
13 'domain' => { label=>'Domain' },
14 'workgroup' => { label=>'Default Workgroup' },
19 'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
20 'options'=> \%options,
23 <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>.
24 Requires installation of
25 <a href="http://search.cpan.org/dist/Net-APP">Net::APP</a>
30 sub rebless { shift; }
33 my( $self, $svc_acct ) = (shift, shift);
34 $self->cp_queue( $svc_acct->svcnum, 'create_mailbox',
35 'Mailbox' => $svc_acct->username,
36 'Password' => $svc_acct->_password,
37 'Workgroup' => $self->option('workgroup'),
38 'Domain' => $svc_acct->domain,
43 my( $self, $new, $old ) = (shift, shift, shift);
44 return "can't change domain with Critical Path"
45 if $old->domain ne $new->domain;
46 return '' unless $old->username ne $new->username
47 || $old->_password ne $new->_password;
48 $self->cp_queue( $new->svcnum, 'replace', $new->domain,
49 $old->username, $new->username, $old->_password, $new->_password );
53 my( $self, $svc_acct ) = (shift, shift);
54 $self->cp_queue( $svc_acct->svcnum, 'delete_mailbox',
55 'Mailbox' => $svc_acct->username,
56 'Domain' => $svc_acct->domain,
61 my( $self, $svc_acct ) = (shift, shift);
62 $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
63 'Mailbox' => $svc_acct->username,
64 'Domain' => $svc_acct->domain,
66 'OTHER_SUSPEND' => 'T',
70 sub _export_unsuspend {
71 my( $self, $svc_acct ) = (shift, shift);
72 $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
73 'Mailbox' => $svc_acct->username,
74 'Domain' => $svc_acct->domain,
77 'OTHER_SUSPEND' => 'F',
78 'OTHER_BOUNCE' => 'F',
83 my( $self, $svcnum, $method ) = (shift, shift, shift);
84 my $queue = new FS::queue {
86 'job' => 'FS::part_export::cp::cp_command',
90 $self->option('port'),
91 $self->option('username'),
92 $self->option('password'),
93 $self->option('domain'),
99 sub cp_command { #subroutine, not method
100 my($host, $port, $username, $password, $login_domain, $method, @args) = @_;
103 if ( $method eq 'replace' ) {
105 my( $domain, $old_username, $new_username, $old_password, $new_password)
108 if ( $old_username ne $new_username ) {
109 cp_command($host, $port, $username, $password, 'rename_mailbox',
111 Old_Mailbox => $old_username,
112 New_Mailbox => $new_username,
117 if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
121 #cp_command($host, $port, $username, $password, $login_domain,
122 # 'set_mailbox_status',
124 # Mailbox => $new_username,
126 # Other_Bounce => $other,
129 if ( $old_password ne $new_password ) {
130 cp_command($host, $port, $username, $password, $login_domain,
133 Mailbox => $new_username,
134 Password => $new_password,
142 eval "use Net::APP;";
144 my $app = new Net::APP (
147 Password => $password,
148 Domain => $login_domain,
153 $app->$method( @args );
155 die $app->message."\n" unless $app->ok;