1 package FS::part_export::www_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 'template' => { label=>'Domain Template' },
14 'web' => { label=>'Host Website',
16 'debug' => { label=>'Enable debugging',
22 'desc' => 'Real-time export to Plesk managed hosting service',
23 'options'=> \%options,
26 <a href="http://www.swsoft.com/">Plesk</a> managed server.
27 Requires installation of
28 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
29 from CPAN and proper <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration:www_plesk.pm">configuration</a>.
33 sub rebless { shift; }
35 # experiment: want the status of these right away (don't want account to
36 # create or whatever and then get error in the queue from dup username or
37 # something), so no queueing
40 my( $self, $www ) = ( shift, shift );
42 eval "use Net::Plesk;";
45 my $plesk = new Net::Plesk (
46 'POST' => $self->option('URL'),
47 ':HTTP_AUTH_LOGIN' => $self->option('login'),
48 ':HTTP_AUTH_PASSWD' => $self->option('password'),
51 my $gcresp = $plesk->client_get( $www->svc_acct->username );
52 return $gcresp->errortext
53 unless $gcresp->is_success;
55 unless ($gcresp->id) {
56 my $cust_main = $www->cust_svc->cust_pkg->cust_main;
57 $gcresp = $plesk->client_add( $cust_main->name,
58 $www->svc_acct->username,
59 $www->svc_acct->_password,
62 $cust_main->invoicing_list->[0],
63 $cust_main->address1 . $cust_main->address2,
69 return $gcresp->errortext
70 unless $gcresp->is_success;
73 $plesk->client_ippool_add_ip ( $gcresp->id,
74 $www->domain_record->recdata,
77 if ($self->option('web')) {
78 $self->_plesk_command( 'domain_add',
79 $www->domain_record->svc_domain->domain,
81 $www->domain_record->recdata,
82 $self->option('template')?$self->option('template'):'',
83 $www->svc_acct->username,
84 $www->svc_acct->_password,
87 $self->_plesk_command( 'domain_add',
88 $www->domain_record->svc_domain->domain,
90 $www->domain_record->recdata,
91 $self->option('template')?$self->option('template'):'',
97 my( $self, $method, @args ) = @_;
99 eval "use Net::Plesk;";
102 local($Net::Plesk::DEBUG) = 1
103 if $self->option('debug');
105 my $plesk = new Net::Plesk (
106 'POST' => $self->option('URL'),
107 ':HTTP_AUTH_LOGIN' => $self->option('login'),
108 ':HTTP_AUTH_PASSWD' => $self->option('password'),
111 my $response = $plesk->$method(@args);
112 return $response->errortext unless $response->is_success;
117 sub _export_replace {
118 my( $self, $new, $old ) = (shift, shift, shift);
120 return "can't change domain with Plesk"
121 if $old->domain_record->svc_domain->domain ne
122 $new->domain_record->svc_domain->domain;
124 return "can't change client with Plesk"
125 if $old->svc_acct->username ne
126 $new->svc_acct->username;
133 my( $self, $www ) = ( shift, shift );
134 $self->_plesk_command( 'domain_del', $www->domain_record->svc_domain->domain);