1 package FS::part_export::cp;
6 @ISA = qw(FS::part_export);
11 my( $self, $svc_acct ) = (shift, shift);
12 $self->cp_queue( $svc_acct->svcnum, 'create_mailbox',
13 Mailbox => $svc_acct->username,
14 Password => $svc_acct->_password,
15 Workgroup => $self->option('workgroup'),
16 Domain => $svc_acct->domain,
21 my( $self, $new, $old ) = (shift, shift, shift);
22 return "can't change domain with Critical Path"
23 if $old->domain ne $new->domain;
24 return '' unless $old->username ne $new->username
25 || $old->_password ne $new->_password;
26 $self->cp_queue( $new->svcnum, 'replace', $new->domain,
27 $old->username, $new->username, $old->_password, $new->_password );
31 my( $self, $svc_acct ) = (shift, shift);
32 $self->cp_queue( $svc_acct->svcnum, 'delete_mailbox',
33 Mailbox => $svc_acct->username,
34 Domain => $svc_acct->domain,
39 my( $self, $svcnum, $method ) = (shift, shift, shift);
40 my $queue = new FS::queue {
42 'job' => 'FS::part_export::cp::cp_command',
45 $self->option('host'),
46 $self->option('port'),
47 $self->option('username'),
48 $self->option('password'),
49 $self->option('domain'),
55 sub cp_command { #subroutine, not method
56 my($host, $port, $username, $password, $login_domain, $method, @args) = @_;
59 if ( $method eq 'replace' ) {
61 my( $domain, $old_username, $new_username, $old_password, $new_password)
64 if ( $old_username ne $new_username ) {
65 cp_command($host, $port, $username, $password, 'rename_mailbox',
67 Old_Mailbox => $old_username,
68 New_Mailbox => $new_username,
72 if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
74 cp_command($host, $port, $username, $password, 'set_mailbox_status',
76 Mailbox => $new_username,
81 cp_command($host, $port, $username, $password, 'set_mailbox_status',
83 Mailbox => $new_username,
89 if ( $old_password ne $new_password ) {
90 cp_command($host, $port, $username, $password, 'change_mailbox',
92 Mailbox => $new_username,
93 Password => $new_password,
101 eval "use Net::APP;";
103 my $app = new Net::APP (
106 Password => $password,
107 Domain => $login_domain,
112 $app->$method( @args );
114 die $app->message."\n" unless $app->ok;