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,
21 'default_svc_class' => 'Email',
24 <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>.
25 Requires installation of
26 <a href="http://search.cpan.org/dist/Net-APP">Net::APP</a>
31 sub rebless { shift; }
34 my( $self, $svc_acct ) = (shift, shift);
35 $self->cp_queue( $svc_acct->svcnum, 'create_mailbox',
36 'Mailbox' => $svc_acct->username,
37 'Password' => $svc_acct->_password,
38 'Workgroup' => $self->option('workgroup'),
39 'Domain' => $svc_acct->domain,
44 my( $self, $new, $old ) = (shift, shift, shift);
45 return "can't change domain with Critical Path"
46 if $old->domain ne $new->domain;
47 return "can't change username with Critical Path" #CP no longer supports this
48 if $old->username ne $new->username;
49 return '' unless $old->_password ne $new->_password;
50 $self->cp_queue( $new->svcnum, 'replace', $new->domain,
51 $old->username, $new->username, $old->_password, $new->_password );
55 my( $self, $svc_acct ) = (shift, shift);
56 $self->cp_queue( $svc_acct->svcnum, 'delete_mailbox',
57 'Mailbox' => $svc_acct->username,
58 'Domain' => $svc_acct->domain,
63 my( $self, $svc_acct ) = (shift, shift);
64 $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
65 'Mailbox' => $svc_acct->username,
66 'Domain' => $svc_acct->domain,
68 'OTHER_SUSPEND' => 'T',
72 sub _export_unsuspend {
73 my( $self, $svc_acct ) = (shift, shift);
74 $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
75 'Mailbox' => $svc_acct->username,
76 'Domain' => $svc_acct->domain,
79 'OTHER_SUSPEND' => 'F',
80 'OTHER_BOUNCE' => 'F',
85 my( $self, $svcnum, $method ) = (shift, shift, shift);
86 my $queue = new FS::queue {
88 'job' => 'FS::part_export::cp::cp_command',
92 $self->option('port'),
93 $self->option('username'),
94 $self->option('password'),
95 $self->option('domain'),
101 sub cp_command { #subroutine, not method
102 my($host, $port, $username, $password, $login_domain, $method, @args) = @_;
105 if ( $method eq 'replace' ) {
107 my( $domain, $old_username, $new_username, $old_password, $new_password)
110 if ( $old_username ne $new_username ) {
111 cp_command($host, $port, $username, $password, 'rename_mailbox',
113 Old_Mailbox => $old_username,
114 New_Mailbox => $new_username,
119 if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
123 #cp_command($host, $port, $username, $password, $login_domain,
124 # 'set_mailbox_status',
126 # Mailbox => $new_username,
128 # Other_Bounce => $other,
131 if ( $old_password ne $new_password ) {
132 cp_command($host, $port, $username, $password, $login_domain,
135 Mailbox => $new_username,
136 Password => $new_password,
144 eval "use Net::APP;";
146 my $app = new Net::APP (
149 Password => $password,
150 Domain => $login_domain,
155 $app->$method( @args );
157 die $app->message."\n" unless $app->ok;