[eluser]Hank the Punk[/eluser]
Hello.
In the controller constructor i'm calling a function in the user model like this schema:
Code:
class Some_class extends CI_Controller
{
public function __construct()
{
parent::__construct();
// Stuff to load user model
$this->user->check_permission();
}
public function index()
{
// Do whatever...
}
}
Code:
function check_permission()
{
if (! $this->is_registered())
{
redirect('members/login', 'refresh');
die('Youre not logged'); // Case of error
}
if (! $this->has_access_to_controller())
{
redirect('error403', 'refresh');
die('Access denied');
}
}
Instead of using redirect methods, can I load some views and then bypass the execution of the current controller (for instance the index() method) and execute the _output method ?? Something like this:
Code:
function check_permission()
{
if (! $this->is_registered())
{
$this->load->view('login');
call_controller_output() // echoes whatever
exit(); // Bypass index() method in controller
}
if (! $this->has_access_to_controller())
{
$this->load->view('denied');
call_controller_output() // echoes whatever
exit(); // Bypass index() method in controller
}
}
Thanks !!!