57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||
|
|
||
|
/**
|
||
|
* This class provides the default template controller for rendering pages.
|
||
|
*
|
||
|
* @package lnApp
|
||
|
* @subpackage Page/Template
|
||
|
* @category Controllers
|
||
|
* @author Deon George
|
||
|
* @copyright (c) 2010 Deon George
|
||
|
* @license http://dev.leenooks.net/license.html
|
||
|
*/
|
||
|
class Controller_TemplateDefault extends Controller_lnApp_TemplateDefault {
|
||
|
/**
|
||
|
* Check and see if this controller needs authentication
|
||
|
*
|
||
|
* if $this->auth_required is TRUE, then the user must be logged in only.
|
||
|
* if $this->auth_required is FALSE, AND $this->secure_actions has an array of
|
||
|
* methods set to TRUE, then the user must be logged in AND a member of the
|
||
|
* role.
|
||
|
*
|
||
|
* @return boolean
|
||
|
*/
|
||
|
protected function _auth_required() {
|
||
|
// If our global configurable is disabled, then continue
|
||
|
if (! Kohana::Config('config.method_security'))
|
||
|
return FALSE;
|
||
|
|
||
|
return (($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE) ||
|
||
|
(is_array($this->secure_actions) && array_key_exists($this->request->action,$this->secure_actions) &&
|
||
|
Auth::instance()->logged_in($this->secure_actions[$this->request->action],get_class($this).'|'.__METHOD__) === FALSE));
|
||
|
}
|
||
|
|
||
|
protected function _left() {
|
||
|
if ($this->template->left)
|
||
|
return $this->template->left;
|
||
|
|
||
|
elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__))
|
||
|
return Controller_Tree::js();
|
||
|
}
|
||
|
|
||
|
protected function _right() {
|
||
|
if ($this->template->right)
|
||
|
return $this->template->right;
|
||
|
else
|
||
|
return $this->_cart();
|
||
|
}
|
||
|
|
||
|
private function _cart() {
|
||
|
if (! Cart::instance()->contents()->reset(FALSE)->count_all())
|
||
|
return '';
|
||
|
|
||
|
return Cart::instance()->cart_block();
|
||
|
}
|
||
|
}
|
||
|
?>
|