Skip to content

Instantly share code, notes, and snippets.

@julionc
Created February 8, 2012 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julionc/1765618 to your computer and use it in GitHub Desktop.
Save julionc/1765618 to your computer and use it in GitHub Desktop.
[es] Ejemplo de MY_Controller.php usando ion_auth como librería de Auth
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends Admin_Controller {
public function index()
{
//$this->load->view('admin/_header', $data);
$this->load->view('admin/_header');
$this->load->view('admin/home');
$this->load->view('admin/_footer');
}
}
/* End of file home.php */
/* Location: ./application/controllers/home.php */
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_Controller extends CI_Controller {
protected $the_user;
public function __construct() {
parent::__construct();
if($this->ion_auth->is_admin()) {
$data->the_user = $this->ion_auth->user()->row();
$this->the_user = $data->the_user;
$this->load->vars($data);
}
else {
redirect('/');
}
}
}
class User_Controller extends CI_Controller {
protected $the_user;
public function __construct() {
parent::__construct();
if($this->ion_auth->is_group('user')) {
$data->the_user = $this->ion_auth->user()->row();
$this->the_user = $data->the_user;
$this->load->vars($data);
}
else {
redirect('/');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment