diff --git a/modules/service/classes/controller/admin/service.php b/modules/service/classes/controller/admin/service.php index e5d4aaab..038fef10 100644 --- a/modules/service/classes/controller/admin/service.php +++ b/modules/service/classes/controller/admin/service.php @@ -21,6 +21,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { 'listdomainservicesbysupplier'=>TRUE, 'listhostservices'=>TRUE, 'listhspaservices'=>TRUE, + 'listwebservices'=>TRUE, 'listinvoicesoon'=>TRUE, 'update'=>TRUE, ); @@ -334,6 +335,33 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { )), )); } + + public function action_listwebservices() { + $svs = ORM::factory('service')->list_bylistgroup('WEB'); + Sort::MAsort($svs,'name()'); + + Block::add(array( + 'title'=>_('SSL Services'), + 'body'=>Table::display( + $svs, + 25, + array( + 'id'=>array('label'=>'ID','url'=>'user/service/view/'), + 'service_name()'=>array('label'=>'Details'), + 'recur_schedule'=>array('label'=>'Billing'), + 'price'=>array('label'=>'Price','class'=>'right'), + 'account->accnum()'=>array('label'=>'Cust ID'), + 'account->name()'=>array('label'=>'Customer'), + 'display("date_next_invoice")'=>array('label'=>'Next Invoice'), + ), + array( + 'page'=>TRUE, + 'type'=>'select', + 'form'=>'user/service/view', + )), + )); + } + /** * Reconcile billing for an ADSL supplier * @@ -535,7 +563,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()), - 'body'=>View::factory($so->viewpath()) + 'body'=>View::factory($this->viewpath()) ->set('so',$so) ->set('mediapath',Route::get('default/media')) ->set('plugin_form',$so->admin_update()), diff --git a/modules/ssl/classes/controller/admin/ssl.php b/modules/ssl/classes/controller/admin/ssl.php index 1b2c8387..cc0ca1f0 100644 --- a/modules/ssl/classes/controller/admin/ssl.php +++ b/modules/ssl/classes/controller/admin/ssl.php @@ -12,8 +12,9 @@ */ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin { protected $secure_actions = array( + 'add'=>TRUE, 'list'=>TRUE, - 'update'=>TRUE, + 'view'=>TRUE, ); public function action_list() { @@ -23,7 +24,7 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin { ORM::factory('ssl_ca')->find_all(), 25, array( - 'id'=>array('label'=>'ID','url'=>'admin/ssl/update/'), + 'id'=>array('label'=>'ID','url'=>'admin/ssl/view/'), 'sign_cert'=>array('label'=>'Cert'), 'issuer()'=>array('label'=>'Issuer'), 'expires()'=>array('label'=>'Expires'), @@ -31,31 +32,49 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin { array( 'page'=>TRUE, 'type'=>'select', - 'form'=>'admin/ssl/update', + 'form'=>'admin/ssl/view', )), )); } - public function action_update() { - list($id,$output) = Table::page(__METHOD__); - + private function add_view($id=NULL,$output='') { $so = ORM::factory('ssl_ca',$id); - if (! $so->loaded()) - Request::current()->redirect('welcome/index'); - if ($_POST) { - if (! $so->values($_POST)->update()->saved()) - throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id())); + 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 { + SystemMessage::add(array( + 'title'=>'SSL Certificate Saved', + 'type'=>'info', + 'body'=>'SSL Certificate successfully recorded.', + )); + } } - $output .= View::factory($this->viewpath()) + $output .= Form::open(); + $output .= View::factory('ssl/admin/add_view') ->set('so',$so) ->set('mediapath',Route::get('default/media')); + $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',_('Update SSL Service'),$so->id,$so->display('sign_cert')), - 'body'=>$output, + 'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('ssl_ca',$id)->display('sign_cert')), + 'body'=>$this->add_view($id,$output), )); } } diff --git a/modules/ssl/classes/model/service/plugin/ssl.php b/modules/ssl/classes/model/service/plugin/ssl.php index 61f98d81..abb57b50 100644 --- a/modules/ssl/classes/model/service/plugin/ssl.php +++ b/modules/ssl/classes/model/service/plugin/ssl.php @@ -27,6 +27,9 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { 'csr'=>array( array('SSL::csrsubject',array(':value')), ), + 'cert'=>array( + array('SSL::subject',array(':value')), + ), ); // Required abstract functions @@ -36,7 +39,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { } public function name() { - return $this->display('csr'); + return $this->display($this->cert ? 'cert' : 'csr'); } // @todo This needs to be validated for this model @@ -47,12 +50,12 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { return $this->service->product->plugin(); } - public function valid_from() { - return SSL::from($this->cert); + public function valid_from($format=FALSE) { + return SSL::from($this->cert,$format); } - public function valid_to() { - return SSL::expire($this->cert); + public function valid_to($format=FALSE) { + return SSL::expire($this->cert,$format); } public function serial_num() { @@ -96,7 +99,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { } public function download_button() { - if (! preg_match('/client/',$this->ssl->extensions)) + if (! $this->service->active OR ! preg_match('/client/',$this->ssl->extensions) OR $this->valid_to() < time()) return ''; // @todo Do some password validation diff --git a/modules/ssl/classes/model/ssl/ca.php b/modules/ssl/classes/model/ssl/ca.php index b3c48696..19889003 100644 --- a/modules/ssl/classes/model/ssl/ca.php +++ b/modules/ssl/classes/model/ssl/ca.php @@ -33,5 +33,8 @@ class Model_SSL_CA extends ORMOSB { public function issuer() { return SSL::issuer($this->sign_cert); } + + + // @todo SAVE: auto work out the parent_ssl_ca_id } ?> diff --git a/modules/ssl/classes/ssl.php b/modules/ssl/classes/ssl.php index 94fd3120..55fa13ee 100644 --- a/modules/ssl/classes/ssl.php +++ b/modules/ssl/classes/ssl.php @@ -24,14 +24,14 @@ class SSL { return $k['issuer']['CN']; } - public static function from($key) { + public static function from($key,$format=FALSE) { $k = static::details($key); - return Config::date($k['validFrom_time_t']); + return $format ? Config::date($k['validFrom_time_t']) : $k['validFrom_time_t']; } - public static function expire($key) { + public static function expire($key,$format=FALSE) { $k = static::details($key); - return Config::date($k['validTo_time_t']); + return $format ? Config::date($k['validTo_time_t']) : $k['validTo_time_t']; } public static function hash($key) { diff --git a/modules/ssl/views/service/user/plugin/ssl/view.php b/modules/ssl/views/service/user/plugin/ssl/view.php index 76239ea4..22203bb6 100644 --- a/modules/ssl/views/service/user/plugin/ssl/view.php +++ b/modules/ssl/views/service/user/plugin/ssl/view.php @@ -15,11 +15,11 @@