initial commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/** Autorisaties_model januari 2015 */
|
||||
|
||||
class Autorisaties_model extends MY_Model{
|
||||
|
||||
|
||||
protected $tablename = 'tb_autorisaties';
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array('ijkpartituur/Partituurs_model');
|
||||
$this->load->model($models);
|
||||
}
|
||||
|
||||
function check_autorisatie($role, $level){
|
||||
$this->sql = "SELECT (".$role." & ".$level.") AS checker";
|
||||
$query = $this->db->query($this->sql);
|
||||
$row = $query->row();
|
||||
return $row->checker;
|
||||
}
|
||||
function check_write(){
|
||||
if($this->super) return TRUE;
|
||||
if($this->orgid==$this->globorgid && $this->check_autorisatie($this->userrole, WRITER)) return TRUE;
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_partituur_access($partituurid, $type){
|
||||
$read = TRUE;
|
||||
$write= TRUE;
|
||||
|
||||
if(!$this->super){
|
||||
$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(WRITER, $this->userrole)){
|
||||
$write = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($type==1){
|
||||
return $read;
|
||||
}else{
|
||||
return $write;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user