Minor fixes to ssl and core

This commit is contained in:
Deon George
2011-12-30 10:54:54 +11:00
parent 4a68621fc7
commit 125407656d
9 changed files with 77 additions and 13 deletions

View File

@@ -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();

View File

@@ -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);
}
}
?>