Skip to content

Commit

Permalink
Fixed live issue, removed old api function
Browse files Browse the repository at this point in the history
resolved #1 removed old api reference added blesta loading when
submitting install cert form
  • Loading branch information
lukesUbuntu committed Mar 25, 2015
1 parent 93a60ca commit 2b747b0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 56 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ This is first initial release so please use at your *own risk*, I have done a to
* Remember form filled content when swapping between CSR Generating to install client tab.
* Fix when submitting install to show blesta loading screen.
* Add Administration re-issuing of certificate options.
* Add email tags for when issuing new certificate
96 changes: 42 additions & 54 deletions gogetsslv2.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
* @todo final code clean up
* @todo Add Administration re-issuing of certificate options.
* @todo Add option to send out email after installation has been completed of cert
* @todo when loading re-issue when loading email need to show loading blesta screen
* @todo if order is still pending, then re-issue tab should possible be disabled?
*/
class Gogetsslv2 extends Module
{

/**
* @var string The version of this module
*/
private static $version = "1.0.8";
private static $version = "1.0.9";
/**
* @var string The authors of this module
*/
Expand Down Expand Up @@ -521,7 +523,8 @@ public function editService($package, $service, array $vars = array(), $parent_p
return;

$row = $this->getModuleRow($package->module_row);
$api = $this->getApi($row->meta->api_username, $row->meta->api_password, $row->meta->sandbox, $row);

$api = $this->api($row);

$service_fields = $this->serviceFieldsToObject($service->fields);

Expand Down Expand Up @@ -705,7 +708,8 @@ public function renewService($package, $service, $parent_package = null, $parent
{
//@todo finish of renew service
$row = $this->getModuleRow($package->module_row);
$api = $this->getApi($row->meta->api_username, $row->meta->api_password, $row->meta->sandbox, $row);
$api = $this->api($row);


$order_id = '';

Expand Down Expand Up @@ -1015,7 +1019,9 @@ public function getPackageFields($vars = null)
}

if ($row) {
$api = $this->getApi($row->meta->api_username, $row->meta->api_password, $row->meta->sandbox, $row);

$api = $this->api($row);

$products = $this->getProducts($api, $row);
} else {
$products = array();
Expand Down Expand Up @@ -1345,9 +1351,9 @@ public function tabClientReissue($package, $service, array $getRequest = null, a
"gogetssl_fqdn" => $service_fields->gogetssl_fqdn,
"use_module" => true,
"pricing_id" => $service->pricing_id,
"gogetssl_webserver_type" => $postRequest["gogetssl_webserver_type"],
"gogetssl_csr" => $postRequest["gogetssl_csr"],
"gogetssl_approver_type" => $postRequest["gogetssl_approver_type"],
"gogetssl_webserver_type" => $postRequest["gogetssl_webserver_type"],
"gogetssl_csr" => $postRequest["gogetssl_csr"],
"gogetssl_approver_type" => $postRequest["gogetssl_approver_type"],
"gogetssl_approver_email" => $postRequest["gogetssl_approver_email"],
);

Expand Down Expand Up @@ -1559,8 +1565,8 @@ public function tabClientInstall($package, $service, array $getRequest=null, arr
//***************************************CERTIFICATE HAS BEEN INSTALLED*******************************************
if ($service_fields->gogetssl_issed){

$api = $this->getApi($row->meta->api_username, $row->meta->api_password, $row->meta->sandbox, $row);

$api = $this->api($row);
//$response = false;
//$response = $api->getOrderStatus($service_fields->gogetssl_orderid);

Expand Down Expand Up @@ -1667,23 +1673,6 @@ public function tabClientInstall($package, $service, array $getRequest=null, arr



/**
* Initializes the API and returns an instance of that object with the given $host, $user, and $pass set
*
* @param string $user The of the GoGetSSLv2 user
* @param string $password The password to the GoGetSSL server
* @param string $sandbox Whether sandbox or not
* @param stdClass $module_row A stdClass object representing a single reseller (optional, required when Module::getModuleRow() is unavailable)
* @return GoGetSSLApi The GoGetSSLApi instance
*/
public function getApi($user, $password, $sandbox, $module_row) {
Loader::load(dirname(__FILE__) . DS . "apis" . DS . "GoGetSSLApi.php");

$api = new GoGetSSLApi($sandbox == "true");
$this->parseResponse($api->auth($user, $password), $module_row);
return $api;
}

/**
* Retrieves a list of products
*
Expand All @@ -1705,16 +1694,16 @@ private function getProducts($api, $module_row) {
}

/**
* GET singleton API call as we are caching some calls to server
* Initializes the API and returns a Singleton instance of that object for api calls
*
* @param stdClass $module_row A stdClass object representing a single reseller (optional, required when Module::getModuleRow() is unavailable)
* @return GoGetSSLApi The GoGetSSLApi instance
*/
private $_api = false;
private function api($module_row = false){
//load our api


if ($this->_api == false){

//if module_row was not passed will try retrieve
if ($module_row == false || !isset($module_row))
$module_row = $this->getModuleRow();

Expand All @@ -1723,27 +1712,17 @@ private function api($module_row = false){
}

Loader::load(dirname(__FILE__) . DS . "apis" . DS . "GoGetSSLApi.php");
// Loader::load(dirname(__FILE__) . DS . "apis" . DS . "virtualmin_api.php");

//$host, $username, $password, $port = "10000", $use_ssl = true
//$api = new GoGetSSLApi($sandbox == "true");
$this->_api = new GoGetSSLApi($module_row->meta->sandbox == "true");

$this->_api = new GoGetSSLApi(
$module_row->meta->sandbox
);
/*
$this->_api = new GoGetSSLApi(
$module_row->meta->host_name, //hostname
$module_row->meta->user_name, //username
$module_row->meta->password, //password
$module_row->meta->port_number, //port number
($module_row->meta->use_ssl == "true") //use secure
);*/
//$api->auth($user, $password), $module_row
$this->parseResponse($this->_api->auth($module_row->meta->api_username, $module_row->meta->api_password), $module_row);
}

$this->parseResponse($this->_api->auth(
$module_row->meta->api_username,
$module_row->meta->api_password
),
$module_row);

}

return $this->_api;
}
Expand Down Expand Up @@ -1877,9 +1856,9 @@ public function validateConnection($api_username, $vars) {
$api_password = (isset($vars['api_password']) ? $vars['api_password'] : "");
$sandbox = (isset($vars['sandbox']) && $vars['sandbox'] == "true" ? "true" : "false");
$module_row = (object)array('meta' => (object)$vars);
$this->getApi($api_username, $api_password, $sandbox, $module_row);

$this->api($module_row);

if (!$this->Input->errors())
return true;

Expand Down Expand Up @@ -2184,30 +2163,37 @@ public function emailAuthorisation($request,$dataRequest){

$lib = $this->getLib();

//@todo put this in a proper cache
//@todo only want to store email_auth during swapping between CSR Generation & domain renew will save as services
//@disabled for now due to https://github.com/lukesUbuntu/gogetsslv2/issues/1

if (isset($_SESSION[$domain]['email_auth']) && !empty($_SESSION[$domain]['email_auth'])){
$lib->sendAjax($_SESSION[$domain]['email_auth']);
}

if (empty($domain))$lib->sendAjax("domain failed empty",false);

$row = $this->getModuleRow($package->module_row);
$api = $this->api($row);


$row = $this->getModuleRow($package->module_row);
$api = $this->api($row);


$this->log($row->meta->api_username . "|ssl-domain-emails", serialize($domain), "input", true);

$gogetssl_approver_emails = array();
try {

$gogetssl_approver_emails = $this->parseResponse($api->getDomainEmails($domain), $row);
$response = $api->getDomainEmails($domain);

$gogetssl_approver_emails = $this->parseResponse($response, $row);
}
catch (Exception $e) {
// Error, invalid authorization
$this->Input->setErrors(array('api' => array('internal' => Language::_("GoGetSSLv2.!error.api.internal", true))));
}
//error checking response
if ($this->Input->errors())
$lib->sendAjax($response,false);

$emails = array();
if($this->isComodoCert($api, $package) && isset($gogetssl_approver_emails['ComodoApprovalEmails']))
Expand Down Expand Up @@ -2277,7 +2263,7 @@ public function generateCSR($request,$dataRequest){

//we can use generate ourselfs or use API
$row = $this->getModuleRow($package->module_row);
$api = $this->getApi($row->meta->api_username, $row->meta->api_password, $row->meta->sandbox, $row);
$api = $this->api($row);

//@issue gossl sandbox does not support SHA2 for some reason
$SHA = ($row->meta->sandbox == "true" ? "SHA1" : "SHA2");
Expand Down Expand Up @@ -2329,6 +2315,8 @@ public function generateCSR($request,$dataRequest){
$lib->sendAjax($response);

}


}


Expand Down
6 changes: 6 additions & 0 deletions views/default/js/tab_client_install.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ var gogetssl_other_methods = {};
$("#get_approver_email").show();
});

//show blesta loading on submit
$("#submit_install").click(function(){
$("#installCsrForm").append($(this).blestaLoadingDialog());
});
//***********************FINAL PAGE MODIFICATIONS**************************************
$(".install_methods").hide();
$("#other_methods_div").hide();
Expand Down Expand Up @@ -256,4 +260,6 @@ var gogetssl_other_methods = {};
}
});
}



2 changes: 1 addition & 1 deletion views/default/js/tab_client_install.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/default/tab_client_install.pdt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
$this->Form->fieldText("gogetssl_organization_unit", $this->Html->ifSet($vars->gogetssl_organization_unit), array('id' => "gogetssl_organization_unit", 'class'=>"form-control"));
?>
</div>
<button class="btn btn-success pull-right">Submit</button>
<button id="submit_install" class="btn btn-success pull-right">Submit</button>
</div>

</div>
Expand Down

0 comments on commit 2b747b0

Please sign in to comment.