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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mgroupaccesscontroller extends CI_Model {
protected $_table='group_access_controller';
public function __construct(){
parent::__construct();
date_default_timezone_set("Asia/Ho_Chi_Minh");
}
public function add($dataInsert){
$this->db->insert($this->_table, $dataInsert);
}
public function addBatch($dataInsertBatch){
$this->db->insert_batch($this->_table, $dataInsertBatch);
}
public function delete($group_id, $access_controller_id){
$this->db->where('group_id', $group_id);
$this->db->where('access_controller_id', $access_controller_id);
$this->db->delete($this->_table);
}
public function getByGroupId($group_id){
$this->db->select('access_controller_id');
$this->db->from($this->_table);
$this->db->where('group_id', $group_id);
$query = $this->db->get();
$result = $query->result_array();
$list = array();
foreach($result as $value){
$list[] = $value['access_controller_id'];
}
return $list;
}
/**
* Lấy list controller được phân quyền cho Nhóm
* @return array
*/
public function getControllerNameAssigned(){
$this->load->model('madmin');
$admin_id = $this->session->userdata('id');
$adminInfo = $this->madmin->getById($admin_id);
$group_id = $adminInfo[0]['group_id'];
$this->db->select('ac.name');
$this->db->from($this->_table.' gac');
$this->db->join('access_controller ac', 'ac.id = gac.access_controller_id');
$this->db->join('group g', 'g.id = gac.group_id');
$this->db->where('gac.group_id', $group_id);
$this->db->where('g.name !=', 'dcv_super_admin');
$this->db->where('g.is_active', 1);
$this->db->where('ac.is_active', 1);
$query = $this->db->get();
$result = $query->result_array();
$list = array();
foreach($result as $value){
$list[] = $value['name'];
}
return $list;
}
public function getCountActionInControllerAssigned(){
$this->load->model('madmin');
$admin_id = $this->session->userdata('id');
$adminInfo = $this->madmin->getById($admin_id);
$group_id = $adminInfo[0]['group_id'];
$this->db->select('ac.name AS controller_name, COUNT(*) AS count_action');
$this->db->from($this->_table.' gac');
$this->db->join('group g', 'g.id = gac.group_id');
$this->db->join('access_controller ac', 'ac.id = gac.access_controller_id');
$this->db->join('access_action aa', 'aa.id = adaa.access_action_id');
$this->db->join('group_access_controller gac', 'gac.access_controller_id = ac.id');
$this->db->where('g.is_active', 1);
$this->db->where('ac.is_active', 1);
$this->db->where('aa.is_active', 1);
$this->db->where('adaa.admin_id', $admin_id);
$this->db->where('gac.group_id', $group_id);
$this->db->group_by(array('gac.access_controller_id'));
$query = $this->db->get();
return $query->result_array();
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */