Privilnode_model.php 1.2 KB

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