2011-12-16 23:31:35 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides Admin SSL functions
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @subpackage SSL
|
|
|
|
* @category Controllers/Admin
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
|
|
|
|
protected $secure_actions = array(
|
2011-12-26 13:52:46 +00:00
|
|
|
'add'=>TRUE,
|
2011-12-16 23:31:35 +00:00
|
|
|
'list'=>TRUE,
|
2011-12-26 13:52:46 +00:00
|
|
|
'view'=>TRUE,
|
2011-12-16 23:31:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
public function action_list() {
|
|
|
|
Block::add(array(
|
2011-12-29 02:52:24 +00:00
|
|
|
'title'=>_('SSL CA Certificates'),
|
2011-12-16 23:31:35 +00:00
|
|
|
'body'=>Table::display(
|
|
|
|
ORM::factory('ssl_ca')->find_all(),
|
|
|
|
25,
|
|
|
|
array(
|
2011-12-26 13:52:46 +00:00
|
|
|
'id'=>array('label'=>'ID','url'=>'admin/ssl/view/'),
|
2011-12-16 23:31:35 +00:00
|
|
|
'sign_cert'=>array('label'=>'Cert'),
|
|
|
|
'issuer()'=>array('label'=>'Issuer'),
|
2012-12-19 06:28:39 +00:00
|
|
|
'valid_to(TRUE)'=>array('label'=>'Expires'),
|
2011-12-16 23:31:35 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'page'=>TRUE,
|
|
|
|
'type'=>'select',
|
2011-12-26 13:52:46 +00:00
|
|
|
'form'=>'admin/ssl/view',
|
2011-12-16 23:31:35 +00:00
|
|
|
)),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-12-26 13:52:46 +00:00
|
|
|
private function add_view($id=NULL,$output='') {
|
2011-12-16 23:31:35 +00:00
|
|
|
$so = ORM::factory('ssl_ca',$id);
|
|
|
|
|
|
|
|
if ($_POST) {
|
2012-12-19 06:28:39 +00:00
|
|
|
if ($so->values($_POST)->changed()) {
|
|
|
|
try {
|
|
|
|
$so->save();
|
|
|
|
SystemMessage::add(array(
|
|
|
|
'title'=>'SSL Certificate Saved',
|
|
|
|
'type'=>'info',
|
|
|
|
'body'=>'SSL Certificate successfully recorded.',
|
|
|
|
));
|
|
|
|
|
|
|
|
} catch (ORM_Validation_Exception $e) {
|
|
|
|
$errors = $e->errors('models');
|
|
|
|
|
|
|
|
SystemMessage::add(array(
|
|
|
|
'title'=>'SSL Certificate NOT saved',
|
|
|
|
'type'=>'error',
|
|
|
|
'body'=>join("\n",array_values($errors)),
|
|
|
|
));
|
|
|
|
|
|
|
|
$so->reload();
|
|
|
|
}
|
|
|
|
}
|
2011-12-16 23:31:35 +00:00
|
|
|
}
|
|
|
|
|
2011-12-26 13:52:46 +00:00
|
|
|
$output .= Form::open();
|
|
|
|
$output .= View::factory('ssl/admin/add_view')
|
2012-12-19 06:28:39 +00:00
|
|
|
->set('o',$so);
|
2011-12-26 13:52:46 +00:00
|
|
|
$output .= Form::submit('submit','submit',array('class'=>'form_button'));
|
|
|
|
$output .= Form::close();
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function action_add() {
|
|
|
|
Block::add(array(
|
|
|
|
'title'=>_('Add SSL CA Certificate'),
|
|
|
|
'body'=>$this->add_view(),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function action_view() {
|
|
|
|
list($id,$output) = Table::page(__METHOD__);
|
2011-12-21 01:39:21 +00:00
|
|
|
|
2011-12-16 23:31:35 +00:00
|
|
|
Block::add(array(
|
2011-12-26 13:52:46 +00:00
|
|
|
'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('ssl_ca',$id)->display('sign_cert')),
|
|
|
|
'body'=>$this->add_view($id,$output),
|
2011-12-16 23:31:35 +00:00
|
|
|
));
|
2012-10-22 12:24:28 +00:00
|
|
|
|
|
|
|
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',
|
|
|
|
)),
|
|
|
|
));
|
|
|
|
|
2011-12-16 23:31:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|