Internal overhaul of Cart/Checkout and other minor fixes
This commit is contained in:
parent
f8a5b153cf
commit
06b87c5135
@ -221,7 +221,7 @@ abstract class ORM extends Kohana_ORM {
|
||||
public function save(Validation $validation=NULL) {
|
||||
parent::save();
|
||||
|
||||
if ($this->saved() AND $this->_save_message)
|
||||
if ($this->saved() AND $this->_save_message AND (PHP_SAPI !== 'cli'))
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
|
@ -20,7 +20,7 @@ class Task_Adsl_Trafficalert extends Minion_Task {
|
||||
|
||||
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.
|
||||
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
|
||||
if ($params['verbose'])
|
||||
if (Minion_CLI::options('verbose'))
|
||||
echo $so->service_name()."\n";
|
||||
|
||||
if (! $data=$so->plugin()->traffic_report())
|
||||
|
@ -20,7 +20,7 @@ class Task_Adsl_Trafficcharge extends Minion_Task {
|
||||
|
||||
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.
|
||||
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
|
||||
if ($params['verbose'])
|
||||
if (Minion_CLI::options('verbose'))
|
||||
echo $so->service_name()."\n";
|
||||
|
||||
if ($x=$so->plugin()->traffic_excess($date)) {
|
||||
|
@ -22,8 +22,8 @@ class Task_Adsl_Trafficget extends Minion_Task {
|
||||
|
||||
protected function _execute(array $params) {
|
||||
foreach ($this->_traffic_suppliers(TRUE) as $aso) {
|
||||
if ($params['verbose'])
|
||||
echo $aso->name."\n";
|
||||
if (Minion_CLI::options('verbose'))
|
||||
printf("%s: %s\n",$aso->id,$aso->name);
|
||||
|
||||
Service_Traffic_Adsl::instance($aso->name)->update_traffic();
|
||||
}
|
||||
|
@ -6,5 +6,10 @@
|
||||
<?php echo Form::file('csv',array('label'=>'Invoice File','required')); ?>
|
||||
</fieldset>
|
||||
|
||||
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
|
||||
<div class="row">
|
||||
<div class="offset2">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /span -->
|
||||
|
@ -16,10 +16,6 @@ class Cart {
|
||||
$this->id = is_null($id) ? Session::instance()->id() : $id;
|
||||
}
|
||||
|
||||
public static function instance($id=NULL) {
|
||||
return new Cart($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of items in the cart
|
||||
*/
|
||||
@ -29,6 +25,20 @@ class Cart {
|
||||
->find_all();
|
||||
}
|
||||
|
||||
public function checkout() {
|
||||
$result = array();
|
||||
|
||||
$checkout = ORM::factory('Checkout')->where_active()->find_all()->as_array();
|
||||
|
||||
foreach ($this->contents() as $cio)
|
||||
$checkout = array_intersect($checkout,$cio->checkout()->as_array());
|
||||
|
||||
foreach ($checkout as $cko)
|
||||
$result[$cko->id] = $cko->name;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
foreach (ORM::factory('Cart')->where('session_id','=',$this->id)->find_all() as $co)
|
||||
$co->delete();
|
||||
@ -46,6 +56,10 @@ class Cart {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public static function instance($id=NULL) {
|
||||
return new Cart($id);
|
||||
}
|
||||
|
||||
public function total($format=FALSE) {
|
||||
$total = 0;
|
||||
|
||||
@ -54,43 +68,5 @@ class Cart {
|
||||
|
||||
return $format ? Currency::display($total) : $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an HTML cart list
|
||||
*
|
||||
* @param bool $detail List a detailed cart or a summary cart
|
||||
*/
|
||||
public function cart_block() {
|
||||
// @todo To implement.
|
||||
return '';
|
||||
// If the cart is empty, we'll return here.
|
||||
if (! count($this->contents()))
|
||||
return 'The cart is empty.';
|
||||
|
||||
Style::add(array(
|
||||
'type'=>'file',
|
||||
'data'=>'css/cart_blocklist.css',
|
||||
));
|
||||
|
||||
$output = '<table class="cart_blocklist" border="0">';
|
||||
foreach ($this->contents() as $item) {
|
||||
$ppa = $item->product->get_price_array();
|
||||
$pdata = Period::details($item->recurr_schedule,$item->product->price_recurr_weekday,time(),TRUE);
|
||||
|
||||
$output .= View::factory('cart/block_list')
|
||||
->set('item',$item)
|
||||
->set('price_setup',$item->quantity*$ppa[$item->recurr_schedule]['price_setup'])
|
||||
->set('price_firstinvoice',$item->quantity*$ppa[$item->recurr_schedule]['price_base']*$pdata['prorata']);
|
||||
}
|
||||
|
||||
$output .= '<tr class="submit">';
|
||||
$output .= sprintf('<td colspan="3">%s %s</td>',
|
||||
Form::button('checkout','Checkout',array('type' => 'submit')),
|
||||
Form::button('empty','Empty',array('type' => 'submit')));
|
||||
$output .= '</tr>';
|
||||
$output .= '</table>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -16,52 +16,21 @@ class Controller_Cart extends Controller_TemplateDefault {
|
||||
* List the cart contents
|
||||
*/
|
||||
public function action_index() {
|
||||
$output = '';
|
||||
$co = Cart::instance();
|
||||
|
||||
// If the cart is empty, we'll return here.
|
||||
if (! count($co->contents()))
|
||||
Block::add(array(
|
||||
'title'=>_('Empty Cart'),
|
||||
'body'=>_('The cart is empty')
|
||||
));
|
||||
if (! $co->contents()->count())
|
||||
$this->template->content = _('Cart is Empty');
|
||||
|
||||
else {
|
||||
Block::add(array(
|
||||
'title'=>_('Cart Items'),
|
||||
'body'=>Table::display(
|
||||
$co->contents(),
|
||||
NULL,
|
||||
array(
|
||||
'item()->q'=>array('label'=>'Quantity'),
|
||||
'item()->i'=>array('label'=>'Item'),
|
||||
'item()->t'=>array('label'=>'Total','class'=>'right'),
|
||||
),
|
||||
array(
|
||||
'type'=>'list',
|
||||
)
|
||||
),
|
||||
));
|
||||
$output = View::factory('cart/view')->set('o',$co);
|
||||
|
||||
$checkout = ORM::factory('Checkout')->where_active()->find_all()->as_array();
|
||||
|
||||
foreach ($co->contents() as $cio)
|
||||
$checkout = array_intersect($checkout,$cio->checkout()->as_array());
|
||||
|
||||
$payopt = array();
|
||||
foreach ($checkout as $cko)
|
||||
$payopt[$cko->id] = $cko->name;
|
||||
|
||||
$output .= _('Total amount due for payment').' '.$co->total(TRUE);
|
||||
$output .= Form::open('checkout/before');
|
||||
$output .= Form::select('checkout_id',$payopt);
|
||||
$output .= Form::submit('submit',_('Checkout'));
|
||||
$output .= View::factory('cart/payment')->set('o',$co);
|
||||
$output .= Form::close();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Payment'),
|
||||
'body'=>$output,
|
||||
));
|
||||
Block::factory()
|
||||
->body($output);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,24 +38,19 @@ class Controller_Cart extends Controller_TemplateDefault {
|
||||
* Add an item to the cart
|
||||
*/
|
||||
public function action_add() {
|
||||
$cart = ORM::factory('Cart');
|
||||
$co = ORM::factory('Cart');
|
||||
|
||||
$cart->session_id = Session::instance()->id();
|
||||
$co->values(Request::current()->post());
|
||||
$co->session_id = Session::instance()->id();
|
||||
|
||||
if ($cart->values(Request::current()->post())->check())
|
||||
$cart->save();
|
||||
else
|
||||
throw new Kohana_Exception('Unable to add to cart');
|
||||
if (! $this->save($co))
|
||||
throw HTTP_Exception::factory(501,_('There was a problem adding the item to the cart.'));
|
||||
|
||||
if ($cart->saved())
|
||||
HTTP::redirect('cart/index');
|
||||
else
|
||||
throw new Kohana_Exception(_('There was a problem adding the item to the cart.'));
|
||||
}
|
||||
|
||||
public function action_empty() {
|
||||
foreach (ORM::factory('Cart')->where('session_id','=',Session::instance()->id())->find_all() as $co)
|
||||
$co->delete();
|
||||
Cart::instance()->delete();
|
||||
|
||||
$this->template->content = _('Cart Emptied');
|
||||
}
|
||||
|
@ -10,13 +10,14 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Cart extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
);
|
||||
|
||||
// Cart doesnt use the update column
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
'module'=>array(),
|
||||
);
|
||||
|
||||
protected $_serialize_column = array(
|
||||
'module_data',
|
||||
);
|
||||
@ -30,46 +31,26 @@ class Model_Cart extends ORM_OSB {
|
||||
),
|
||||
);
|
||||
|
||||
private $mo;
|
||||
|
||||
public function __construct($id = NULL) {
|
||||
// Load our Model
|
||||
parent::__construct($id);
|
||||
|
||||
// Autoload our Sub Items
|
||||
if ($this->loaded())
|
||||
$this->_load_sub_items();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _load_sub_items() {
|
||||
$this->mo = ORM::factory('Module',$this->module_id)->instance($this->module_item);
|
||||
|
||||
if (! $this->mo->loaded())
|
||||
throw new Kohana_Exception('Item :item not loaded?',array(':item'=>$this->module_item));
|
||||
}
|
||||
|
||||
public function checkout() {
|
||||
if (! method_exists($this->mo,'checkout'))
|
||||
if (! method_exists($this->mo(),'checkout'))
|
||||
throw new Kohana_Exception('Module :module doesnt implement checkout?',array(':module'=>get_class($this->mo)));
|
||||
|
||||
return $this->mo->checkout();
|
||||
return $this->mo()->checkout();
|
||||
}
|
||||
|
||||
public function item() {
|
||||
if (! method_exists($this->mo,'cart_item'))
|
||||
if (! method_exists($this->mo(),'cart_item'))
|
||||
throw new Kohana_Exception('Module :module doesnt implement cart_item?',array(':module'=>get_class($this->mo)));
|
||||
|
||||
return $this->mo->cart_item();
|
||||
return $this->mo()->cart_item();
|
||||
}
|
||||
|
||||
public function mo() {
|
||||
return $this->mo;
|
||||
return $this->module->instance($this->module_item);
|
||||
}
|
||||
|
||||
public function motype() {
|
||||
return strtolower(preg_replace('/^Model_/','',get_class($this->mo)));
|
||||
return strtolower(preg_replace('/^Model_/','',get_class($this->mo())));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
24
modules/cart/views/cart/payment.php
Normal file
24
modules/cart/views/cart/payment.php
Normal file
@ -0,0 +1,24 @@
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<legend>Payment</legend>
|
||||
|
||||
<div class="dl-horizontal">
|
||||
<dt>Payment By</dt>
|
||||
<dd><?php echo Form::select('checkout_id',$o->checkout(),NULL,array('class'=>'small','nocg'=>TRUE)); ?></dd>
|
||||
|
||||
<dt>Total Due</dt>
|
||||
<dd><?php echo $o->total(TRUE); ?></dd>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="row"> </div>
|
||||
|
||||
<div class="row">
|
||||
<div class="offset1">
|
||||
<button type="submit" class="btn btn-primary">Checkout</button>
|
||||
<a href="cart/empty" class="btn">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /span -->
|
||||
|
||||
<div class="row"> </div>
|
13
modules/cart/views/cart/view.php
Normal file
13
modules/cart/views/cart/view.php
Normal file
@ -0,0 +1,13 @@
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<legend>Cart Contents</legend>
|
||||
|
||||
<?php echo Table::factory()
|
||||
->data($o->contents())
|
||||
->columns(array(
|
||||
'item()->q'=>'Quantity',
|
||||
'item()->i'=>'Item',
|
||||
'item()->t'=>'Total',
|
||||
)); ?>
|
||||
</fieldset>
|
||||
</div> <!-- /span -->
|
@ -24,5 +24,10 @@
|
||||
endfor ?>
|
||||
</fieldset>
|
||||
|
||||
<?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 -->
|
||||
|
@ -18,11 +18,12 @@ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
|
||||
public function before(Cart $co) {
|
||||
$output = '';
|
||||
|
||||
$output .= Form::open(sprintf('https://%s/cgi-bin/webscr',$this->test_mode ? $this->url_test : $this->url_prod),array('method'=>'POST'));
|
||||
|
||||
$output .= View::factory('checkout/plugin/paypal/before')
|
||||
->set('checkout',$this->co)
|
||||
->set('cart',$co);
|
||||
|
||||
$output .= Form::open(sprintf('https://%s/cgi-bin/webscr',$this->test_mode ? $this->url_test : $this->url_prod),array('method'=>'POST'));
|
||||
$output .= Form::hidden('cmd','_cart');
|
||||
$output .= Form::hidden('business',$this->test_mode ? 'deon_1260578114_biz@graytech.net.au' : 'deon@graytech.net.au');
|
||||
$output .= Form::hidden('bn','Graytech_BuyNow_WPS_AU');
|
||||
@ -46,7 +47,6 @@ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
|
||||
$output .= Form::hidden('item_name_'.$c,'Paypal Fee');
|
||||
$output .= Form::hidden('amount_'.$c,$this->co->fee($co->total()));
|
||||
|
||||
$output .= Form::submit('submit','Pay Now');
|
||||
$output .= Form::close();
|
||||
|
||||
return $output;
|
||||
|
16
modules/checkout/classes/Controller/Admin/Checkout.php
Normal file
16
modules/checkout/classes/Controller/Admin/Checkout.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Admin for Checkout management
|
||||
*
|
||||
* @package Checkout
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Checkout extends Controller_Checkout {
|
||||
protected $secure_actions = array(
|
||||
);
|
||||
}
|
||||
?>
|
@ -28,13 +28,8 @@ class Controller_Checkout extends Controller_TemplateDefault {
|
||||
|
||||
$co = ORM::factory('Checkout',$cid);
|
||||
|
||||
Block::add(array(
|
||||
'title'=>'Checkout',
|
||||
'body'=>$co->plugin()->before(Cart::instance()),
|
||||
));
|
||||
|
||||
// Suppress our right hand tab
|
||||
$this->template->right = ' ';
|
||||
Block::factory()
|
||||
->body($co->plugin()->before(Cart::instance()));
|
||||
}
|
||||
|
||||
public function action_after() {
|
||||
@ -71,6 +66,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
|
||||
$cno->status = 1;
|
||||
$cno->data = Request::current()->post();
|
||||
$cno->save();
|
||||
|
||||
} else {
|
||||
$cno->where('id','=',$test_id)->find();
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
<tr>
|
||||
<td class="icon"><label for="payment_<?php echo $payment->id; ?>"><?php echo FORM::radio('payment',$payment->id,0,array('id'=>'payment_'.$payment->id)); ?> <?php echo HTML::image($payment->graphic_url,array('alt'=>'')); ?> <?php echo $payment->name; ?></label></td>
|
||||
</tr>
|
@ -1,32 +1,30 @@
|
||||
<p>Paypal will be used to pay for the following items:</p>
|
||||
</br>
|
||||
<?php
|
||||
echo Table::display(
|
||||
$cart->contents(),
|
||||
NULL,
|
||||
array(
|
||||
'item()->q'=>array('label'=>'Quantity'),
|
||||
'item()->i'=>array('label'=>'Item'),
|
||||
'item()->t'=>array('label'=>'Total','class'=>'right'),
|
||||
),
|
||||
array(
|
||||
'type'=>'list',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</br>
|
||||
<p>Please Note: Paypal charges a fee to receive payments, and that fee will be added to your payment.</p>
|
||||
<table class="list-box-left">
|
||||
<tr class="list-data">
|
||||
<th>Cart Total</th>
|
||||
<td class="right"><?php echo $t=$cart->total(TRUE); ?></td>
|
||||
</tr>
|
||||
<tr class="list-data">
|
||||
<th>Payment Fee</th>
|
||||
<td class="right"><?php echo Currency::display($f=$checkout->fee($t)); ?></td>
|
||||
</tr>
|
||||
<tr class="list-data">
|
||||
<th>Total</th>
|
||||
<td class="right"><?php echo Currency::display($t+$f); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo View::factory('cart/view')->set('o',$cart); ?>
|
||||
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<legend>Payment by Paypal</legend>
|
||||
|
||||
<p>Please Note: Paypal charges a fee to receive payments, and that fee will be added to your payment.</p>
|
||||
<div class="dl-horizontal">
|
||||
<dt>Cart Total</dt>
|
||||
<dd><?php echo $t=$cart->total(TRUE); ?></dd>
|
||||
|
||||
<dt>Payment Fee</dt>
|
||||
<dd><?php echo Currency::display($f=$checkout->fee($t)); ?></dd>
|
||||
|
||||
<dt>Total</dt>
|
||||
<dd><?php echo Currency::display($t+$f); ?></dd>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="row"> </div>
|
||||
|
||||
<div class="row">
|
||||
<div class="offset1">
|
||||
<button type="submit" class="btn btn-primary">Pay Now</button>
|
||||
<a href="cart/empty" class="btn">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /span -->
|
||||
|
||||
<div class="row"> </div>
|
||||
|
@ -95,7 +95,9 @@ class Controller_Admin_Payment extends Controller_Payment {
|
||||
private function add_edit($id=NULL,$output='') {
|
||||
$po = ORM::factory('Payment',$id);
|
||||
|
||||
if ($_POST) {
|
||||
if ($this->request->post()) {
|
||||
$po->values($this->request->post());
|
||||
|
||||
// Update our invoice payment items
|
||||
if (isset($_POST['payment_item']) AND count($_POST['payment_item']))
|
||||
foreach ($_POST['payment_item'] as $k=>$v) {
|
||||
|
@ -15,7 +15,14 @@
|
||||
<?php echo Form::input('notes',$o->notes,array('class'=>'span5','label'=>'Notes','placeholder'=>'Any notes about this payment?')); ?>
|
||||
</fieldset>
|
||||
|
||||
<div class="span8" id="items"</div>
|
||||
<div class="span11">
|
||||
<div class="span8" id="items"></div>
|
||||
</div>
|
||||
|
||||
<?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 -->
|
||||
|
@ -7,5 +7,10 @@
|
||||
<?php echo Form::file('payment',array('label'=>'Payment File','required','help-block'=>'BillDetails')); ?>
|
||||
</fieldset>
|
||||
|
||||
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
|
||||
<div class="row">
|
||||
<div class="offset2">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /span -->
|
||||
|
@ -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)))
|
||||
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,12 +121,32 @@ 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() {
|
||||
return $this->children->find_all();
|
||||
}
|
||||
@ -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