Welcome Guest, Not a member yet? Register   Sign In
Abort execution and call _output() method
#1

[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 !!!


Messages In This Thread
Abort execution and call _output() method - by El Forum - 10-01-2012, 08:04 AM
Abort execution and call _output() method - by El Forum - 10-01-2012, 03:13 PM
Abort execution and call _output() method - by El Forum - 10-01-2012, 03:49 PM
Abort execution and call _output() method - by El Forum - 10-01-2012, 03:58 PM
Abort execution and call _output() method - by El Forum - 10-01-2012, 04:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB