Privilnode_model.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Privilnode_model extends CI_Model{
  3. private $table = 'privilnode';
  4. public function __construct(){
  5. parent::__construct();
  6. }
  7. public function get_all_privilnode($role){
  8. $this->db->where('status', 1);
  9. $this->db->where('level >=', $role);
  10. $query = $this->db->get($this->table);
  11. return $query->result_array();
  12. }
  13. public function get_default_privilege($role){
  14. $this->db->select('id');
  15. $this->db->where('status', 1);
  16. $this->db->where('level >=', $role);
  17. if ($role == COMPANY_CUSTOMER) {
  18. $this->db->where('parentid', 1);
  19. }
  20. $query = $this->db->get($this->table);
  21. $result = $query->result_array();
  22. $privilegeid = array();
  23. foreach ($result as $key => $value) {
  24. $privilegeid[] = $value['id'];
  25. }
  26. return join(',', $privilegeid);
  27. }
  28. // 获取权限action
  29. public function get_privilege_action($ids){
  30. $sql = "select action from {$this->table} where id in ({$ids})";
  31. $res = $this->db->query($sql)->result_array();
  32. $data = array();
  33. foreach ($res as $v) {
  34. if (!empty($v['action'])) {
  35. $data[] = $v['action'];
  36. }
  37. }
  38. return empty($data) ? $data : explode(',', implode(',', $data));
  39. }
  40. }