12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- if (!defined('BASEPATH'))exit('No direct script access allowed');
- include_once(FCPATH . 'application/models/Base_model.php');
- class Privilnode_model extends Base_model{
- protected $table = 'privilnode';
- public function __construct(){
- parent::__construct();
- }
- public function get_all_privilnode($role){
- $this->db->where('status', 1);
- $this->db->where('level >=', $role);
- $query = $this->db->get($this->table);
- return $query->result_array();
- }
- public function get_default_privilege($role){
- $this->db->select('id');
- $this->db->where('status', 1);
- $this->db->where('level >=', $role);
- if ($role == COMPANY_CUSTOMER) {
- $this->db->where('parentid', 1);
- }
- $query = $this->db->get($this->table);
- $result = $query->result_array();
- $privilegeid = array();
- foreach ($result as $key => $value) {
- $privilegeid[] = $value['id'];
- }
- return join(',', $privilegeid);
- }
- // 获取权限action
- public function get_privilege_action($ids){
- $sql = "select action from {$this->table} where id in ({$ids})";
- $res = $this->db->query($sql)->result_array();
- $data = array();
- foreach ($res as $v) {
- if (!empty($v['action'])) {
- $data[] = $v['action'];
- }
- }
- return empty($data) ? $data : explode(',', implode(',', $data));
- }
-
- }
|