Status updates, SSL updates

This commit is contained in:
Deon George
2013-11-08 22:02:32 +11:00
parent 28ea1ac613
commit 2d9d7f383c
31 changed files with 688 additions and 299 deletions

View File

@@ -1,109 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Admin SSL functions
*
* @package SSL
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'add'=>TRUE,
'list'=>TRUE,
'view'=>TRUE,
);
public function action_list() {
Block::add(array(
'title'=>_('SSL CA Certificates'),
'body'=>Table::display(
ORM::factory('SSL_CA')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('admin','ssl/view/')),
'sign_cert'=>array('label'=>'Cert'),
'issuer()'=>array('label'=>'Issuer'),
'valid_to(TRUE)'=>array('label'=>'Expires'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('admin','ssl/view'),
)),
));
}
private function add_view($id=NULL,$output='') {
$so = ORM::factory('SSL_CA',$id);
if ($_POST) {
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();
}
}
}
$output .= Form::open();
$output .= View::factory('ssl/admin/add_view')
->set('o',$so);
$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__);
Block::add(array(
'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('SSL_CA',$id)->display('sign_cert')),
'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'=>URL::link('admin','service/view/')),
'plugin()->dn()'=>array('label'=>'Cert'),
'plugin()->valid_to(TRUE)'=>array('label'=>'Expires'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('admin','service/view'),
)),
));
}
}
?>

View File

@@ -0,0 +1,162 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller SSL functions
*
* @package SSL
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_SSL extends Controller_SSL {
protected $secure_actions = array(
'add'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
'renew'=>TRUE,
'listchildca'=>TRUE,
'listchildcrt'=>TRUE,
);
public function action_list() {
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)->find_all())
->columns(array(
'id'=>'ID',
'sign_cert'=>'Cert',
'valid_to(TRUE)'=>'Expires',
'validParent(TRUE)'=>'Valid',
'childca(TRUE)'=>'cCA',
'childcrt(TRUE)'=>'Crts',
'issuer()'=>'Issuer',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','ssl/edit/')),
'childca(TRUE)'=>array('url_resolve'=>URL::link('reseller','ssl/listchildca/%id%')),
'childcrt(TRUE)'=>array('url_resolve'=>URL::link('reseller','ssl/listchildcrt/%id%')),
))
);
}
public function action_listchildca() {
list($id,$output) = Table::page(__METHOD__);
$sco = ORM::factory('SSL_CA',$id);
if ($sco->childca())
Block::factory()
->title(sprintf('SSL CA Certificates for CA: %s',$sco->dn()))
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('ca')
->data($sco->where_authorised($this->ao)->list_childca())
->columns(array(
'id'=>'ID',
'sign_cert'=>'Cert',
'ski()'=>'Identifier',
'valid_to(TRUE)'=>'Expires',
'validParent(TRUE)'=>'Valid',
'childca()'=>'cCA',
'childcrt()'=>'Crts',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','ssl/edit/')),
'childca()'=>array('url_resolve'=>URL::link('reseller','ssl/listchildca/%id%')),
'childcrt()'=>array('url_resolve'=>URL::link('reseller','ssl/listchildcrt/%id%')),
))
);
if ($sco->childcrt())
$this->action_listchildcrt();
}
public function action_listchildcrt() {
list($id,$output) = Table::page(__METHOD__);
$sco = ORM::factory('SSL_CA',$id);
Block::factory()
->title(sprintf('SSL Certificates for CA: %s',$sco->dn()))
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('crt')
->data($sco->where_authorised($this->ao)->list_childcrt())
->columns(array(
'id'=>'ID',
'plugin()->dn()'=>'Cert',
'plugin()->valid_to(TRUE)'=>'Expires',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
public function action_add() {
Block::factory()
->type('form-horizontal')
->title('Add/View SSL CA')
->title_icon('icon-wrench')
->body($this->add_edit());
}
public function action_edit() {
list($id,$output) = Table::page(__METHOD__);
Block::factory()
->type('form-horizontal')
->title(sprintf('%s: %s',_('Add/View SSL CA'),$id))
->title_icon('icon-wrench')
->body($this->add_edit($id,$output));
}
public function action_renew() {
$so = ORM::factory('Service',Request::current()->param('id'));
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
SystemMessage::factory()
->title('SSL Certificate not updated')
->type('error')
->body('Either the Service doesnt exist, or you are not authorised to see it');
HTTP::redirect('welcome');
}
$so->plugin()->renew();
HTTP::redirect(URL::link('user','service/view/'.$so->id));
}
private function add_edit($id=NULL,$output='') {
$sco = ORM::factory('SSL_CA',$id);
if ($_POST) {
// Entry updated
if ($sco->values($_POST)->check()) {
try {
$sco->save();
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your Charge record has been recorded/updated.'));
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors('models');
SystemMessage::factory()
->title('Record NOT updated')
->type('error')
->body(join('<br/>',array_values($errors)));
$sco->reload();
}
}
}
return View::factory('ssl/reseller/add_edit')
->set('o',$sco);
}
}
?>