-
-
Save purdy/c3a2dc832eadbd203458 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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