| 1 |
<?php |
| 2 |
class Backend_controller extends MY_Controller |
| 3 |
{ |
| 4 |
function __construct( $user_level = 0, $default_path = '' ) |
| 5 |
{ |
| 6 |
parent::__construct(); |
| 7 |
|
| 8 |
$this->load->library('migration'); |
| 9 |
if ( ! $this->migration->current()){ |
| 10 |
// show_error($this->migration->error_string()); |
| 11 |
return false; |
| 12 |
} |
| 13 |
$this->load->library( 'conf/app_conf' ); |
| 14 |
$this->load->library( 'hc_time' ); |
| 15 |
$this->load->library( 'hc_form' ); |
| 16 |
|
| 17 |
$app = $this->config->item('nts_app'); |
| 18 |
|
| 19 |
if( isset($GLOBALS['NTS_CONFIG'][$app]['FORCE_LOGIN_ID']) ) |
| 20 |
{ |
| 21 |
$id = $GLOBALS['NTS_CONFIG'][$app]['FORCE_LOGIN_ID']; |
| 22 |
$this->auth->login( $id ); |
| 23 |
} |
| 24 |
|
| 25 |
if ( ! $this->auth->check() ) |
| 26 |
{ |
| 27 |
ci_redirect('auth/login'); |
| 28 |
exit; |
| 29 |
} |
| 30 |
|
| 31 |
/* check user active */ |
| 32 |
$user_active = 0; |
| 33 |
if( $test_user = $this->auth->user() ) |
| 34 |
{ |
| 35 |
$user_active = $test_user->active; |
| 36 |
} |
| 37 |
|
| 38 |
if( ! $user_active ) |
| 39 |
{ |
| 40 |
$to = 'auth/notallowed'; |
| 41 |
ci_redirect( $to ); |
| 42 |
exit; |
| 43 |
} |
| 44 |
|
| 45 |
/* check user level */ |
| 46 |
if( $user_level ) |
| 47 |
{ |
| 48 |
$this->check_level( $user_level ); |
| 49 |
if( $default_path ) |
| 50 |
$this->conf['path'] = $default_path; |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|