More minor fixes
This commit is contained in:
parent
9569467153
commit
83a2c85a25
73
application/classes/Kohana/Exception.php
Normal file
73
application/classes/Kohana/Exception.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php defined('SYSPATH') OR die('No direct access');
|
||||||
|
/**
|
||||||
|
* Kohana exception class. Translates exceptions using the [I18n] class.
|
||||||
|
*
|
||||||
|
* @package TSM Access Management
|
||||||
|
* @category Modifications
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2009-2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Kohana_Exception extends Kohana_Kohana_Exception {
|
||||||
|
/**
|
||||||
|
* Logs an exception in the database. If that fails fall back to Kohana's Logging.
|
||||||
|
*
|
||||||
|
* @uses Kohana_Exception::text
|
||||||
|
* @param Exception $e
|
||||||
|
* @param int $level
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function log(Exception $e,$level=Log::EMERGENCY) {
|
||||||
|
if (! class_exists('Log_Error'))
|
||||||
|
return parent::log($e,$level);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$eo = ORM::factory('Log_Error');
|
||||||
|
$eo->message = Kohana_Exception::text($e);
|
||||||
|
$eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id;
|
||||||
|
|
||||||
|
if (Request::current()) {
|
||||||
|
$eo->module = (Request::current()->directory() ? Request::current()->directory().'_' : '').Request::current()->controller();
|
||||||
|
$eo->method = Request::current()->action();
|
||||||
|
}
|
||||||
|
|
||||||
|
$eo->save();
|
||||||
|
|
||||||
|
} catch (Exception $x) {
|
||||||
|
return parent::log($e,$level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect errors to the main page after showing a system message.
|
||||||
|
* The error should be logged in the DB.
|
||||||
|
*
|
||||||
|
* @param Exception $e
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public static function response(Exception $e) {
|
||||||
|
if (Kohana::$config->load('debug')->show_errors) {
|
||||||
|
return parent::response($e);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SystemMessage::add(array(
|
||||||
|
'title'=>'An Error Occured.',
|
||||||
|
'type'=>'error',
|
||||||
|
'body'=>'Dont panic, its been logged.',
|
||||||
|
));
|
||||||
|
|
||||||
|
// We'll redirect to the main page.
|
||||||
|
$response = Response::factory();
|
||||||
|
$response->status(302);
|
||||||
|
$response->headers('Location',URL::site());
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch (Exception $x) {
|
||||||
|
return parent::response($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
17
application/config/debug.php
Normal file
17
application/config/debug.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration - Debug Settings
|
||||||
|
*
|
||||||
|
* @package TSM Access Management
|
||||||
|
* @category Configuration
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010-2013 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
return array
|
||||||
|
(
|
||||||
|
'show_errors'=>FALSE, // Show any Exception Errors
|
||||||
|
);
|
||||||
|
?>
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<?php echo Form::input('email',$o->display('email'),array('label'=>'Email','divclass'=>'col-md-3','placeholder'=>'Email Address','type'=>'email','required','data-error'=>'Invalid EMAIL address')); ?>
|
<?php echo Form::input('email',$o->display('email'),array('label'=>'Email','divclass'=>'col-md-3','placeholder'=>'Email Address','type'=>'email','required','data-error'=>'Invalid EMAIL address')); ?>
|
||||||
|
|
||||||
<?php echo Form::input('company',$o->display('company'),array('label'=>'Company','divclass'=>'col-md-3','placeholder'=>'Company Name','required')); ?>
|
<?php echo Form::input('company',$o->display('company'),array('label'=>'Company','divclass'=>'col-md-6','placeholder'=>'Company Name','required')); ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label" for="Title">Name</label>
|
<label class="col-md-2 control-label" for="Title">Name</label>
|
||||||
@ -51,6 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php echo Form::hidden('language_id',Site::language()); ?>
|
<?php echo Form::hidden('language_id',Site::language()); ?>
|
||||||
|
<?php echo Form::hidden('active',TRUE); ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -14,6 +14,7 @@ class Controller_Admin_Ssl extends Controller_Ssl {
|
|||||||
|
|
||||||
protected $secure_actions = array(
|
protected $secure_actions = array(
|
||||||
'add'=>3,
|
'add'=>3,
|
||||||
|
'adduser'=>3,
|
||||||
'edit'=>3,
|
'edit'=>3,
|
||||||
'list'=>3,
|
'list'=>3,
|
||||||
'listchildca'=>3,
|
'listchildca'=>3,
|
||||||
@ -29,6 +30,28 @@ class Controller_Admin_Ssl extends Controller_Ssl {
|
|||||||
->body($this->add_edit());
|
->body($this->add_edit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function action_adduser() {
|
||||||
|
$so = ORM::factory('SSL');
|
||||||
|
|
||||||
|
if ($this->request->post()) {
|
||||||
|
$so->account_id = (string)Auth::instance()->get_user();
|
||||||
|
|
||||||
|
// Set our values, so that our filters have data
|
||||||
|
$so->values($this->request->post());
|
||||||
|
|
||||||
|
$this->save($so);
|
||||||
|
|
||||||
|
if ($so->saved())
|
||||||
|
HTTP::redirect(URL::link('user','ssl/view/'.$so->id));
|
||||||
|
}
|
||||||
|
|
||||||
|
Block::factory()
|
||||||
|
->type('form-horizontal')
|
||||||
|
->title('SSL Certificate')
|
||||||
|
->title_icon('fa-certificate')
|
||||||
|
->body(View::factory('ssl/admin/adduser')->set('o',$so)->set('mode','add'));
|
||||||
|
}
|
||||||
|
|
||||||
public function action_edit() {
|
public function action_edit() {
|
||||||
list($id,$output) = Table::page(__METHOD__);
|
list($id,$output) = Table::page(__METHOD__);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
class Model_SSL_CA extends Model_SSL {
|
class Model_SSL_CA extends Model_SSL {
|
||||||
// Relationships
|
// Relationships
|
||||||
protected $_belongs_to = array(
|
protected $_belongs_to = array(
|
||||||
|
'account'=>array(),
|
||||||
'parent'=>array('model'=>'ssl_ca','foreign_key'=>'ssl_ca_id'),
|
'parent'=>array('model'=>'ssl_ca','foreign_key'=>'ssl_ca_id'),
|
||||||
);
|
);
|
||||||
protected $_has_many = array(
|
protected $_has_many = array(
|
||||||
|
@ -329,7 +329,7 @@ abstract class lnApp_Model_SSL extends ORM {
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
$x = $this;
|
$x = $this;
|
||||||
while (! is_null($x->ssl_ca_id) AND $x->id != $x->ssl_ca_id AND $x=$x->ca)
|
while (! is_null($x->ssl_ca_id) AND (! $x instanceof Model_SSL_CA OR $x->id != $x->ssl_ca_id) AND $x=$x->ca)
|
||||||
array_push($result,$x);
|
array_push($result,$x);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
18
modules/ssl/views/ssl/admin/adduser.php
Normal file
18
modules/ssl/views/ssl/admin/adduser.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<div class="row">
|
||||||
|
<fieldset class="col-md-6">
|
||||||
|
<legend>CSR Data</legend>
|
||||||
|
<?php echo Form::textarea('csr',$o->csr,array('divclass'=>'col-md-12','placeholder'=>'Certificate Sign Request','style'=>'font-family: monospace; font-size: 95%;','rows'=>Form::textarea_rows($o->csr))); ?>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="col-md-6">
|
||||||
|
<legend>Certificate Data</legend>
|
||||||
|
<?php echo Form::textarea('cert',$o->cert,array('divclass'=>'col-md-12','placeholder'=>'Public Certificate','style'=>'font-family: monospace; font-size: 95%;','rows'=>Form::textarea_rows($o->cert))); ?>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-offset-1">
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
<button type="button" class="btn btn-default">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
Reference in New Issue
Block a user