Skip to content

Instantly share code, notes, and snippets.

@purdy
Created September 12, 2013 04:29
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 purdy/c3a2dc832eadbd203458 to your computer and use it in GitHub Desktop.
Save purdy/c3a2dc832eadbd203458 to your computer and use it in GitHub Desktop.
<?php
class Lead_approval extends CI_Controller {
protected $user = NULL;
function __construct() {
parent::__construct();
if ( $this->session->userdata( 'user_id' ) ) {
$this->load->model( 'user_model', 'users' );
$db_user = $this->users->user_load( $this->session->userdata( 'user_id' ) );
if ( $db_user['token_created'] + $db_user['expires_in'] < time() ) {
$this->session->sess_destroy();
redirect( 'login' );
}
else {
$this->user = $db_user;
}
}
if ( ! $this->user ) {
redirect( 'login' );
}
else if ( ! $this->user['is_admin'] ) {
redirect( 'login/not_approved');
}
$this->load->model( 'lead_model', 'leads' );
}
public function index() {
// ... this is where i give the admin user some fancy functionality to do their job
// the neat part is that I can pass in $this->user to my templates to show the current
// logged-in user and profile picture.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment