From fadd59b20fe5baf4e82e45ea021e4292f5eb77d8 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 24 Jun 2014 14:38:39 +1000 Subject: [PATCH] Added Crazydomains and fixed payment updates --- .../classes/Service/Domain/CrazyDomain.php | 35 ++++++++++++ modules/domain/classes/Service/Domain/TPP.php | 4 +- .../views/service/user/plugin/domain/view.php | 12 ++--- .../host/classes/Host/Plugin/Crazydomains.php | 53 +++++++++++++++++++ .../views/service/user/plugin/host/view.php | 11 ++-- modules/payment/classes/Model/Payment.php | 4 +- .../service/classes/Model/Service/Plugin.php | 2 +- 7 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 modules/domain/classes/Service/Domain/CrazyDomain.php create mode 100644 modules/host/classes/Host/Plugin/Crazydomains.php diff --git a/modules/domain/classes/Service/Domain/CrazyDomain.php b/modules/domain/classes/Service/Domain/CrazyDomain.php new file mode 100644 index 00000000..312f8e23 --- /dev/null +++ b/modules/domain/classes/Service/Domain/CrazyDomain.php @@ -0,0 +1,35 @@ +so->manage_url, + array('target'=>'crazy','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t)) + ); + $output .= Form::input($this->login_user_field,$spdo->username(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t))); + $output .= Form::input($this->login_pass_field,substr(md5($spdo->password()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); + $output .= Form::hidden('submitted','TRUE'); + $output .= Form::close(); + $output .= Form::button('submit',_('Login'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t))); + + return $output; + } +} +?> diff --git a/modules/domain/classes/Service/Domain/TPP.php b/modules/domain/classes/Service/Domain/TPP.php index 94f728d2..ee70ad87 100644 --- a/modules/domain/classes/Service/Domain/TPP.php +++ b/modules/domain/classes/Service/Domain/TPP.php @@ -20,13 +20,13 @@ class Service_Domain_TPP extends Service_Domain { $output = ''; $output .= Form::open( - $debug ? 'debug/site' : sprintf('%s/%s',$this->so->whitelabel_url,'execute/logon'), + $debug ? 'debug/site' : $this->so->manage_url, array('target'=>'tpp','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t)) ); $output .= Form::input($this->login_user_field,$spdo->username(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_pass_field,substr(md5($spdo->password()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); $output .= Form::close(); - $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t))); + $output .= Form::button('submit',_('Login'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t))); return $output; } diff --git a/modules/domain/views/service/user/plugin/domain/view.php b/modules/domain/views/service/user/plugin/domain/view.php index ea266174..50bc859f 100644 --- a/modules/domain/views/service/user/plugin/domain/view.php +++ b/modules/domain/views/service/user/plugin/domain/view.php @@ -6,13 +6,11 @@
Domain Name
name(); ?>
- service->external_billing) : ?> -
Domain Expire
-
display('domain_expire'); ?>
+
Domain Expire
+
display('domain_expire'); ?>
-
Domain Auth Password
-
service->expiring() ? $o->display('registrar_auth_password') : 'EXPIRED'; ?>
- +
Domain Auth Password
+
service->expiring() ? $o->display('registrar_auth_password') : 'EXPIRED'; ?>
manage_button()) : ?>
Registrar
@@ -29,8 +27,6 @@
registrar->whitelabel_url,NULL); ?>
Username
registrar_username; ?>
-
Password
-
registrar_password; ?>
diff --git a/modules/host/classes/Host/Plugin/Crazydomains.php b/modules/host/classes/Host/Plugin/Crazydomains.php new file mode 100644 index 00000000..b36e25d8 --- /dev/null +++ b/modules/host/classes/Host/Plugin/Crazydomains.php @@ -0,0 +1,53 @@ +_object; + } + public function unserialize($s) { + $this->_object = XML::factory(NULL,NULL,$s); + } + + public function manage_button(Model_Service_Plugin_Host $spho,$t) { + return $this->render_button($t,$spho->service_id,$spho->username(),substr(md5($spho->password()),0,8)); + } + public function admin_manage_button(Model_Host_Server $hso,$t) { + return $this->render_button($t,$hso->id,substr(md5($hso->manage_username),0,8),substr(md5($hso->manage_password),0,8)); + } + + protected function render_button($t,$sid,$u,$p) { + $debug = FALSE; + $output = ''; + + $output .= Form::open( + $debug ? 'debug/site' : $this->hso->manage_url, + array('target'=>'w24','method'=>'post','id'=>sprintf('id_%s_%s',$sid,$t)) + ); + $output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t))); + $output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t))); + $output .= Form::hidden('submitted','TRUE'); + $output .= Form::close(); + $output .= Form::button('submit',_('Login'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$sid,$t),'nocg'=>TRUE)); + + return $output; + } +} +?> diff --git a/modules/host/views/service/user/plugin/host/view.php b/modules/host/views/service/user/plugin/host/view.php index cb381c73..b4d0e886 100644 --- a/modules/host/views/service/user/plugin/host/view.php +++ b/modules/host/views/service/user/plugin/host/view.php @@ -10,10 +10,15 @@
display('host_expire'); ?>
manage_button()) : ?> -
- -
+
Panel
+
+ service->external_billing) : ?> +
Provider
+
host->whitelabel_url,NULL); ?>
+
Username
+
host_username; ?>
+ diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php index 0c2bd155..8d1e01f9 100644 --- a/modules/payment/classes/Model/Payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -189,10 +189,8 @@ class Model_Payment extends ORM_OSB { if (! $pio->check()) throw HTTP_Exception::factory(501,'Problem saving payment_item for invoice :invoice - Failed check()',array(':invoice'=>$pio->invoice_id)); - $pio->save(); - // @todo Mark payment as cancelled and write a memo, then... - if (! $pio->saved()) + if ($pio->changed() AND ! $pio->save()) throw HTTP_Exception::factory(501,'Problem saving payment_item for invoice :invoice - Failed save()',array(':invoice'=>$pio->invoice_id)); } diff --git a/modules/service/classes/Model/Service/Plugin.php b/modules/service/classes/Model/Service/Plugin.php index 9056fd4d..6cb61fe7 100644 --- a/modules/service/classes/Model/Service/Plugin.php +++ b/modules/service/classes/Model/Service/Plugin.php @@ -38,7 +38,7 @@ abstract class Model_Service_Plugin extends ORM_OSB { */ protected function manage() { // Dont show the manage button for expired or inactive services - if (! $this->service->status OR $this->service->expiring() OR $this->service->external_billing) + if (! $this->service->status OR $this->service->expiring()) return FALSE; static $x = '';