activate_helper.php
937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if(!function_exists('activate')) {
function activate($url) {
return uri_string() == $url;
}
}
if(!function_exists('api')) {
function api($url) {
$CI = &get_instance();
$url = $CI->config->item('apiBaseUrl') . $url;
$result = file_get_contents($url);
$json = json_decode($result);
$ret = $json->data;
return $ret;
}
}
if(!function_exists('hasRole')) {
function hasRole($roles = []) {
$CI = &get_instance();
$CI->load->helper('cookie');
$login_user = get_cookie('login_user');
if($login_user) {
$login_user = json_decode($login_user, true);
foreach($login_user['roleKeys'] as $v){
if(in_array($v, $roles)){
return true;
}
}
return false;
}
}
}