79 lines
1.9 KiB
PHP
79 lines
1.9 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Accesslevel class
|
|
*/
|
|
|
|
/**
|
|
* 권한이 있는지 없는지 판단하는 class 입니다.
|
|
*/
|
|
class Accesslevel extends CI_Controller
|
|
{
|
|
|
|
private $CI;
|
|
|
|
function __construct()
|
|
{
|
|
$this->CI = & get_instance();
|
|
}
|
|
|
|
|
|
/**
|
|
* 접근권한이 있는지를 판단합니다
|
|
*/
|
|
public function is_accessable($access_type = '', $group = '', $check = array())
|
|
{
|
|
$access_type = (string) $access_type;
|
|
if (empty($access_type)) { // 모든 사용자
|
|
return true;
|
|
} elseif ($access_type === '1') { // 로그인 사용자
|
|
if ($this->CI->userlib->is_user() === false) {
|
|
return false;
|
|
}
|
|
return true;
|
|
} elseif ($access_type === '100') { // 관리자
|
|
if ($this->CI->userlib->is_admin($check) === false) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 접근권한이 없으면 alert 를 띄웁니다
|
|
*/
|
|
public function check($access_type = '', $group = '', $alertmessage = '', $check = array())
|
|
{
|
|
if (empty($alertmessage)) {
|
|
$alertmessage = '접근 권한이 없습니다';
|
|
}
|
|
$accessable = $this->is_accessable($access_type, $group, $check);
|
|
|
|
if ($accessable) {
|
|
return true;
|
|
} else {
|
|
alert($alertmessage);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
public function check_admin($type = '', $msg = '')
|
|
{
|
|
if (empty($msg)) {
|
|
$msg = '접근 권한이 없습니다';
|
|
}
|
|
if ($this->CI->userlib->is_admin() == 'super') {
|
|
return;
|
|
}
|
|
if ( ! $this->CI->userlib->is_admin()) {
|
|
alert($msg);
|
|
exit;
|
|
}
|
|
alert($msg);
|
|
exit;
|
|
}
|
|
}
|