Create a gist now

Instantly share code, notes, and snippets.

@purdy /lead_approval.php Secret
Created Sep 12, 2013

<?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