Internal overhaul of Cart/Checkout and other minor fixes
This commit is contained in:
@@ -127,8 +127,18 @@ class Controller_Reseller_SSL extends Controller_SSL {
|
||||
private function add_edit($id=NULL,$output='') {
|
||||
$sco = ORM::factory('SSL_CA',$id);
|
||||
|
||||
if ($_POST AND $sco->values($_POST)->changed() AND ! ($this->save($sco)))
|
||||
$sco->reload();
|
||||
if ($this->request->post()) {
|
||||
if (! $sco->account_id)
|
||||
$sco->account_id = (string)Auth::instance()->get_user();
|
||||
|
||||
// Set our values, so that our filters have data
|
||||
$sco->values($this->request->post());
|
||||
// To trigger our filter to get the correct parent
|
||||
$sco->parent_ssl_ca_id = -1;
|
||||
|
||||
if ($sco->changed() AND ! $this->save($sco))
|
||||
$sco->reload();
|
||||
}
|
||||
|
||||
return View::factory('ssl/reseller/add_edit')
|
||||
->set('o',$sco);
|
||||
|
@@ -36,15 +36,16 @@ class Model_SSL_CA extends ORM_OSB {
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
return array(
|
||||
return Arr::merge(parent::rules(),array(
|
||||
'sign_cert'=>array(
|
||||
array('not_empty'),
|
||||
array(array($this,'isCert')),
|
||||
array(array($this,'isCA')),
|
||||
),
|
||||
'parent_ssl_ca_id'=>array(
|
||||
array(array($this,'rule_parentExist')),
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
private $_so = NULL;
|
||||
@@ -120,10 +121,30 @@ class Model_SSL_CA extends ORM_OSB {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter to find the parent SSL_CA
|
||||
*
|
||||
* @notes This filter only runs when the value passed is -1
|
||||
*/
|
||||
public function filter_getParent() {
|
||||
foreach (ORM::factory($this->_object_name)->find_all() as $sco)
|
||||
if ($sco->aki_keyid() == $this->aki_keyid())
|
||||
// This cannot be an array
|
||||
if (count(func_get_args()) != 1)
|
||||
return NULL;
|
||||
|
||||
$x = func_get_args();
|
||||
$x = array_pop($x);
|
||||
|
||||
// This filter only runs when our value is -1
|
||||
if ($x != -1)
|
||||
return $x;
|
||||
|
||||
foreach (ORM::factory($this->_object_name)->find_all() as $sco) {
|
||||
if ($sco->ski() == $this->aki_keyid())
|
||||
return $sco->id;
|
||||
}
|
||||
|
||||
// If we got here, we couldnt find it
|
||||
return $this->isRoot() ? NULL : $x;
|
||||
}
|
||||
|
||||
public function list_childca() {
|
||||
@@ -136,7 +157,7 @@ class Model_SSL_CA extends ORM_OSB {
|
||||
|
||||
public function rule_parentExist() {
|
||||
// Our parent_ssl_ca_id should have been populated by filter_GetParent().
|
||||
return $this->parent_ssl_ca_id OR $this->isRoot();
|
||||
return ($this->parent_ssl_ca_id > 0) OR $this->isRoot();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -72,36 +72,20 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validCA() {
|
||||
return $this->ca->validParent();
|
||||
}
|
||||
|
||||
// If we change the SSL certificate, we need to reload our SSL object
|
||||
public function values(array $values, array $expected = NULL) {
|
||||
parent::values($values,$expected);
|
||||
|
||||
if (array_key_exists('cert',$values))
|
||||
$this->_so = SSL::instance($this->cert);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific service details for use in other modules
|
||||
* For Example: Invoice
|
||||
*
|
||||
* @todo Make the rendered items configurable
|
||||
* @todo Change this method name, now that it is public
|
||||
* Return all our CA Certs for this certificate
|
||||
*/
|
||||
// @todo This needs to be validated for this model
|
||||
public function _details($type) {
|
||||
switch ($type) {
|
||||
case 'invoice_detail_items':
|
||||
return array();
|
||||
break;
|
||||
default:
|
||||
return parent::$_details($type);
|
||||
public function cacerts() {
|
||||
$result = array();
|
||||
|
||||
$x = $this->ssl_ca_id;
|
||||
while ($x) {
|
||||
$sco = ORM::factory('SSL_CA',$x);
|
||||
array_push($result,$sco->sign_cert);
|
||||
$x = $sco->parent_ssl_ca_id;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function download_button() {
|
||||
@@ -119,19 +103,6 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function cacerts() {
|
||||
$result = array();
|
||||
|
||||
$x = $this->ssl_ca_id;
|
||||
while ($x) {
|
||||
$sco = ORM::factory('SSL_CA',$x);
|
||||
array_push($result,$sco->sign_cert);
|
||||
$x = $sco->parent_ssl_ca_id;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renew an SSL Certificate
|
||||
*/
|
||||
@@ -171,5 +142,37 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
|
||||
throw new Kohana_Exception('Error Creating SSL Certificate :error',array(':error'=>openssl_error_string()));
|
||||
}
|
||||
}
|
||||
|
||||
public function validCA() {
|
||||
return $this->ca->validParent();
|
||||
}
|
||||
|
||||
// If we change the SSL certificate, we need to reload our SSL object
|
||||
public function values(array $values, array $expected = NULL) {
|
||||
parent::values($values,$expected);
|
||||
|
||||
if (array_key_exists('cert',$values))
|
||||
$this->_so = SSL::instance($this->cert);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific service details for use in other modules
|
||||
* For Example: Invoice
|
||||
*
|
||||
* @todo Make the rendered items configurable
|
||||
* @todo Change this method name, now that it is public
|
||||
*/
|
||||
// @todo This needs to be validated for this model
|
||||
public function _details($type) {
|
||||
switch ($type) {
|
||||
case 'invoice_detail_items':
|
||||
return array();
|
||||
break;
|
||||
default:
|
||||
return parent::$_details($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -150,11 +150,11 @@ class SSL {
|
||||
}
|
||||
|
||||
public function get_isCA() {
|
||||
return preg_match('/CA:TRUE/',$this->_bc());
|
||||
return preg_match('/CA:TRUE/',$this->_bc()) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
public function get_isCert() {
|
||||
return is_array($this->_details());
|
||||
return is_array($this->_details()) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
public function get_isRoot() {
|
||||
|
@@ -16,7 +16,7 @@ return array(
|
||||
'isCA'=>'This is certificate is not a Certificate Authority certificate',
|
||||
),
|
||||
'parent_ssl_ca_id'=>array(
|
||||
'Rule_ParentExists'=>'The parent certificate doesnt exist, please define it first',
|
||||
'rule_parentExist'=>'The parent certificate doesnt exist, please define it first',
|
||||
),
|
||||
);
|
||||
?>
|
||||
|
@@ -46,6 +46,7 @@
|
||||
<div class="span6">
|
||||
<fieldset>
|
||||
<legend>Certificate</legend>
|
||||
|
||||
<pre><?php echo $o->cert; ?></pre>
|
||||
|
||||
<?php
|
||||
@@ -55,6 +56,5 @@
|
||||
echo Form::button('submit','Renew',array('class'=>'btn btn-primary'));
|
||||
endif
|
||||
?>
|
||||
|
||||
</fieldset>
|
||||
</div> <!-- /span -->
|
||||
|
@@ -52,5 +52,10 @@
|
||||
<?php echo Form::textarea('sign_pk',$o->sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?>
|
||||
<?php echo Form::textarea('sign_cert',$o->sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?>
|
||||
|
||||
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
|
||||
<div class="row">
|
||||
<div class="offset2">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /span -->
|
||||
|
Reference in New Issue
Block a user