1 package FS::part_export::acct_plesk;
3 use vars qw(@ISA %info);
7 @ISA = qw(FS::part_export);
9 tie my %options, 'Tie::IxHash',
10 'URL' => { label=>'URL' },
11 'login' => { label=>'Login' },
12 'password' => { label=>'Password' },
13 'debug' => { label=>'Enable debugging',
19 'desc' => 'Real-time export to Plesk managed mail service',
20 'options'=> \%options,
23 <a href="http://www.swsoft.com/">Plesk</a> managed server.
24 Requires installation of
25 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
26 from CPAN and proper <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration:acct_plesk.pm">configuration</a>.
30 sub rebless { shift; }
32 # experiment: want the status of these right away (don't want account to
33 # create or whatever and then get error in the queue from dup username or
34 # something), so no queueing
37 my( $self, $svc_acct ) = (shift, shift);
39 $self->_plesk_command( 'mail_add',
44 $self->_export_unsuspend($svc_acct);
48 my( $self, $method, $domain, @args ) = @_;
50 eval "use Net::Plesk;";
53 local($Net::Plesk::DEBUG) = 1
54 if $self->option('debug');
56 my $plesk = new Net::Plesk (
57 'POST' => $self->option('URL'),
58 ':HTTP_AUTH_LOGIN' => $self->option('login'),
59 ':HTTP_AUTH_PASSWD' => $self->option('password'),
62 my $dresponse = $plesk->domain_get( $domain );
63 return $dresponse->errortext unless $dresponse->is_success;
64 my $domainID = $dresponse->id;
66 my $response = $plesk->$method($dresponse->id, @args);
67 return $response->errortext unless $response->is_success;
73 my( $self, $new, $old ) = (shift, shift, shift);
75 return "can't change domain with Plesk"
76 if $old->domain ne $new->domain;
77 return "can't change username with Plesk"
78 if $old->username ne $new->username;
79 return '' unless $old->_password ne $new->_password;
81 $self->_plesk_command( 'mail_set',
85 $old->cust_svc->cust_pkg->susp ? 0 : 1,
90 my( $self, $svc_acct ) = (shift, shift);
92 $self->_plesk_command( 'mail_remove',
99 my( $self, $svc_acct ) = (shift, shift);
101 $self->_plesk_command( 'mail_set',
104 $svc_acct->_password,
109 sub _export_unsuspend {
110 my( $self, $svc_acct ) = (shift, shift);
112 $self->_plesk_command( 'mail_set',
115 $svc_acct->_password,