export host selection per service, RT#17914
[freeside.git] / FS / FS / part_export / www_plesk.pm
index a4ebbf5..a247f05 100644 (file)
@@ -10,20 +10,24 @@ tie my %options, 'Tie::IxHash',
   'URL'       => { label=>'URL' },
   'login'     => { label=>'Login' },
   'password'  => { label=>'Password' },
+  'template'  => { label=>'Domain Template' },
+  'web'       => { label=>'Host Website',
+                    type=>'checkbox'          },
   'debug'     => { label=>'Enable debugging',
                     type=>'checkbox'          },
 ;
 
 %info = (
-  'svc'    => 'svc_www',
-  'desc'   => 'Real-time export to Plesk managed hosting service',
-  'options'=> \%options,
-  'notes'  => <<'END'
+  'svc'        => 'svc_www',
+  'desc'       => 'Real-time export to Plesk managed hosting service',
+  'options'    => \%options,
+  'no_machine' => 1,
+  'notes'      => <<'END'
 Real-time export to
 <a href="http://www.swsoft.com/">Plesk</a> managed server.
 Requires installation of
 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
-from CPAN.
+from CPAN and proper <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration:www_plesk.pm">configuration</a>.
 END
 );
 
@@ -36,7 +40,7 @@ sub rebless { shift; }
 sub _export_insert {
   my( $self, $www ) = ( shift, shift );
 
-  eval "use Net::Plesk'";
+  eval "use Net::Plesk;";
   return $@ if $@;
 
   my $plesk = new Net::Plesk (
@@ -71,17 +75,29 @@ sub _export_insert {
                                  $www->domain_record->recdata,
                                        );
 
-  $self->_plesk_command( 'domain_add', 
-                         $www->domain_record->svc_domain->domain,
-                        $gcresp->id,
-                        $www->domain_record->recdata,
-                      );
+  if ($self->option('web')) {
+    $self->_plesk_command( 'domain_add', 
+                           $www->domain_record->svc_domain->domain,
+                          $gcresp->id,
+                          $www->domain_record->recdata,
+                           $self->option('template')?$self->option('template'):'',
+                           $www->svc_acct->username,
+                           $www->svc_acct->_password,
+                        );
+  }else{
+    $self->_plesk_command( 'domain_add', 
+                           $www->domain_record->svc_domain->domain,
+                          $gcresp->id,
+                          $www->domain_record->recdata,
+                           $self->option('template')?$self->option('template'):'',
+                        );
+  }
 }
 
 sub _plesk_command {
   my( $self, $method, @args ) = @_;
 
-  eval "use Net::Plesk'";
+  eval "use Net::Plesk;";
   return $@ if $@;
   
   local($Net::Plesk::DEBUG) = 1