Fixes for traffic, manage_button and SSL work

This commit is contained in:
Deon George 2012-10-22 23:24:28 +11:00
parent 59321a6877
commit 002c3b8f44
7 changed files with 42 additions and 11 deletions

View File

@ -152,8 +152,8 @@ Route::set('default', '(<controller>(/<action>(/<id>)))', array('id' => '[a-zA-Z
/** /**
* If APC is enabled, and we need to clear the cache * If APC is enabled, and we need to clear the cache
*/ */
if (file_exists(APPPATH.'CLEAR_APC_CACHE') AND function_exists('apc_clear_cache') AND ! Kohana::$is_cli) { if (file_exists(APPPATH.'cache/CLEAR_APC_CACHE') AND function_exists('apc_clear_cache') AND ! Kohana::$is_cli) {
if (! apc_clear_cache() OR ! unlink(APPPATH.'CLEAR_APC_CACHE')) if (! apc_clear_cache() OR ! unlink(APPPATH.'cache/CLEAR_APC_CACHE'))
throw new Kohana_Exception('Unable to clear the APC cache.'); throw new Kohana_Exception('Unable to clear the APC cache.');
} }
?> ?>

View File

@ -19,11 +19,12 @@ class Model_Service_Plugin_ADSL_Traffic extends ORMOSB {
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
public function rules() { public function rules() {
return array( $result = parent::rules();
'site_id'=>array(
array('ORMOSB::set_site_id',array(':validation',':model',':field')), // We don use the "ID" field.
), unset($result['id']);
);
return $result;
} }
public function traffic(Model_Product_Plugin_ADSL $plan) { public function traffic(Model_Product_Plugin_ADSL $plan) {

View File

@ -74,7 +74,8 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
* to manage the domain. * to manage the domain.
*/ */
public function manage_button($t='') { public function manage_button($t='') {
parent::manage_button($t); if (! parent::manage_button($t))
return NULL;
return ($this->username_value() AND $this->password_value()) ? $this->domain_registrar->manage_button($this,$t) : _('Please contact us'); return ($this->username_value() AND $this->password_value()) ? $this->domain_registrar->manage_button($this,$t) : _('Please contact us');
} }

View File

@ -67,7 +67,8 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
* to manage the domain. * to manage the domain.
*/ */
public function manage_button($t='') { public function manage_button($t='') {
parent::manage_button($t); if (! parent::manage_button($t))
return NULL;
// @todo Convert this to a Static_List display // @todo Convert this to a Static_List display
if ($this->service->queue == 'PROVISION') if ($this->service->queue == 'PROVISION')

View File

@ -48,11 +48,14 @@ abstract class Model_Service_Plugin extends ORMOSB {
abstract public function password_value(); abstract public function password_value();
public function manage_button() { public function manage_button() {
if (! $this->service->status)
return FALSE;
static $k = ''; static $k = '';
// If $k is already set, we've rendered this JS // If $k is already set, we've rendered this JS
if ($k) if ($k)
return; return TRUE;
$k = Random::char(); $k = Random::char();
Session::instance()->set('manage_button',$k); Session::instance()->set('manage_button',$k);
@ -70,6 +73,8 @@ function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
}); });
});' });'
)); ));
return TRUE;
} }
/** /**

View File

@ -73,6 +73,24 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('ssl_ca',$id)->display('sign_cert')), 'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('ssl_ca',$id)->display('sign_cert')),
'body'=>$this->add_view($id,$output), 'body'=>$this->add_view($id,$output),
)); ));
Block::add(array(
'title'=>_('Services using this Certificate'),
'body'=>Table::display(
ORM::factory('ssl_ca',$id)->list_issued(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/service/view/'),
'plugin()->dn()'=>array('label'=>'Cert'),
'plugin()->valid_to(TRUE)'=>array('label'=>'Expires'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'admin/service/view',
)),
));
} }
} }
?> ?>

View File

@ -17,7 +17,8 @@ class Model_SSL_CA extends ORMOSB {
protected $_belongs_to = array( protected $_belongs_to = array(
); );
protected $_has_one = array( protected $_has_many = array(
'service'=>array('through'=>'service__ssl'),
); );
protected $_display_filters = array( protected $_display_filters = array(
@ -65,5 +66,9 @@ class Model_SSL_CA extends ORMOSB {
// Save the record // Save the record
return parent::save($validation); return parent::save($validation);
} }
public function list_issued() {
return $this->service->find_all();
}
} }
?> ?>