Misc fixes from live

This commit is contained in:
Deon George 2015-09-29 11:54:45 +10:00
parent df74512105
commit 425ea9ff10
10 changed files with 80 additions and 35 deletions

View File

@ -26,6 +26,8 @@ abstract class ORM extends lnApp_ORM {
$this->where($this->_object_name.'.site_id','=',Company::instance()->site());
// Ensure we Cache our queries
// @todo: Disabled as it is not working as expected
/*
$caching = FALSE;
foreach ($this->_db_pending as $method)
if ($method['name'] == 'cached') {
@ -35,6 +37,7 @@ abstract class ORM extends lnApp_ORM {
if (! $caching)
$this->cached(Kohana::$config->load('cache.orm.'.$this->_table_name));
*/
return parent::_build($type);
}

View File

@ -128,7 +128,7 @@ class ADSL_Billing_Exetelvisp {
list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3])));
$result[$service]['credit'] = str_replace('$','',$record[6]);
} elseif (preg_match('/Excess usage charges for /',$record[3])) {
} elseif (preg_match('/Excess usage charges/',$record[3])) {
list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3])));
$result[$service]['excess'] = str_replace('$','',$record[7]);

View File

@ -19,6 +19,10 @@ class Model_Charge extends ORM_OSB implements Invoicable {
'invoice_item'=>array('far_key'=>'id'),
);
protected $_compress_column = array(
'attributes',
);
protected $_nullifempty = array(
'attributes',
);

View File

@ -27,6 +27,8 @@
<dd><?php echo HTML::anchor($o->registrar->whitelabel_url,NULL); ?></dd>
<dt>Username</dt>
<dd><?php echo $o->registrar_username; ?></dd>
<dt>Password</dt>
<dd><?php echo $o->registrar_password; ?></dd>
<?php endif ?>
</div> <!-- dl-horizontal -->
</fieldset>

View File

@ -19,6 +19,8 @@
<dd><?php echo HTML::anchor($o->host->whitelabel_url,NULL); ?></dd>
<dt>Username</dt>
<dd><?php echo $o->host_username; ?></dd>
<dt>Password</dt>
<dd><?php echo $o->host_password; ?></dd>
<?php endif ?>
</div> <!-- dl-horizontal -->
</fieldset>

View File

@ -222,9 +222,10 @@ class Model_Invoice extends ORM_OSB implements Cartable {
* Check the reminder value
*/
public function remind($key) {
if (isset($this->reminders[$key]))
return (is_array($this->reminders[$key])) ? end($this->reminders[$key]) : $this->reminders[$key];
else
if (isset($this->reminders[$key])) {
$x = $this->reminders[$key];
return is_array($x) ? end($x) : $x;
} else
return FALSE;
}

View File

@ -20,12 +20,16 @@ class Controller_Reseller_SSL extends Controller_SSL {
);
public function action_list() {
$o = ORM::factory('SSL_CA')->where_authorised($this->ao);
if ($this->request->param('id') != 'Y')
$o->where_active();
Block::factory()
->title('SSL CA Certificates')
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('ca')
->data(ORM::factory('SSL_CA')->where_authorised($this->ao)->where_active()->find_all())
->data($o->find_all())
->columns(array(
'id'=>'ID',
'sign_cert'=>'Cert',

View File

@ -56,8 +56,12 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
public function __call($name,$args) {
$m = 'get_'.$name;
if (method_exists($this->_so,$m))
if ($this->isCSR() AND method_exists($this,$m))
return $this->{$m}($args);
elseif (method_exists($this->_so,$m))
return $this->_so->{$m}($args);
else
throw new Kohana_Exception('Unknown method :method',array(':method'=>$name));
}
@ -72,6 +76,13 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $this;
}
/**
* Is this just a CSR?
*/
public function isCSR() {
return ! $this->cert AND $this->csr;
}
/**
* Return all our CA Certs for this certificate
*/
@ -103,17 +114,33 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $output;
}
public function get_dn() {
return SSL::csrsubject($this->csr);
}
public function get_valid_to() {
// @todo
return 'Unknown';
}
/**
* Renew an SSL Certificate
*/
// @todo: Renew renews the expiry date as 1 day too early.
public function renew($force=FALSE) {
$sslo = SSL::instance($this->cert);
$ssl_conf = Kohana::$config->load('ssl');
if ($this->cert) {
$sslo = SSL::instance($this->cert);
// If our certificate is not old enough skip
if ($sslo->get_valid_to() > time()+$ssl_conf['min_renew_days']*86400 AND ! $force)
return FALSE;
} elseif (! $this->csr) {
throw new Kohana_Exception('Unable to renew, no CERT or CSR');
}
$today = mktime(0,0,0,date('n'),date('j'),date('Y'));
$days = (int)(($this->service->invoiced_to()-$today)/86400);

View File

@ -28,7 +28,7 @@ class SSL {
private static function _dec_to_hex($number) {
$hex = array();
if ($number == 0)
if ($number == 0 OR ! $number)
return '00';
while ($number > 0) {

View File

@ -6,6 +6,7 @@
<dt>DN</dt>
<dd><?php echo $o->dn(); ?></dd>
<?php if (! $o->isCSR()) : ?>
<dt>Serial Number</dt>
<dd><?php echo $o->serial(); ?></dd>
@ -38,6 +39,7 @@
<dt>Algorithm</dt>
<dd><?php echo $o->algorithm(); ?></dd>
<?php endif ?>
</div> <!-- dl-horizontal -->
</fieldset>