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:
<?php
class Module extends CI_Model
{
function __construct()
{
parent::__construct();
}
public function get_module_name($module_id)
{
$query = $this->db->get_where('modules', array('module_id' => $module_id), 1);
if($query->num_rows() == 1)
{
$row = $query->row();
return $this->lang->line($row->name_lang_key);
}
return $this->lang->line('error_unknown');
}
public function get_module_desc($module_id)
{
$query = $this->db->get_where('modules', array('module_id' => $module_id), 1);
if($query->num_rows() == 1)
{
$row = $query->row();
return $this->lang->line($row->desc_lang_key);
}
return $this->lang->line('error_unknown');
}
public function get_all_permissions()
{
$this->db->from();
return $this->db->get();
}
public function get_all_subpermissions()
{
$this->db->from('permissions');
$this->db->join('modules', 'modules.module_id = permissions.module_id');
$this->db->where($this->db->dbprefix('modules') . '.module_id!=', 'permission_id', FALSE);
return $this->db->get();
}
public function get_all_modules()
{
$this->db->from('modules');
$this->db->order_by('sort', 'asc');
return $this->db->get();
}
public function get_allowed_modules($person_id)
{
$this->db->from('modules');
$this->db->join('permissions', 'permissions.permission_id = modules.module_id');
$this->db->join('grants', 'permissions.permission_id = grants.permission_id');
$this->db->where('person_id', $person_id);
$this->db->order_by('sort', 'asc');
return $this->db->get();
}
}
?>