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,
22 'default_svc_class' => 'Email',
25 <a href="http://www.swsoft.com/">Plesk</a> managed server.
26 Requires installation of
27 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
28 from CPAN and proper <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration:acct_plesk.pm">configuration</a>.
32 sub rebless { shift; }
34 # experiment: want the status of these right away (don't want account to
35 # create or whatever and then get error in the queue from dup username or
36 # something), so no queueing
39 my( $self, $svc_acct ) = (shift, shift);
41 $self->_plesk_command( 'mail_add',
46 $self->_export_unsuspend($svc_acct);
50 my( $self, $method, $domain, @args ) = @_;
52 eval "use Net::Plesk;";
55 local($Net::Plesk::DEBUG) = 1
56 if $self->option('debug');
58 my $plesk = new Net::Plesk (
59 'POST' => $self->option('URL'),
60 ':HTTP_AUTH_LOGIN' => $self->option('login'),
61 ':HTTP_AUTH_PASSWD' => $self->option('password'),
64 my $dresponse = $plesk->domain_get( $domain );
65 return $dresponse->errortext unless $dresponse->is_success;
66 my $domainID = $dresponse->id;
68 my $response = $plesk->$method($dresponse->id, @args);
69 return $response->errortext unless $response->is_success;
75 my( $self, $new, $old ) = (shift, shift, shift);
77 return "can't change domain with Plesk"
78 if $old->domain ne $new->domain;
79 return "can't change username with Plesk"
80 if $old->username ne $new->username;
81 return '' unless $old->_password ne $new->_password;
83 $self->_plesk_command( 'mail_set',
87 $old->cust_svc->cust_pkg->susp ? 0 : 1,
92 my( $self, $svc_acct ) = (shift, shift);
94 $self->_plesk_command( 'mail_remove',
100 sub _export_suspend {
101 my( $self, $svc_acct ) = (shift, shift);
103 $self->_plesk_command( 'mail_set',
106 $svc_acct->_password,
111 sub _export_unsuspend {
112 my( $self, $svc_acct ) = (shift, shift);
114 $self->_plesk_command( 'mail_set',
117 $svc_acct->_password,