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,
73 if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
77 cp_command($host, $port, $username, $password, 'set_mailbox_status',
79 Mailbox => $new_username,
81 Other_Bounce => $other,
84 if ( $old_password ne $new_password ) {
85 cp_command($host, $port, $username, $password, 'change_mailbox',
87 Mailbox => $new_username,
88 Password => $new_password,
98 my $app = new Net::APP (
101 Password => $password,
102 Domain => $login_domain,
107 $app->$method( @args );
109 die $app->message."\n" unless $app->ok;