Minor fixes to ssl and core
This commit is contained in:
parent
4a68621fc7
commit
125407656d
@ -23,8 +23,8 @@ class Controller_TemplateDefault_User extends Controller_TemplateDefault {
|
||||
parent::before();
|
||||
|
||||
$this->ao = Auth::instance()->get_user();
|
||||
if (! $this->ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>Auth::instance()->get_user()->id));
|
||||
if (is_string($this->ao) OR ! $this->ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>is_string($this->ao) ? $this->ao : Auth::instance()->get_user()->id));
|
||||
}
|
||||
|
||||
public function after() {
|
||||
|
36
application/classes/kohana.php
Normal file
36
application/classes/kohana.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class overrides Kohana's Core
|
||||
*
|
||||
* @package OSB/Modifications
|
||||
* @category Classes
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Kohana extends Kohana_Core {
|
||||
/**
|
||||
* Override Kohana's shutdown_handler()
|
||||
*
|
||||
* When set up for multi-site, we need to disable Kohana's caching
|
||||
* unless each site has exactly the same modules enabled.
|
||||
* This is because Kohana::$file is cached with the enabled modules
|
||||
* and is not OSB multi-site aware.
|
||||
*
|
||||
* @todo It might be nice to cache the Kohana::$file site-aware for improved performance
|
||||
*/
|
||||
public static function shutdown_handler() {
|
||||
// If caching isnt enabled, we can skip this anyway
|
||||
if (! Kohana::$caching)
|
||||
return parent::shutdown_handler();;
|
||||
|
||||
Kohana::$caching = FALSE;
|
||||
$result = parent::shutdown_handler();
|
||||
Kohana::$caching = TRUE;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
@ -124,6 +124,7 @@ class ORM extends Kohana_ORM {
|
||||
->from($this->_has_many[$alias]['through'])
|
||||
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
||||
->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys)
|
||||
->where('site_id', '=', Config::siteid())
|
||||
->execute($this->_db)->get('records_found');
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,10 @@
|
||||
<div id="kohana-profiler" style="display: none;"><?php echo View::factory('profiler/stats'); ?></div>
|
||||
<script type="text/javascript">$("#ajFOOT").click(function() {$('#kohana-profiler').toggle();});</script>
|
||||
<?php }?>
|
||||
<?php if (Config::sitemode() >= Kohana::STAGING) { ?>
|
||||
<div id="kohana-session" style="display: none; text-align: left;"><?php echo debug::vars(Session::instance()); ?></div>
|
||||
<script type="text/javascript">$("#ajFOOT").click(function() {$('#kohana-session').toggle();});</script>
|
||||
<?php }?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -28,7 +28,6 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
|
||||
'id'=>array('label'=>'ID','url'=>'product/view/'),
|
||||
'name()'=>array('label'=>'Details'),
|
||||
'active'=>array('label'=>'Active'),
|
||||
'prod_plugin'=>array('label'=>'Plugin'),
|
||||
'prod_plugin_file'=>array('label'=>'Plugin Name'),
|
||||
'prod_plugin_data'=>array('label'=>'Plugin Data'),
|
||||
'price_type'=>array('label'=>'Price Type'),
|
||||
|
@ -89,7 +89,7 @@ class Model_Product extends ORMOSB {
|
||||
// Work out the best price for the user
|
||||
$price = array();
|
||||
foreach (unserialize($this->price_group) as $bill_freq => $pg) {
|
||||
if ($pg['show'])
|
||||
if (isset($pg['show']) AND $pg['show'])
|
||||
foreach ($groups as $gid) {
|
||||
if (! empty($pg[$gid])) {
|
||||
if (empty($price[$bill_freq]['price_base'])
|
||||
@ -101,7 +101,8 @@ class Model_Product extends ORMOSB {
|
||||
}
|
||||
}
|
||||
|
||||
return $price;
|
||||
// @todo Ugly hack
|
||||
return $price ? $price : array('0'=>array('price_base'=>0,'price_setup'=>0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,15 +41,12 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
|
||||
$so = ORM::factory('ssl_ca',$id);
|
||||
|
||||
if ($_POST) {
|
||||
if (! $so->values($_POST)->check() OR ! $so->save())
|
||||
throw new Kohana_Exception('Failed to save updates to data for record :record',array(':record'=>$so->id()));
|
||||
else {
|
||||
if ($so->values($_POST)->check() AND $so->save())
|
||||
SystemMessage::add(array(
|
||||
'title'=>'SSL Certificate Saved',
|
||||
'type'=>'info',
|
||||
'body'=>'SSL Certificate successfully recorded.',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$output .= Form::open();
|
||||
|
@ -34,7 +34,36 @@ class Model_SSL_CA extends ORMOSB {
|
||||
return SSL::issuer($this->sign_cert);
|
||||
}
|
||||
|
||||
public function subject() {
|
||||
return SSL::subject($this->sign_cert);
|
||||
}
|
||||
|
||||
// @todo SAVE: auto work out the parent_ssl_ca_id
|
||||
public function save(Validation $validation = NULL) {
|
||||
// If our parent_ssl_ca_id is null, we'll need to work it out
|
||||
if (is_null($this->parent_ssl_ca_id)) {
|
||||
$i = SSL::issuer($this->sign_cert);
|
||||
|
||||
$po = NULL;
|
||||
foreach (ORM::factory('ssl_ca')->find_all() as $sco)
|
||||
if ($sco->subject() == $i) {
|
||||
$po = $sco;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_null($po)) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>'Certificate NOT Recorded',
|
||||
'type'=>'warning',
|
||||
'body'=>sprintf('Parent Certificate is not available (%s)',$this->issuer()),
|
||||
));
|
||||
|
||||
return FALSE;
|
||||
} else
|
||||
$this->parent_ssl_ca_id = $po->id;
|
||||
}
|
||||
|
||||
// Save the record
|
||||
return parent::save($validation);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,4 +1,3 @@
|
||||
<?php echo Form::open(); ?>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Subject</td>
|
||||
@ -37,5 +36,3 @@
|
||||
<td><?php echo FORM::textarea('sign_cert',$so->sign_cert,array('cols'=>64,'rows'=>13)); ?></td>
|
||||
</tr>
|
||||
<table>
|
||||
<?php echo Form::submit('submit',_('Update'),array('class'=>'form_button')); ?>
|
||||
<?php echo Form::close(); ?>
|
||||
|
Reference in New Issue
Block a user