initial commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class Functies extends MY_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$models = array("shared/Functies_model",
|
||||
"shared/Functies_modules_model",
|
||||
"monpas/Modules_model");
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
if (!$this->check_online_status()) {
|
||||
echo json_encode(array('offline' => TRUE));
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
|
||||
function getModules()
|
||||
{
|
||||
$modules = $this->Modules_model->getallmodules();
|
||||
if ($modules) {
|
||||
echo json_encode($modules);
|
||||
} else {
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
|
||||
function getFuncties()
|
||||
{
|
||||
$moduleid = $this->uri->segment(4);
|
||||
$functies = $this->Functies_model->getFuncties();
|
||||
$functiesmodule = $this->Functies_model->getFunctiesBijModule($moduleid);
|
||||
|
||||
if ($functies) {
|
||||
foreach ($functies as $functie) {
|
||||
$functie->doelgroep = 'F';
|
||||
if ($functiesmodule) {
|
||||
foreach ($functiesmodule as $gekoppeld) {
|
||||
if ($functie->functie_id == $gekoppeld->functie_id) {//vergelijkt de functie_ids van de functies met de functies die bij de module hooren
|
||||
$functie->doelgroep = 'T'; //indien hetzelfde: doelgroep = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($functies && sizeof($functies > 1)) {
|
||||
$test = (array)$functies;
|
||||
usort($test, array($this, 'opDoelgroep'));
|
||||
}
|
||||
echo json_encode($test);
|
||||
|
||||
} else {
|
||||
echo json_encode(false);
|
||||
}
|
||||
}
|
||||
|
||||
function newModuleFunctieKoppeling(){
|
||||
$moduleid = $this->clean_input("moduleid");
|
||||
$functieid = $this->clean_input("functieid");
|
||||
|
||||
if($moduleid && $functieid) {
|
||||
$data = array(
|
||||
'module_id' => $moduleid,
|
||||
'functie_id' => $functieid
|
||||
);
|
||||
|
||||
$this->Functies_modules_model->save_record($data, false);
|
||||
echo json_encode('ok');
|
||||
}
|
||||
else{
|
||||
echo json_encode(false);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteModuleFunctieKoppeling(){
|
||||
$moduleid = $this->clean_input("moduleid");
|
||||
$functieid = $this->clean_input("functieid");
|
||||
|
||||
if($moduleid && $functieid) {
|
||||
$where = array(
|
||||
'module_id' => $moduleid,
|
||||
'functie_id' => $functieid
|
||||
);
|
||||
$this->Functies_modules_model->delete_record_where($where);
|
||||
echo json_encode('ok');
|
||||
}
|
||||
else{
|
||||
echo json_encode(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function opDoelgroep($a, $b)
|
||||
{
|
||||
return strcmp($b->doelgroep, $a->doelgroep);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user