This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/ssl/classes/Controller/Reseller/Ssl.php

158 lines
4.2 KiB
PHP
Raw Normal View History

2013-11-08 11:02:32 +00:00
<?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
*/
2016-07-29 01:19:30 +00:00
class Controller_Reseller_Ssl extends Controller_Ssl {
protected $auth_required = TRUE;
2013-11-08 11:02:32 +00:00
protected $secure_actions = array(
'add'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
'renew'=>TRUE,
'listchildca'=>TRUE,
'listchildcrt'=>TRUE,
);
public function action_list() {
2015-09-29 01:54:45 +00:00
$o = ORM::factory('SSL_CA')->where_authorised($this->ao);
if ($this->request->param('id') != 'Y')
$o->where_active();
2016-07-29 01:19:30 +00:00
$this->meta->title = 'SSL List';
2013-11-08 11:02:32 +00:00
Block::factory()
->title('SSL CA Certificates')
2016-07-29 01:19:30 +00:00
->title_icon('fa fa-shield')
2013-11-08 11:02:32 +00:00
->body(Table::factory()
->jssort('ca')
2015-09-29 01:54:45 +00:00
->data($o->find_all())
2013-11-08 11:02:32 +00:00
->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)->where_active()->list_childca())
2013-11-08 11:02:32 +00:00
->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')
2016-07-29 01:19:30 +00:00
->title_icon('fa fa-wrench')
2013-11-08 11:02:32 +00:00
->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))
2016-07-29 01:19:30 +00:00
->title_icon('fa fa-wrench')
2013-11-08 11:02:32 +00:00
->body($this->add_edit($id,$output));
}
public function action_renew() {
$so = ORM::factory('Service',$this->request->param('id'));
2013-11-08 11:02:32 +00:00
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
$so->plugin()->renew($this->request->query('force'));
2013-11-08 11:02:32 +00:00
HTTP::redirect(URL::link('user','service/view/'.$so->id));
}
private function add_edit($id=NULL,$output='') {
$sco = ORM::factory('SSL_CA',$id);
if ($this->request->post()) {
if (! $sco->account_id)
$sco->account_id = (string)Auth::instance()->get_user();
// Set our values, so that our filters have data
$sco->values($this->request->post());
// To trigger our filter to get the correct parent
$sco->parent_ssl_ca_id = -1;
if ($sco->changed() AND ! $this->save($sco))
$sco->reload();
}
2013-11-08 11:02:32 +00:00
2016-07-29 01:19:30 +00:00
$this->meta->title = 'SSL: '.$sco->name();
2013-11-08 11:02:32 +00:00
return View::factory('ssl/reseller/add_edit')
->set('o',$sco);
}
}
?>