Some minor internal fixes
This commit is contained in:
parent
6d914ff290
commit
fc5cea470a
@ -98,7 +98,7 @@ abstract class lnApp_Auth_ORM extends Kohana_Auth_ORM {
|
|||||||
* @return boolean TRUE if authorised, FALSE if not.
|
* @return boolean TRUE if authorised, FALSE if not.
|
||||||
*/
|
*/
|
||||||
public function authorised(Model_Account $ao) {
|
public function authorised(Model_Account $ao) {
|
||||||
return (($uo = $this->get_user()) AND $uo->loaded() AND ($uo == $ao OR in_array($ao->id,$uo->RTM->customers($uo->RTM))));
|
return (($uo = $this->get_user()) AND $uo->loaded() AND ($uo == $ao OR ($uo->admin > $ao->admin)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_groups() {
|
public function get_groups() {
|
||||||
@ -158,6 +158,7 @@ abstract class lnApp_Auth_ORM extends Kohana_Auth_ORM {
|
|||||||
|
|
||||||
// If we are not a valid user object, then we are not logged in
|
// If we are not a valid user object, then we are not logged in
|
||||||
if (is_object($uo) AND ($uo instanceof Model_Account) AND $uo->loaded())
|
if (is_object($uo) AND ($uo instanceof Model_Account) AND $uo->loaded())
|
||||||
|
if (empty($role) OR ($role <= $uo->admin))
|
||||||
$status = TRUE;
|
$status = TRUE;
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
|
@ -68,8 +68,16 @@ abstract class lnApp_Controller_TemplateDefault extends Kohana_Controller_Templa
|
|||||||
* @uses meta
|
* @uses meta
|
||||||
*/
|
*/
|
||||||
public function before() {
|
public function before() {
|
||||||
|
if ($this->auth_required) {
|
||||||
|
if (! count($this->secure_actions) OR (! isset($this->secure_actions[Request::current()->action()])))
|
||||||
|
throw HTTP_Exception::factory(403,'Class has no security defined :class, or no security configured for :method',array(':class'=>get_class($this),':method'=>Request::current()->action()));
|
||||||
|
|
||||||
$this->ao = Auth::instance()->get_user();
|
$this->ao = Auth::instance()->get_user();
|
||||||
|
|
||||||
|
if (! is_null($this->ao) AND (is_string($this->ao)))
|
||||||
|
throw HTTP_Exception::factory(501,'Account doesnt exist :account ?',array(':account'=>(is_string($this->ao) OR is_null($this->ao)) ? $this->ao : Auth::instance()->get_user()->id));
|
||||||
|
}
|
||||||
|
|
||||||
// Actions that start with ajax, should only be ajax
|
// Actions that start with ajax, should only be ajax
|
||||||
if (! Kohana::$config->load('debug')->ajax AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax())
|
if (! Kohana::$config->load('debug')->ajax AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax())
|
||||||
throw HTTP_Exception::factory(412,_('Unable to fulfil request.'));
|
throw HTTP_Exception::factory(412,_('Unable to fulfil request.'));
|
||||||
@ -82,7 +90,7 @@ abstract class lnApp_Controller_TemplateDefault extends Kohana_Controller_Templa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->ao AND $this->ao->loaded() AND ! $this->ao->activated() AND ($this->request->controller() != 'Account' OR $this->request->action() != 'activate'))
|
if ($this->ao AND is_object($this->ao) AND $this->ao->loaded() AND ! $this->ao->activated() AND ($this->request->controller() != 'Account' OR $this->request->action() != 'activate'))
|
||||||
HTTP::redirect('login/activate');
|
HTTP::redirect('login/activate');
|
||||||
|
|
||||||
// Check user auth and role
|
// Check user auth and role
|
||||||
|
@ -22,6 +22,9 @@ abstract class lnApp_Form extends Kohana_Form {
|
|||||||
return '%s';
|
return '%s';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! isset($attributes['class']))
|
||||||
|
$attributes['class'] = 'form-control';
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
$output .= '<div class="form-group">';
|
$output .= '<div class="form-group">';
|
||||||
@ -43,9 +46,9 @@ abstract class lnApp_Form extends Kohana_Form {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$classdiv = FALSE;
|
$classdiv = FALSE;
|
||||||
if (isset($attributes['class'])) {
|
if (isset($attributes['divclass'])) {
|
||||||
$output .= sprintf('<div class="%s">',$attributes['class']);
|
$output .= sprintf('<div class="%s">',$attributes['divclass']);
|
||||||
unset($attributes['class']);
|
unset($attributes['divclass']);
|
||||||
$classdiv = TRUE;
|
$classdiv = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +87,7 @@ abstract class lnApp_Form extends Kohana_Form {
|
|||||||
* @usedby Form::image
|
* @usedby Form::image
|
||||||
*/
|
*/
|
||||||
public static function input($name,$value=NULL,array $attributes=NULL) {
|
public static function input($name,$value=NULL,array $attributes=NULL) {
|
||||||
return (isset($attributes['type']) AND $attributes['type'] == 'hidden') ? parent::input($name,$value,$attributes) : sprintf(self::_controlgroup($name,$attributes),parent::input($name,$value,Arr::merge($attributes,array('class'=>'form-control'))));
|
return (isset($attributes['type']) AND $attributes['type'] == 'hidden') ? parent::input($name,$value,$attributes) : sprintf(self::_controlgroup($name,$attributes),parent::input($name,$value,$attributes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function select($name,array $options=NULL,$selected=NULL,array $attributes=NULL) {
|
public static function select($name,array $options=NULL,$selected=NULL,array $attributes=NULL) {
|
||||||
|
@ -10,12 +10,13 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class lnApp_Menu {
|
class lnApp_Menu {
|
||||||
public static function items($type) {
|
public static function items($type,array $list=array()) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
if (empty(URL::$method_directory[$type]))
|
if (empty(URL::$method_directory[$type]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (! $list)
|
||||||
$list = Kohana::list_files('classes/Controller/'.ucfirst($type));
|
$list = Kohana::list_files('classes/Controller/'.ucfirst($type));
|
||||||
|
|
||||||
// This will be used a lot!
|
// This will be used a lot!
|
||||||
@ -23,7 +24,7 @@ class lnApp_Menu {
|
|||||||
|
|
||||||
foreach ($list as $name => $path)
|
foreach ($list as $name => $path)
|
||||||
if (is_array($path)) {
|
if (is_array($path)) {
|
||||||
$result += self::items($path);
|
$result += self::items($type,$path);
|
||||||
|
|
||||||
} elseif (substr($name, -$ext_length) === EXT) {
|
} elseif (substr($name, -$ext_length) === EXT) {
|
||||||
// Remove "classes/" and the extension
|
// Remove "classes/" and the extension
|
||||||
|
6
views/errors/400.php
Normal file
6
views/errors/400.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<h1>Oops!</h1>
|
||||||
|
<h2>400 Bad Request?</h2>
|
||||||
|
<?php echo $message; ?>
|
||||||
|
<div class="error-details">
|
||||||
|
Sorry, the request couldnt be actioned.
|
||||||
|
</div>
|
Reference in New Issue
Block a user