initial commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Description of Autorisatie_model
|
||||
*
|
||||
* @author Theo Weijmer
|
||||
* @date april 26, 2013 2:21 PM
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class Autorisaties_model extends MY_Model{
|
||||
|
||||
protected $tablename = 'tb_autorisaties';
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array('Autorisatietypes_model');
|
||||
$this->load->model($models);
|
||||
}
|
||||
|
||||
|
||||
function check_autorisatie($role, $level){
|
||||
$this->sql = " SELECT {$role} & {$level} AS level";
|
||||
|
||||
$check = $this->get_query_row('level');
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
function get_autorisaties($level){
|
||||
$autotypes = $this->Autorisatietypes_model->get_records_where();
|
||||
|
||||
if(!$autotypes) return FALSE;
|
||||
|
||||
foreach($autotypes as $autotype){
|
||||
if($this->check_autorisatie($autotype->autorisatietype_level, $level)){
|
||||
$autorisaties[] = $autotype->autorisatietype_naam;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($autorisaties)) $autorisaties = FALSE;
|
||||
|
||||
return $autorisaties;
|
||||
}
|
||||
|
||||
function check_partituur_access($partituurid, $type){
|
||||
$read = TRUE;
|
||||
$write= TRUE;
|
||||
|
||||
if(!$this->admin){
|
||||
$partorgid = $this->Partituurs_model->get_record_by_id($partituurid, 'partituur_organisatie_id');
|
||||
if($this->globorgid!=$partorgid){
|
||||
$read = FALSE;
|
||||
$write= FALSE;
|
||||
}else{
|
||||
// aangepast van $this->role naar $this->userrole
|
||||
if(!$this->check_autorisatie(WRITE, $this->userrole)){
|
||||
$write = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($type==1){
|
||||
return $read;
|
||||
}else{
|
||||
return $write;
|
||||
}
|
||||
}
|
||||
|
||||
function get_autorisaties_per_gebruiker($min,$max){
|
||||
$this->sql = "SELECT id, autorisatietype_level as level, autorisatietype_naam as omschrijving
|
||||
FROM tb_autorisatietypes
|
||||
WHERE autorisatietype_level >= {$min}
|
||||
AND autorisatietype_level <= {$max} ";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user