More minor fixes
This commit is contained in:
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('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">
|
||||
<label class="col-md-2 control-label" for="Title">Name</label>
|
||||
@@ -51,6 +51,7 @@
|
||||
</div>
|
||||
|
||||
<?php echo Form::hidden('language_id',Site::language()); ?>
|
||||
<?php echo Form::hidden('active',TRUE); ?>
|
||||
</fieldset>
|
||||
|
||||
<div class="row">
|
||||
|
Reference in New Issue
Block a user