initial commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
class Autorisatienivos extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array( "shared/Orgusers_model",
|
||||
"shared/Autorisaties_model",
|
||||
"shared/Autorisatienivos_model",
|
||||
"shared/Organisaties_model");
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
if ( ! $this->check_online_status() ) {
|
||||
echo json_encode( array('offline' => TRUE) );
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
|
||||
public function getautorisaties(){
|
||||
$userid = $this->userid;
|
||||
$orgid = $this->globorgid;
|
||||
if (! $this->super || $this->userrole == 2){
|
||||
$where= array("user_id"=> $userid, "organisatie_id"=>$orgid);
|
||||
$orguserid = $this->Orgusers_model->get_fieldvalue($where, 'id');
|
||||
$where=array("orguser_id" => $orguserid);
|
||||
$userautid = $this->Autorisaties_model->get_fieldvalue($where,'nivo_id');
|
||||
$where=array("id"=>$userautid);
|
||||
$userhierarchie = $this->Autorisatienivos_model->get_fieldvalue($where, "hierarchie");
|
||||
}
|
||||
else {
|
||||
$userhierarchie = 1000;
|
||||
}
|
||||
$autnivos = $this->Autorisatienivos_model->getnivos($userhierarchie);
|
||||
echo json_encode($autnivos);
|
||||
}
|
||||
public function getautorisatie(){
|
||||
$autonivo = $this->Autorisatienivos_model->getusernivo($this->userid);
|
||||
echo json_encode($autonivo);
|
||||
}
|
||||
public function getwriteautorisatie(){
|
||||
// write autorisatie wordt alleen gegeven als
|
||||
// org is eigen organisatie en rechten = management
|
||||
$orgid = $this->uri->segment(4);
|
||||
if (!$orgid) {$orgid = $this->globorgid;};
|
||||
|
||||
$writeOK = false;
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, 343 ) >0){
|
||||
$writeOK = true;};
|
||||
// check of user lid is van orgid
|
||||
$userorg = $this->Orgusers_model->get_records_where(array('user_id' => $this->userid, 'organisatie_id' => $orgid),true);
|
||||
if (!$userorg) {$writeOK = false ;};
|
||||
// $userorg = $this->Organisaties_model->getuserorg($this->userid);
|
||||
// if ($userorg->id != $orgid) {$writeOK = false;}
|
||||
// super en helpdesk altijd schrijfrecht
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, 3) == 1){
|
||||
$writeOK = true;
|
||||
|
||||
}
|
||||
echo json_encode($writeOK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Filefolders extends MY_Controller {
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$models = array( "shared/Filefolders_model",
|
||||
"shared/Files_model",
|
||||
"monpas/Orgversies_model",
|
||||
"monpas/Modules_model",
|
||||
"monpas/Teksten_model",
|
||||
"Phantom_model");
|
||||
$this->load->model($models);
|
||||
|
||||
$this->load->helper('string');
|
||||
if (!$this->check_online_status() || ! $this->userid) {
|
||||
echo json_encode(array('offline' => TRUE));
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
|
||||
function getfolders(){
|
||||
$modulenr = $this->uri->segment(4);
|
||||
if (! $modulenr || $modulenr <=0) {
|
||||
echo $this->json(false);
|
||||
return;
|
||||
}
|
||||
|
||||
$orgID = $this->globorgid;
|
||||
$folders = $this->Filefolders_model->get_folders($modulenr, $orgID);
|
||||
if ($folders){
|
||||
foreach($folders as $folder){
|
||||
$folder->subfolders = $this->Filefolders_model->get_subfolders($folder);
|
||||
$folder->files= $this->Files_model->get_files($folder->id);
|
||||
}
|
||||
}// if folders
|
||||
$this->json($folders);
|
||||
}
|
||||
|
||||
public function maakStandaardFolders(){
|
||||
//CHECK MANAGER RIGHT
|
||||
if (! $this->isManager() ) return;
|
||||
|
||||
$modulenr = $this->clean_input('modulenr');
|
||||
$orgID = $this->globorgid;
|
||||
$folders = false;
|
||||
|
||||
$org = $this->Organisaties_model->get(['id'=>$orgID], false,true);
|
||||
if ($org->id != $org->valtonder_id) $targetOrgID = $this->Organisaties_model->getkamer($org->id);
|
||||
else $targetOrgID = $org->id;
|
||||
|
||||
$cats = $this->Orgversies_model->getversiecats($targetOrgID,$modulenr);
|
||||
if (! $cats) {
|
||||
$org = $this->Organisaties_model->get(['id'=> $targetOrgID],false, true);
|
||||
$cats = $this->Orgversies_model->getversiecats($org->valtonder_id, $modulenr);
|
||||
}
|
||||
if ($cats){
|
||||
foreach($cats as $cat){
|
||||
$folder =
|
||||
$this->Filefolders_model->get_folder_by_cat($orgID, $cat->nummer, $cat->omschrijving, $modulenr);
|
||||
if (! $folder){
|
||||
$data=[ 'modulenr' =>$modulenr,
|
||||
'organisatie_id' => $orgID,
|
||||
'naam' => $cat->omschrijving,
|
||||
'instrumentcat' =>$cat->nummer];
|
||||
$newID = $this->Filefolders_model->insert_record($data);
|
||||
$this->Filefolders_model->update_record( array('valtonder'=>$newID) , $newID);
|
||||
$folders[] = $this->Filefolders_model->get_folder($newID);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->json($folders);
|
||||
}
|
||||
|
||||
public function maakTopFolder(){
|
||||
//CHECK MANAGER RIGHT
|
||||
if (! $this->isManager() ) return;
|
||||
$nummer = $this->clean_input('nummer');
|
||||
$naam = stripslashes($this->clean_input('naam'));
|
||||
$modulenr = $this->clean_input('modulenr');
|
||||
|
||||
|
||||
$data = ['modulenr' => $modulenr,
|
||||
'organisatie_id' => $this->globorgid,
|
||||
'nummer' => $nummer,
|
||||
'naam' => $naam];
|
||||
|
||||
$newID = $this->Filefolders_model->insert_record($data);
|
||||
$this->Filefolders_model->update_record( array('valtonder'=>$newID), $newID);
|
||||
$folder = $this->Filefolders_model->get_folder($newID);
|
||||
$this->json($folder);
|
||||
}
|
||||
|
||||
public function maakSubFolder(){
|
||||
//CHECK MANAGER RIGHT
|
||||
if (! $this->isManager() ) return;
|
||||
|
||||
$nummer = $this->clean_input('nummer');
|
||||
$naam = stripslashes($this->clean_input('naam'));
|
||||
$modulenr = $this->clean_input('modulenr');
|
||||
$folderID = $this->clean_input('folderID');
|
||||
|
||||
$data=[ 'modulenr' =>$modulenr,
|
||||
'organisatie_id' => $this->globorgid,
|
||||
'nummer' => $nummer,
|
||||
'naam' => $naam,
|
||||
'valtonder' => $folderID];
|
||||
$newID = $this->Filefolders_model->insert_record($data);
|
||||
$folder = $this->Filefolders_model->get_folder($newID);
|
||||
$this->json($folder);
|
||||
}
|
||||
|
||||
public function editFolder(){
|
||||
//CHECK MANAGER RIGHT
|
||||
if (! $this->isManager() ) return;
|
||||
|
||||
$id = $this->clean_input("folderID");
|
||||
$naam = $this->input->post("naam");
|
||||
$nummer = $this->input->post("nummer");
|
||||
$this->Filefolders_model->update_record(['nummer'=> $nummer,'naam'=>$naam], $id);
|
||||
$folder = $this->Filefolders_model->get_folder($id);
|
||||
$this->json($folder->id);
|
||||
|
||||
}
|
||||
|
||||
public function getafwijkendetekst(){
|
||||
$modulenr = $this->clean_input('modulenr');
|
||||
$paginanaam = $this->clean_input('paginanaam');
|
||||
$afwijkend = $this->Teksten_model->gettekst($modulenr, $paginanaam);
|
||||
|
||||
echo json_encode($afwijkend);
|
||||
}
|
||||
|
||||
public function deleteFolder(){
|
||||
//CHECK MANAGER RIGHT
|
||||
if (! $this->isManager() ) return;
|
||||
|
||||
$folderID = $this->uri->segment(4);
|
||||
//TODO check of er geen files of subfolders zijn
|
||||
if ($this->Files_model->get(['folder_id'=>$folderID],false,false) ) return;
|
||||
|
||||
|
||||
$this->Filefolders_model->delete_record($folderID);
|
||||
}
|
||||
|
||||
public function deleteFile(){
|
||||
//check op eigenar
|
||||
$fileID = $this->uri->segment(4);
|
||||
if (! $this->magDelete($fileID) ) return;
|
||||
$bestand = $this->Files_model->get(['id'=>$fileID], false, true);
|
||||
$this->load->helper('file');
|
||||
unlink('../dossier/'.$bestand->new_name);
|
||||
unlink('../pdfdossier/'.$bestand->new_name);
|
||||
$this->Files_model->delete_record($fileID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function saveFileNaam(){
|
||||
//CHECK MANAGER RIGHT
|
||||
if (! $this->isManager() ) return;
|
||||
|
||||
$id = $this->clean_input("id");
|
||||
$naam = $this->input->post("naam");
|
||||
$this->Files_model->update_record(['original_name'=>$naam], $id);
|
||||
}
|
||||
|
||||
public function getFiles(){
|
||||
//TODO check toegang
|
||||
$folderID = $this->clean_input("folderID");
|
||||
$files = $this->Files_model->get_files($folderID);
|
||||
$this->json($files);
|
||||
}
|
||||
public function zoekFile(){
|
||||
$modulenr = $this->clean_input("modulenr");
|
||||
$zoekterm = strip_slashes($this->clean_input("zoekfile"));
|
||||
$files= $this->Files_model->zoek_files($zoekterm, $this->globorgid);
|
||||
$this->json($files);
|
||||
}
|
||||
|
||||
public function getAuth(){
|
||||
$aut = $this->Autorisaties_model->check_autorisatie($this->userrole, 343);
|
||||
$this->json($aut);
|
||||
}
|
||||
|
||||
private function isManager(){
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, 343) == 0 ) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
private function magDelete($fileid){
|
||||
$owner = $this->Files_model->get(['id'=>$fileid],owner,true);
|
||||
if ($owner == $this->userid) return true;
|
||||
else return false;
|
||||
}
|
||||
public function maakpdf(){
|
||||
//TODO check toegang
|
||||
$module = $this->uri->segment(4);
|
||||
$modulenaam = $this->Modules_model->get(['sysnr'=>$module], 'naam',true);
|
||||
$organisatie = $this->Organisaties_model->getOrganisatie($this->globorgid);
|
||||
$folders = $this->Filefolders_model->get_folders($module, $this->globorgid);
|
||||
if ($folders){
|
||||
foreach($folders as $folder){
|
||||
$folder->subfolders = $this->Filefolders_model->get_subfolders($folder);
|
||||
$folder->files = $this->Files_model->get_files($folder->id);
|
||||
}
|
||||
}
|
||||
$lijst = ['folders' => $folders,
|
||||
'organisatie' => $organisatie,
|
||||
'today' => date('d-m-Y'),
|
||||
'modulenaam' => $modulenaam,
|
||||
'baseURL' =>base_url()];
|
||||
$html = $this->load->view( 'monpas/reports/filefolders', $lijst, true);
|
||||
$this->Phantom_model->create_pdf( $html, 'filefolders', FALSE, FALSE, [] );
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class Menu extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array("shared/Users_model",
|
||||
'shared/Organisaties_model',
|
||||
"monpas/Menus_model",
|
||||
"monpas/Modules_model",
|
||||
"monpas/Documenten_model",
|
||||
"shared/Licenties_model",
|
||||
"ijkpartituur/pages_model");
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
if ( ! $this->check_online_status() ) {
|
||||
echo json_encode( array('offline' => TRUE) );
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
|
||||
public function get_menu(){
|
||||
|
||||
$menu = new stdClass;
|
||||
$user = new stdClass;
|
||||
$organisatie = new stdClass;
|
||||
$module = $this->session->userdata['module'];
|
||||
$modulenaam = '';
|
||||
if ($module >=0){
|
||||
|
||||
if (0 == $module) {$modulenaam = "Instrumenten";}
|
||||
else {$modulenaam= $this->Modules_model->get_fieldvalue(array("sysnr" => $module), 'naamkort'); }
|
||||
|
||||
|
||||
$menu = $this->Menus_model->getmenu($module,$this->userrole);
|
||||
foreach($menu as $menuitem){
|
||||
if($menuitem->holdernaam == "sophoofd"){
|
||||
$menuitem->subpaginas = $this->Menus_model->getsubmenus($menuitem->id, $this->userrole);
|
||||
}
|
||||
}
|
||||
|
||||
$licenties = null;
|
||||
$licenties = $this->Licenties_model->get_licentie($this->orgid);
|
||||
// als licenties voor 1 module, disable de portal knop
|
||||
if ($licenties && $menu && (count($licenties) <= 1)) {
|
||||
$i = 0;
|
||||
$target = -1;
|
||||
foreach($menu as $item){
|
||||
if ($item->naam == "stop") $target = $i;
|
||||
$i ++;
|
||||
}
|
||||
if ($target > -1) unset($menu[$target]);
|
||||
}
|
||||
|
||||
$user = $this->Users_model->get_fullname($this->userid);
|
||||
$organisatie = $this->Organisaties_model->get_orgnaam($this->globorgid);
|
||||
}
|
||||
|
||||
$org = $this->Organisaties_model->get_record_by_id($this->globorgid);
|
||||
if ($org){
|
||||
foreach ($menu as $menuitem){
|
||||
if (strtoupper($menuitem->naam) == "sophoofd"){
|
||||
switch ($org->soort){
|
||||
case 1: $menuitem->naam = "SWOP"; break;
|
||||
case 2: $menuitem->naam = "KOP" ; break;
|
||||
case 3: $menuitem->naam ="BOP"; break;
|
||||
default: $menuitem->naam = "SOP";
|
||||
};//switch
|
||||
}; //if
|
||||
}; // foreach
|
||||
}; //if organisatie
|
||||
|
||||
echo json_encode(array( 'module' =>$module,
|
||||
'modulenaam' => $modulenaam,
|
||||
'menu' =>$menu,
|
||||
'user' => $user,
|
||||
'organisatie' => $organisatie));
|
||||
}
|
||||
function gethandleidingen(){
|
||||
$handleidingen = $this->Documenten_model->gethandleidingen($this->globorgid, $this->userrole);
|
||||
echo json_encode($handleidingen);
|
||||
}
|
||||
function downloadhandleiding(){
|
||||
if( ! $this->userid ) return;
|
||||
$handleidingid = $this->uri->segment(4);
|
||||
$handleiding = $this->Documenten_model->get_record_by_id($handleidingid);
|
||||
|
||||
$this->load->helper('download');
|
||||
// $data = file_get_contents($this->rootpath ."/documents/".$handleiding->documentnaam);
|
||||
$data = file_get_contents("/home/mps/prod/documents/".$handleiding->documentnaam);//TW: rootpath is verkeerd door symlink
|
||||
force_download($handleiding->documentnaam, $data);
|
||||
}
|
||||
function getsubmenu(){
|
||||
//TODO clean input
|
||||
$pageid = $this->uri->segment(4);
|
||||
$submenus = $this->Menus_model->getsubmenus($pageid, $this->userrole);
|
||||
echo json_encode($submenus);
|
||||
}
|
||||
function getmodule(){
|
||||
echo json_encode($this->module);
|
||||
}
|
||||
|
||||
// function scriptSetModules(){
|
||||
// $organisaties = $this->Organisaties_model->getall();
|
||||
// foreach($organisaties as $organisatie){
|
||||
// if ($organisatie->monbas == 1){
|
||||
// $data=array('orgid' =>$organisatie->id, 'modulenr'=>1);
|
||||
// $this->Licenties_model->insert_record($data);
|
||||
// }
|
||||
// if ($organisatie->mondiv == 1){
|
||||
// $data=array('orgid' =>$organisatie->id, 'modulenr'=>2);
|
||||
// $this->Licenties_model->insert_record($data);
|
||||
// }
|
||||
// }; // foreach
|
||||
// echo 'klaar';
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,485 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Organisaties extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
if ($this->nologin) return;
|
||||
$models = array("monpas/Modules_model",
|
||||
'shared/Organisaties_model',
|
||||
'shared/Orgusers_model',
|
||||
"shared/Users_model",
|
||||
"monpas/Versies_model",
|
||||
"monpas/Orgversies_model",
|
||||
"monpas/Filledversions_model",
|
||||
"monpas/Scores_model",
|
||||
"monpas/Ambities_model",
|
||||
"shared/Licenties_model");
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
if ( ! $this->check_online_status() ) {
|
||||
echo json_encode( array('offline' => TRUE) );
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
|
||||
function getorgsperlevel(){
|
||||
$soort = $this->uri->segment(4);
|
||||
$toporgid = $this->input->post("toporgid");
|
||||
$orgs = $this->Organisaties_model->getorgsdetails($soort,$toporgid);
|
||||
echo json_encode($orgs);
|
||||
}
|
||||
|
||||
function getallowedorgs(){
|
||||
$orgs =null;
|
||||
if ($this->super || $this->userrole == 2){
|
||||
$orgs = $this->Organisaties_model->getallorgs();
|
||||
}
|
||||
else {
|
||||
$orgs = $this->Organisaties_model->getuserorgs($this->userid);
|
||||
if (count($orgs) == 1) $orgs = null; // als er maar 1 organisatie is , kan de gebruiker niet switchen
|
||||
}
|
||||
echo json_encode($orgs);
|
||||
}
|
||||
function setgloborg(){
|
||||
//TODO sanitize input
|
||||
$newOrgid = $this->uri->segment(4);
|
||||
$userrole = $this->Orgusers_model->getuserrole($this->userid, $newOrgid);
|
||||
|
||||
if ($this->super || $this->userrole ==2){
|
||||
$this->Session_model->set_globorgid($newOrgid);
|
||||
$module = $this->session->userdata('module');
|
||||
$allowed = $this->Licenties_model->get_records_where(array("orgid"=> $newOrgid, "modulenr"=>$module));
|
||||
if(!$allowed){
|
||||
$this->Session_model->set_module(0);
|
||||
};
|
||||
}
|
||||
// set nu ook de rol van de user in de geselecteerde organisatie;
|
||||
else {
|
||||
if ($userrole) {
|
||||
$this->Session_model->set_orgid($newOrgid);
|
||||
$this->Session_model->set_globorgid($newOrgid);
|
||||
$this->Session_model->set_role($userrole->nivo);
|
||||
}
|
||||
}
|
||||
echo json_encode(array("basepath"=>base_url()));
|
||||
}
|
||||
function insertorganisatie(){
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, SUPERUSER) > 0) {
|
||||
$errortekst = '';
|
||||
$neworg = null;
|
||||
$nummer = $this->input->post("nummer");
|
||||
if ($this->Organisaties_model->check_for_record(array("brin"=>$nummer))) {
|
||||
$errortekst= "Nummer bestaat al.";
|
||||
}
|
||||
else {
|
||||
$data=array( "soort" =>$this->input->post("soort"),
|
||||
"brin" =>$this->input->post("nummer"),
|
||||
"naamkort" =>$this->input->post("naamkort"),
|
||||
"naam" =>$this->input->post("naam"),
|
||||
"plaats" =>$this->input->post("plaats"),
|
||||
"valtonder_id" =>$this->input->post("valtonder"),
|
||||
"actief" =>1,
|
||||
);
|
||||
$newid = $this->Organisaties_model->insert_record($data);
|
||||
$licenties = $this->input->post('licenties');
|
||||
if ($licenties){
|
||||
foreach($licenties as $licentie){
|
||||
$this->Licenties_model->insert_record(array("orgid"=>$newid, "modulenr"=>$licentie));
|
||||
}
|
||||
}; //if
|
||||
if ($this->input->post("soort") == 1){
|
||||
$this->Organisaties_model->update_record(array("valtonder_id"=>$newid), $newid);
|
||||
}
|
||||
$neworg = $this->Organisaties_model->getorgdetails($newid);
|
||||
};
|
||||
}
|
||||
else { $errortekst = "u bent niet geautoriseerd tot deze handeling" ;
|
||||
$neworg = false;}; // als geen superuser
|
||||
echo json_encode(array("errortekst" => $errortekst, "org" =>$neworg));
|
||||
}
|
||||
|
||||
function deleteorg(){
|
||||
//TODO clean input
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, SUPERUSER) > 0) {
|
||||
$orgid = $this->uri->segment(4);
|
||||
$errortekst = '';
|
||||
|
||||
if ($this->Orgusers_model->check_for_record(array("organisatie_id" =>$orgid)) ){
|
||||
$errortekst = "Er zijn gebruikers gekoppeld aan deze organisatie.</br>";
|
||||
}
|
||||
if ($this->Organisaties_model->hasdependent($orgid) ) {
|
||||
$errortekst .= " Er zijn afhankelijke organisaties. </br>" ;
|
||||
}
|
||||
//ambities, filled versions, orgversies,scores, licenties
|
||||
if ($errortekst == ''){
|
||||
$filledversions = $this->Filledversions_model->get_records_where(array("organisatie_id" =>$orgid));
|
||||
if ($filledversions){
|
||||
foreach($filledversions as $fv){
|
||||
$this->Scores_model->delete_record_where(array("filledversion_id"=>$fv->id));
|
||||
$this->Filledversions_model->delete_record($fv->id);
|
||||
}
|
||||
}
|
||||
$this->Ambities_model->delete_record_where(array("organisatie_id"=>$orgid));
|
||||
$this->Orgversies_model->delete_record_where(array("organisatie_id" =>$orgid));
|
||||
$this->Licenties_model->delete_record_where(array("orgid" =>$orgid));
|
||||
$this->Organisaties_model->delete_record($orgid);
|
||||
}
|
||||
}
|
||||
else {$errortekst = "U bent niet geautoriseerd voor deze handeling.";};
|
||||
echo json_encode($errortekst);
|
||||
}
|
||||
function update(){
|
||||
//TODO clean input
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, SUPERUSER) > 0) {
|
||||
$orgid =$this->input->post("id");
|
||||
$errortekst = '';
|
||||
$nummer = $this->input->post("nummer");
|
||||
if ($this->Organisaties_model->check_for_record(array("brin"=>$nummer,
|
||||
"id <> " =>$orgid))) {
|
||||
$errortekst= "Nummer bestaat al.";
|
||||
}
|
||||
else {
|
||||
$actief = 1;
|
||||
if ($this->input->post("actief")=="false") $actief = 0;
|
||||
// $monbas=1;
|
||||
// if ($this->input->post("monbas")=="false") $monbas = 0;
|
||||
// $mondiv = 1;
|
||||
// if ($this->input->post("mondiv")=="false") $mondiv = 0;
|
||||
|
||||
$data=array( "brin" =>$this->input->post("nummer"),
|
||||
"naamkort" =>$this->input->post("naamkort"),
|
||||
"naam" =>$this->input->post("naam"),
|
||||
"plaats" =>$this->input->post("plaats"),
|
||||
"actief" =>$actief,
|
||||
// "monbas" =>$monbas,
|
||||
// "mondiv" =>$mondiv
|
||||
);
|
||||
$this->Organisaties_model->update_record($data,$orgid);
|
||||
$this->Licenties_model->delete_record_where(array("orgid"=>$orgid));
|
||||
$licenties = $this->input->post("licenties");
|
||||
if ($licenties){
|
||||
foreach ($licenties as $licentie){
|
||||
$this->Licenties_model->insert_record(array("orgid"=>$orgid, "modulenr"=>$licentie));
|
||||
}; // foreach
|
||||
}; // if licenties
|
||||
|
||||
}
|
||||
}
|
||||
else {$errortekst = " U bent niet geautoriseerd voor deze handeling.";};
|
||||
echo json_encode($errortekst);
|
||||
}
|
||||
function zoek(){
|
||||
//TODO clean input
|
||||
$errortekst="";
|
||||
$zoekstr = $this->input->post("zoekstring");
|
||||
$results = $this->Organisaties_model->zoekorgs($zoekstr);
|
||||
if (!$results){$errortekst = "Geen resultaten gevonden";};
|
||||
if (count($results) > 150) {
|
||||
$errortekst ="Teveel overeenkomende gegevens gevonden. Maak uw zoekcriteria specifieker.";
|
||||
$results = '';}
|
||||
echo json_encode(array("results"=>$results, "errortekst" =>$errortekst));
|
||||
}
|
||||
function getselected(){
|
||||
//TODO clean input
|
||||
$orgid = $this->uri->segment(4);
|
||||
$swvid = null;
|
||||
$kamerid = null;
|
||||
$bgid = null;
|
||||
$schoolid = null;
|
||||
$swvs = null;
|
||||
$kamers = null;
|
||||
$bgs = null;
|
||||
$scholen = null;
|
||||
|
||||
$organisatie = $this->Organisaties_model->get_record_by_id($orgid);
|
||||
|
||||
if ($organisatie->soort == 1){
|
||||
$swvid = $orgid;
|
||||
}
|
||||
|
||||
if ($organisatie->soort == 2){
|
||||
$swvid = $organisatie->valtonder_id;
|
||||
$kamerid = $orgid;
|
||||
}; // if soort =2
|
||||
|
||||
if ($organisatie->soort == 3){
|
||||
$bgid = $organisatie->id;
|
||||
$kamerid = $organisatie->valtonder_id;
|
||||
$kamerorg = $this->Organisaties_model->get_record_by_id($kamerid);
|
||||
$swvid = $kamerorg->valtonder_id;
|
||||
}; // if soort = 3
|
||||
|
||||
if ($organisatie->soort == 4){
|
||||
$schoolid = $orgid;
|
||||
$bgid = $organisatie->valtonder_id;
|
||||
$orgbg = $this->Organisaties_model->get_record_by_id($bgid);
|
||||
$kamerid = $orgbg->valtonder_id;
|
||||
$orgkamer = $this->Organisaties_model->get_record_by_id($kamerid);
|
||||
$swvid = $orgkamer->valtonder_id;
|
||||
}; // if soort = 4
|
||||
|
||||
$swvs=$this->Organisaties_model->getorgsdetails(1, false);
|
||||
foreach ($swvs as $swv) {
|
||||
if ($swv->id == $swvid){
|
||||
$kamers = $this->Organisaties_model->getorgsdetails(2,$swvid);
|
||||
if ($kamers){
|
||||
if (!$kamerid) {$kamerid = $kamers[0]->id; };
|
||||
foreach ($kamers as $kamer){
|
||||
if ($kamer->id == $kamerid){
|
||||
$bgs = $this->Organisaties_model->getorgsdetails(3, $kamerid);
|
||||
if ($bgs){
|
||||
if (!$bgid){$bgid = $bgs[0]->id;};
|
||||
foreach ($bgs as $bg){
|
||||
if ($bg->id == $bgid){
|
||||
$scholen = $this->Organisaties_model->getorgsdetails(4,$bgid);
|
||||
}
|
||||
};// foreach bg
|
||||
}; // if bgs
|
||||
}; // if kamerid = kamerid
|
||||
}; // foreach kamers
|
||||
}; // if kamers
|
||||
}; // if swvid
|
||||
} ; // foreach swv
|
||||
echo json_encode(array('swvid' =>$swvid,
|
||||
'kamerid' =>$kamerid,
|
||||
'bgid' =>$bgid,
|
||||
'schoolid' =>$schoolid,
|
||||
'swvs' =>$swvs,
|
||||
'kamers' =>$kamers,
|
||||
'bgs' =>$bgs,
|
||||
'scholen' =>$scholen));
|
||||
|
||||
}
|
||||
function getorgnivo(){
|
||||
$nivo =$this->Organisaties_model->getsoortvanorginalorg($this->userid);
|
||||
echo json_encode($nivo);
|
||||
}
|
||||
|
||||
function getscholenvoormenu(){
|
||||
$modulenr = $this->uri->segment(4);
|
||||
$orgid = $this->globorgid;
|
||||
$bgs=array();
|
||||
$scholen=array();
|
||||
$org = $this->Organisaties_model->get_record_by_id($orgid);
|
||||
if ($org->soort == 1){
|
||||
$kamers=$this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($kamers) {
|
||||
foreach($kamers as $kamer){
|
||||
$bg =$this->Organisaties_model->getorgsvanaf($kamer->id);
|
||||
if ($bg){$bgs=array_merge($bgs,$bg); };
|
||||
}
|
||||
}
|
||||
if ($bgs) {
|
||||
foreach($bgs as $bg){
|
||||
if($modulenr == 270) {
|
||||
$schl = $this->Organisaties_model->getorgsvanafmetlicentie($bg->id, $modulenr);
|
||||
}
|
||||
else{
|
||||
$schl = $this->Organisaties_model->getorgsvanaf($bg->id);
|
||||
}
|
||||
if ($schl){
|
||||
$scholen=array_merge($scholen, $schl);
|
||||
};
|
||||
}
|
||||
}
|
||||
}; // if orgsoort ==1
|
||||
if ($org->soort ==2){
|
||||
$bgs = $this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($bgs){
|
||||
foreach($bgs as $bg){
|
||||
if($modulenr == 270) {
|
||||
$schl = $this->Organisaties_model->getorgsvanafmetlicentie($bg->id, $modulenr);
|
||||
}
|
||||
else{
|
||||
$schl = $this->Organisaties_model->getorgsvanaf($bg->id);
|
||||
}
|
||||
if ($schl){
|
||||
$scholen=array_merge($scholen, $schl);
|
||||
}; // if schl
|
||||
}
|
||||
}
|
||||
}; // if orgsoort =2
|
||||
if ($org->soort ==3 ){
|
||||
if($modulenr == 270) {
|
||||
$schl = $this->Organisaties_model->getorgsvanafmetlicentie($orgid, $modulenr);
|
||||
}
|
||||
else{
|
||||
$schl = $this->Organisaties_model->getorgsvanaf($orgid);
|
||||
}
|
||||
}
|
||||
if ($org->soort == 4){
|
||||
$scholen[]= $org;
|
||||
}
|
||||
$school = true;
|
||||
if ($org->soort != 4) $school=false;
|
||||
|
||||
|
||||
echo json_encode(array('scholen'=>$scholen, 'school'=>$school));
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getscholen(){
|
||||
$orgid = $this->globorgid;
|
||||
$bgs=array();
|
||||
$scholen=array();
|
||||
$org = $this->Organisaties_model->get_record_by_id($orgid);
|
||||
if ($org->soort == 1){
|
||||
$kamers=$this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($kamers) {
|
||||
foreach($kamers as $kamer){
|
||||
$bg =$this->Organisaties_model->getorgsvanaf($kamer->id);
|
||||
if ($bg){$bgs=array_merge($bgs,$bg); };
|
||||
}
|
||||
}
|
||||
if ($bgs) {
|
||||
foreach($bgs as $bg){
|
||||
$schl = $this->Organisaties_model->getorgsvanaf($bg->id);
|
||||
if ($schl){
|
||||
$scholen=array_merge($scholen, $schl);
|
||||
};
|
||||
}
|
||||
}
|
||||
}; // if orgsoort ==1
|
||||
if ($org->soort ==2){
|
||||
$bgs = $this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($bgs){
|
||||
foreach($bgs as $bg){
|
||||
$schl = $this->Organisaties_model->getorgsvanaf($bg->id);
|
||||
if ($schl){
|
||||
$scholen=array_merge($scholen, $schl);
|
||||
}; // if schl
|
||||
}
|
||||
}
|
||||
}; // if orgsoort =2
|
||||
if ($org->soort ==3 ){
|
||||
$scholen = $this->Organisaties_model->getorgsvanaf($org->id);
|
||||
}
|
||||
if ($org->soort == 4){
|
||||
$scholen[]= $org;
|
||||
}
|
||||
$school = true;
|
||||
if ($org->soort != 4) $school=false;
|
||||
echo json_encode(array('scholen'=>$scholen, 'school'=>$school));
|
||||
}
|
||||
|
||||
function getsoscholen(){
|
||||
$orgid = $this->globorgid;
|
||||
$bgs=array();
|
||||
$scholen=array();
|
||||
$instrument = 270;
|
||||
$org = $this->Organisaties_model->get_record_by_id($orgid);
|
||||
if ($org->soort == 1){
|
||||
$kamers=$this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($kamers) {
|
||||
foreach($kamers as $kamer){
|
||||
$bg =$this->Organisaties_model->getorgsvanaf($kamer->id);
|
||||
if ($bg){$bgs=array_merge($bgs,$bg); };
|
||||
}
|
||||
}
|
||||
if ($bgs) {
|
||||
foreach($bgs as $bg){
|
||||
$schl = $this->Organisaties_model->getorgsvanafmetlicentie($bg->id, $instrument);
|
||||
if ($schl){
|
||||
$scholen=array_merge($scholen, $schl);
|
||||
};
|
||||
}
|
||||
}
|
||||
}; // if orgsoort ==1
|
||||
if ($org->soort ==2){
|
||||
$bgs = $this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($bgs){
|
||||
foreach($bgs as $bg){
|
||||
$schl = $this->Organisaties_model->getorgsvanafmetlicentie($bg->id, $instrument);
|
||||
if ($schl){
|
||||
$scholen=array_merge($scholen, $schl);
|
||||
}; // if schl
|
||||
}
|
||||
}
|
||||
}; // if orgsoort =2
|
||||
if ($org->soort ==3 ){
|
||||
$scholen = $this->Organisaties_model->getorgsvanafmetlicentie($org->id, $instrument);
|
||||
}
|
||||
if ($org->soort == 4){
|
||||
$scholen[]= $org;
|
||||
}
|
||||
$school = true;
|
||||
if ($org->soort != 4) $school=false;
|
||||
|
||||
|
||||
echo json_encode(array('soscholen'=>$scholen, 'school'=>$school));
|
||||
}
|
||||
|
||||
function controleerschool(){
|
||||
if (!$this->userid) die;
|
||||
$orgid = $this->globorgid;
|
||||
$school = false;
|
||||
$organisatie = $this->Organisaties_model->get_record_by_id($orgid);
|
||||
if ($organisatie && $organisatie->soort == 4) $school = true;
|
||||
echo json_encode($school);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getselectedschool(){
|
||||
echo json_encode($this->selectedschool);
|
||||
}
|
||||
|
||||
function getmodules(){
|
||||
$orgid = $this->uri->segment(4); // als 0 dan nieuwe organisatie
|
||||
$modules = $this->Modules_model->getallmodules();
|
||||
if ($modules){
|
||||
foreach($modules as $module){
|
||||
$module->janee =$this->Licenties_model->getmodulelicentie($orgid, $module->sysnr);
|
||||
}
|
||||
}; // if modules
|
||||
echo json_encode($modules);
|
||||
}
|
||||
|
||||
function getRandomName(){
|
||||
$this->load->helper('string');
|
||||
return random_string("alnum", 20);
|
||||
}
|
||||
|
||||
function deleteOldBijlage($orgID){
|
||||
$oldBijlage = $this->Organisaties_model->get(['id'=>$orgID],'randomname', true);
|
||||
if ($oldBijlage) unlink('./../docs/'.$oldBijlage);
|
||||
}
|
||||
|
||||
function setNieuweBijlage($orgID, $randomname, $filename){
|
||||
$this->Organisaties_model->update_record(['randomname'=>$randomname, 'bijlagefile'=>$filename], $orgID);
|
||||
}
|
||||
|
||||
function saveBijlageFile(){
|
||||
$randomname = $this->getRandomName();
|
||||
|
||||
$config['upload_path'] = './../docs/';
|
||||
$config['allowed_types'] = '*';
|
||||
$config['max_size'] = 10000;
|
||||
$config['file_name'] = $randomname;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
$orgID = $_POST['orgID'];
|
||||
$filename = $_FILES['file']['name'];
|
||||
|
||||
|
||||
if ( ! $this->upload->do_upload('file')) $error = $this->upload->display_errors();
|
||||
else {
|
||||
$error = FALSE;
|
||||
$randomname = $this->upload->data('file_name')['file_name'];
|
||||
$this->deleteOldBijlage($orgID);
|
||||
$this->setNieuweBijlage($orgID, $randomname, $filename);
|
||||
}
|
||||
$this->json($error);
|
||||
}
|
||||
|
||||
function deleteBijlage(){
|
||||
// nog een controle op autorisatie?
|
||||
if ( $this->Autorisaties_model->check_autorisatie($this->userrole, 1) <= 0 ) return;
|
||||
$orgID = $this->clean_input('orgID');
|
||||
$this->deleteOldBijlage($orgID);
|
||||
$this->Organisaties_model->update_record(['bijlagefile'=>NULL, 'randomname'=>NULL],$orgID);
|
||||
}
|
||||
} // controller
|
||||
@@ -0,0 +1,287 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
|
||||
class Portal extends MY_Controller {
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$models = array( "shared/Session_model",
|
||||
"shared/Licenties_model",
|
||||
"shared/Organisaties_model",
|
||||
"shared/Users_model",
|
||||
"shared/Orgusers_model",
|
||||
"shared/Functies_model",
|
||||
"monpas/Home_model",
|
||||
"monpas/Orgversies_model",
|
||||
"monpas/Scores_model",
|
||||
"monpas/Labels_model",
|
||||
"monpas/Modules_model");
|
||||
$this->load->model($models);
|
||||
$this->load->library('monpas/kleurcodes');
|
||||
$this->load->helper('string');
|
||||
if (!$this->check_online_status()) {
|
||||
echo json_encode(array('offline' => TRUE));
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
|
||||
function naarmodule() {
|
||||
if ($this->nologin) return;
|
||||
$module = $this->uri->segment(4);
|
||||
$this->Session_model->set_module($module);
|
||||
}
|
||||
|
||||
|
||||
function getlicenties() {
|
||||
$ongeclusterdId = 0;
|
||||
$isCluster = 'F';
|
||||
$ongeclusterd = $this->Licenties_model->get_ongeclusterd($this->globorgid, $ongeclusterdId);
|
||||
if ($ongeclusterd){
|
||||
foreach ($ongeclusterd as $bolletje) {
|
||||
$bolletje->isCluster = $isCluster;//geen knop om het cluster te openen en te sluiten
|
||||
}
|
||||
} else {
|
||||
$ongeclusterd = [];
|
||||
};
|
||||
$isCluster = 'T';
|
||||
$clusters = $this->Licenties_model->get_clusters_org($this->globorgid);
|
||||
if($clusters) {
|
||||
$i = -1;
|
||||
foreach ($clusters as $cluster) {
|
||||
$i ++;
|
||||
if ($cluster->aantalmodules == 1) {
|
||||
$cluster->isCluster = "F";
|
||||
$newitem = $this->Licenties_model->get_ongeclusterd($this->globorgid, $cluster->id);
|
||||
$ongeclusterd = array_merge($ongeclusterd, $newitem);
|
||||
unset($clusters[$i]);
|
||||
} else {
|
||||
$cluster->isCluster = $isCluster; //ivm knop om het cluster te openen en te sluiten
|
||||
$cluster->sub = $this->Licenties_model->get_licentie_cluster($this->globorgid, $cluster->id);//instrumenten bij het cluster
|
||||
$cluster->cluster_id = $cluster->id; //zodat cluster en instrument eenzelfde attribuut hebben
|
||||
}
|
||||
};
|
||||
}; // if $clusters
|
||||
|
||||
if (! $ongeclusterd){
|
||||
$ongeclusterd = [];
|
||||
};
|
||||
if(!$clusters){
|
||||
$clusters = [];
|
||||
};
|
||||
|
||||
$licenties = array_merge($ongeclusterd, $clusters);
|
||||
usort($licenties, array($this, 'opAlfabet'));//bollen op alfbetische volgorde
|
||||
|
||||
echo json_encode($licenties);
|
||||
}
|
||||
|
||||
/**
|
||||
* haalt individuele instrumenten op voor orgusers met een bij het instrument horende functie.
|
||||
* Voor export naar monPon
|
||||
*/
|
||||
|
||||
function getBollenMonPon()
|
||||
{
|
||||
$portalorg = 5;
|
||||
$portaluser = 6;
|
||||
$orgid = $this->Organisaties_model->get_fieldvalue(array('portal_id'=>$portalorg),"id");
|
||||
$userid = $this->Users_model->get_fieldvalue(array('portal_id'=>$portaluser),"id");
|
||||
|
||||
$functiebollen = [];
|
||||
$functiesuser = $this->Functies_model->getFunctiesOrguser($orgid, $userid);
|
||||
|
||||
if (!$functiesuser) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bollen = $this->Modules_model->get_instrumenten_ind_org($orgid);
|
||||
if (!$bollen) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($bollen as $bolletje) {
|
||||
$functiesmod = $this->Functies_model->getFunctiesBijModule($bolletje->moduleid);
|
||||
if ($functiesmod) {
|
||||
|
||||
foreach ($functiesmod as $mfunctie) {
|
||||
foreach ($functiesuser as $userfunctie) {
|
||||
if ($mfunctie->functie_id == $userfunctie->functieid) {
|
||||
$bolletje->userid = $userfunctie->userid;
|
||||
$bolletje->fullname = $userfunctie->fullname;
|
||||
|
||||
if (sizeof($functiebollen) < 1) {
|
||||
array_push($functiebollen, $bolletje);
|
||||
} else {
|
||||
foreach ($functiebollen as $fbol) {
|
||||
if ($fbol->moduleid != $bolletje->moduleid) {
|
||||
array_push($functiebollen, $bolletje);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$functiebollen = array_map("unserialize", array_unique(array_map("serialize", $functiebollen)));//verwijdert dubbele instrumenten
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$bollendef = $this->getIngevuldeInstrumenten($userid, $orgid, $functiebollen);
|
||||
echo json_encode($bollendef);
|
||||
}
|
||||
|
||||
function getAgendaMonPon(){
|
||||
if (!$this->userid) die;
|
||||
$filledversionid = $this->uri->segment(4);
|
||||
$scores = null;
|
||||
$gewenst = null;
|
||||
// let op ja nee bezig wordt vertaald naar 10, 0 en 5
|
||||
|
||||
$scores = $this->Scores_model->calculateindividualMonPon($filledversionid);
|
||||
|
||||
// haal ook nog de criteria van de organisatie op
|
||||
foreach($scores as $score){
|
||||
$score->gem = 0;
|
||||
if ($score->num > 0){
|
||||
$score->gem = round($score->somscore / $score->num,1);
|
||||
}
|
||||
$score->huidig= $this->kleurcodes->getnummer($score->gem);
|
||||
} ; // foreach scores
|
||||
|
||||
|
||||
// $gewenst=$this->Scores_model->getgewenst($orgid, $orgversieid);
|
||||
// if ($gewenst){
|
||||
// $i =0;
|
||||
// foreach($scores as $score){
|
||||
// $score->gewenstid= $gewenst[$i]->id;
|
||||
// $score->gewenst = $gewenst[$i]->wens;
|
||||
// $i = $i + 1;
|
||||
// }; //foreach
|
||||
// }
|
||||
echo json_encode(array('scores' =>$scores));
|
||||
} // getscores
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function kiesCluster(){
|
||||
$clusterId = $this->uri->segment(4);
|
||||
|
||||
$ongeclusterdId = 0;
|
||||
$isCluster = 'F';
|
||||
$wasniveau2 = 'F'; //hingen voor de keuze niet aan cluster
|
||||
|
||||
$ongeclusterd = $this->Licenties_model->get_ongeclusterd($this->globorgid, $ongeclusterdId);
|
||||
//instrumenten die niet bij een cluster horen
|
||||
if($ongeclusterd) {
|
||||
foreach ($ongeclusterd as $bol) {
|
||||
$bol->wasNiveau2 = $wasniveau2;
|
||||
$bol->isCluster = $isCluster;
|
||||
}
|
||||
}
|
||||
$isCluster = 'T';
|
||||
$clusters = $this->Licenties_model->get_clusters_org($this->globorgid);
|
||||
if($clusters) {
|
||||
foreach ($clusters as $cluster) {
|
||||
$cluster->wasNiveau2 = $wasniveau2;
|
||||
$cluster->isCluster = $isCluster;
|
||||
}
|
||||
};
|
||||
|
||||
$isCluster = 'F';
|
||||
$wasniveau2 = 'T';
|
||||
$keuze = $this->Licenties_model->get_ongeclusterd($this->globorgid, $clusterId); //gekozen cluster van instrumenten
|
||||
if($keuze) {
|
||||
foreach ($keuze as $keus) {
|
||||
$keus->wasNiveau2 = $wasniveau2;// waren bollen onde cluster nu niveau hoger
|
||||
$keus->isCluster = $isCluster;
|
||||
}
|
||||
};
|
||||
if($clusters) {
|
||||
foreach ($clusters as $cluster) {
|
||||
$cluster->cluster_id = $cluster->id;
|
||||
if ($cluster->cluster_id != $clusterId) { //voeg instrumenten toe aan niet-gekozen clusters
|
||||
$cluster->sub = $this->Licenties_model->get_licentie_cluster($this->globorgid, $cluster->id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if(!$clusters){
|
||||
$clusters =[];
|
||||
};
|
||||
if(!$ongeclusterd){
|
||||
$ongeclusterd = [];
|
||||
};
|
||||
|
||||
$licenties = array_merge($ongeclusterd, $clusters);
|
||||
usort($licenties, array($this, 'opAlfabet'));
|
||||
usort($keuze, array($this, 'opAlfabet'));
|
||||
$clusternaam = $this->Licenties_model->get_clusterNaam($clusterId);
|
||||
|
||||
$geselecteerd = $this->arrayinArray($licenties, $keuze, $clusterId, $clusternaam);
|
||||
|
||||
echo json_encode($geselecteerd);
|
||||
}
|
||||
|
||||
|
||||
function getmodule() {
|
||||
$module = $this->session->userdata['module'];
|
||||
$hometekst = $this->Home_model->get_fieldvalue(['modulenr' => $module], 'tekst');
|
||||
echo json_encode(['module' => $module, 'hometekst' => $hometekst]);
|
||||
}
|
||||
|
||||
private function arrayinArray($knipArray, $invoegArray, $var1, $var2) {
|
||||
$lengte = count($knipArray);
|
||||
$breekpunt = "";
|
||||
$eindpunt = "";
|
||||
|
||||
for ($i = 0; $i < $lengte; $i++) {
|
||||
if ($knipArray[$i]->id == $var1 && $knipArray[$i]->naam == $var2) {
|
||||
$breekpunt = $i + 1; //array wordt geknipt na het cluster van de keuze
|
||||
$eindpunt = $lengte - $breekpunt - 1;
|
||||
}
|
||||
|
||||
$licenties1 = array_slice($knipArray, 0, $breekpunt);
|
||||
$licenties2 = array_slice($knipArray, $breekpunt + 1, $eindpunt);
|
||||
$doelArray = array_merge($licenties1, $invoegArray, $licenties2); //array invoegen na breekpunt
|
||||
|
||||
}
|
||||
return $doelArray;
|
||||
}
|
||||
|
||||
private function opAlfabet($a, $b)
|
||||
{
|
||||
return strcmp($a->naam, $b->naam);
|
||||
}
|
||||
|
||||
|
||||
private function getIngevuldeInstrumenten($userid, $orgid, $bollen){
|
||||
|
||||
foreach ($bollen as $bolletje){
|
||||
$versies = $this->Modules_model->get_instrumenten_ingevuld_ind($bolletje->moduleid, $userid, $orgid);
|
||||
|
||||
if($versies){
|
||||
$bolletje->ingevuld = 'T';
|
||||
$bolletje->versies = $versies;
|
||||
$bolletje->label = $this->Labels_model->getLabel($bolletje->sysnr);
|
||||
}
|
||||
else{
|
||||
$bolletje->ingevuld = 'F';
|
||||
}
|
||||
}
|
||||
|
||||
return $bollen;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Schooljaren extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array("shared/Users_model",'shared/Schooljaren_model');
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
}
|
||||
|
||||
function getschooljaren(){
|
||||
$schooljaren = $this->Schooljaren_model->getschooljaren();
|
||||
echo json_encode($schooljaren);
|
||||
}
|
||||
|
||||
function getselectedschooljaar(){
|
||||
echo json_encode($this->schooljaar);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
use Pheanstalk\Pheanstalk;
|
||||
|
||||
class Upload extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$models = array( "shared/Files_model");
|
||||
$this->load->model($models);
|
||||
|
||||
if (!$this->check_online_status()) {
|
||||
echo json_encode(array('offline' => TRUE));
|
||||
die;
|
||||
};// if
|
||||
$this->load->helper("file");
|
||||
}
|
||||
|
||||
function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
||||
{
|
||||
$str = '';
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$str .= $keyspace[rand(0, $max)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function CheckFileExists($naam, $modulenr){
|
||||
$exists = $this->Files_model->file_exists($naam, $modulenr, $this->globorgid);
|
||||
return $exists;
|
||||
}
|
||||
|
||||
public function doUpload()
|
||||
{
|
||||
$folder = $this->input->post('folderID');
|
||||
$module = $this->input->post('module');
|
||||
$oldDocID = $this->input->post('oldDocID');
|
||||
|
||||
|
||||
$fn = '';
|
||||
if (isset ($_FILES['upload_file'])){
|
||||
$fn = $_FILES['upload_file'];
|
||||
}
|
||||
$this->sharedUpload($fn, $folder, $module,$oldDocID);
|
||||
|
||||
}
|
||||
private function sharedUpload($fn, $folder, $module,$docID = false){
|
||||
$newName = $this->random_str(12);
|
||||
$fileExists = $this->CheckFileExists($fn['name'], $module);
|
||||
// nog afvangen : file exists maar een doc id meegegeven: dan moet de file overschreven worden
|
||||
$error ='';
|
||||
if ($fn) {
|
||||
$ext =end(explode('.', $fn['name']) );
|
||||
if ($ext) $ext = '.'. $ext;
|
||||
|
||||
if ($fileExists) { $error=$fn['name'].": bestand is al geupload"; };
|
||||
if ($error <=''){
|
||||
if (move_uploaded_file( $fn['tmp_name'] , '../dossier/'.$newName ) ) {
|
||||
|
||||
$data = ['organisatie_id' =>$this->globorgid,
|
||||
'folder_id' =>$folder,
|
||||
'original_name' =>$fn['name'],
|
||||
'new_name' =>$newName,
|
||||
'modified' =>date('Y-m-d h:i:s'),
|
||||
'owner' =>$this->userid ,
|
||||
'extension' =>$ext ];
|
||||
$newID = $this->Files_model->insert_record($data);
|
||||
if ($newID){ $this->queueConversion($newID); }
|
||||
}
|
||||
};
|
||||
} else{
|
||||
$error .= $fn.' fout bij uploaden';
|
||||
}
|
||||
echo $error;
|
||||
}
|
||||
|
||||
public function doDropUpload(){
|
||||
|
||||
$folder = $this->uri->segment(4);
|
||||
$module = $this->uri->segment(5);
|
||||
|
||||
$fn = '';
|
||||
|
||||
$fn = $_FILES['file'];
|
||||
$this->sharedUpload($fn, $folder, $module);
|
||||
}
|
||||
|
||||
private function queueConversion( $fileID ) {
|
||||
$pheanstalk = new Pheanstalk( '127.0.0.1' );
|
||||
|
||||
$job = new stdClass();
|
||||
|
||||
$job->function = 'convertDocument';
|
||||
$job->user_data = $fileID;
|
||||
$job_data = json_encode( $job );
|
||||
|
||||
$pheanstalk
|
||||
->useTube( $this->beanstalkPipe )
|
||||
->put( $job_data );
|
||||
}
|
||||
|
||||
public function show_pdf(){
|
||||
$fileID= $this->uri->segment( 4 );
|
||||
// TODO check file toegangsrecht
|
||||
$file = $this->Files_model->get(['id'=>$fileID],false,true);
|
||||
if (! $file) {
|
||||
$this->json('file niet gevonden');
|
||||
return;
|
||||
}
|
||||
if (! ($file->extension == ".pdf" || $file->conversion_status == 'WORD-PDF-CONVERSION-SUCCEEDED')){
|
||||
$this->json('geen pdf beschikbaar');
|
||||
return;
|
||||
}
|
||||
if ($file->extension == ".pdf") $fullpath = $this->dossierpath;
|
||||
else $fullpath = $this->pdfpath;
|
||||
|
||||
$fullpath = $fullpath . $file->new_name;
|
||||
|
||||
header( 'Content-Description: File Transfer' );
|
||||
header( 'Content-Type: application/pdf' );
|
||||
header( 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' );
|
||||
header( 'Pragma: public' );
|
||||
header( 'Content-Length: ' . filesize( $fullpath) );
|
||||
readfile( $fullpath );
|
||||
}
|
||||
|
||||
public function download_file(){
|
||||
//TODO check toegangsrecht
|
||||
$fileID = $this->uri->segment(4);
|
||||
$document = $this->Files_model->get(['id'=>$fileID],false,true);
|
||||
if (! $document) {
|
||||
$this->json('Document niet gevonden');
|
||||
return;
|
||||
}
|
||||
$this->load->helper( 'download' );
|
||||
$data = file_get_contents( $this->dossierpath . $document->new_name );
|
||||
force_download( $document->original_name, $data );
|
||||
}
|
||||
|
||||
public function download_bijlage(){
|
||||
$orgID = $this->uri->segment(4);
|
||||
$randomname = $this->Organisaties_model->get(['id'=>$orgID],'randomname', true);
|
||||
$originalname = $this->Organisaties_model->get(['id'=>$orgID],'bijlagefile', true);
|
||||
$this->load->helper( 'download' );
|
||||
$data = file_get_contents( './../docs/' . $randomname );
|
||||
force_download( $originalname, $data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Users extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
if ( ! $this->userid) exit('geen toegang');
|
||||
$models = array( "shared/Users_model",
|
||||
'shared/Organisaties_model',
|
||||
"shared/Orgusers_model",
|
||||
"shared/functies_model",
|
||||
"monpas/Filledversions_model",
|
||||
"monpas/Groepenxusers_model",
|
||||
"monpas/Versies_model",
|
||||
"monpas/Orgversies_model");
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
if ( ! $this->check_online_status() ) {
|
||||
echo json_encode( array('offline' => TRUE) );
|
||||
die;
|
||||
};// if
|
||||
}
|
||||
function getuserdetail(){
|
||||
if (!$this->userid || $this->nologin){die;};
|
||||
|
||||
$userid = $this->uri->segment(4);
|
||||
if (!$userid) {$userid = $this->userid; };
|
||||
$user = $this->Users_model->getdetails($userid);
|
||||
echo json_encode($user);
|
||||
}
|
||||
|
||||
public function updateuser(){
|
||||
//TODO sanitize input
|
||||
if (!$this->userid || $this->nologin){die;};
|
||||
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, WRITER) > 0 ) {
|
||||
$data=array('voornaam' => $this->clean_input('voornaam'),
|
||||
'tussenvoegsel' => $this->clean_input('tussenvoegsel'),
|
||||
'achternaam' => $this->clean_input('achternaam'),
|
||||
'email' => $this->clean_input('email') );
|
||||
if (strlen($this->input->post('wachtwoord')) >=4){
|
||||
$data['wachtwoord']=$this->input->post('wachtwoord');
|
||||
} ;
|
||||
$this->Users_model->update_record($data, $this->userid);
|
||||
};
|
||||
$fullname = $this->Users_model->get_fullname($this->userid);
|
||||
echo json_encode($fullname);
|
||||
}
|
||||
|
||||
function getorgs(){
|
||||
$userid = $this->userid;
|
||||
$userorg = $this->Organisaties_model->getorg($this->globorgid) ;
|
||||
$orgs = null;
|
||||
if ($userorg->soort == 4){
|
||||
// doe niks
|
||||
}
|
||||
if ($userorg->soort == 3){
|
||||
//get scholen
|
||||
$userorg->orgs1= $this->Organisaties_model->getorgsvanaf($userorg->id);
|
||||
};
|
||||
if($userorg->soort==2){
|
||||
$userorg->orgs1= $this->Organisaties_model->getorgsvanaf($userorg->id);
|
||||
if ($userorg->orgs1){
|
||||
foreach($userorg->orgs1 as $bg){
|
||||
$bg->orgs2 = $this->Organisaties_model->getorgsvanaf($bg->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($userorg->soort=1){
|
||||
$userorg->orgs= $this->Organisaties_model->getorgsvanaf($userorg->id);
|
||||
if ($userorg->orgs){
|
||||
foreach($userorg->orgs as $kamer){
|
||||
$kamer->orgs = $this->Organisaties_model->getorgsvanaf($kamer->id);
|
||||
if ($kamer->orgs){
|
||||
foreach($kamer->orgs as $bg){
|
||||
$bg->orgs = $this->Organisaties_model->getorgsvanaf($bg->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($userorg);
|
||||
}
|
||||
|
||||
|
||||
function getorggebruikers(){
|
||||
if (!$this->nologin){
|
||||
$orgid = $this->uri->segment(4);
|
||||
$users = $this->Users_model->getorggebruikers($orgid, false);
|
||||
|
||||
echo json_encode($users);
|
||||
}
|
||||
}
|
||||
|
||||
function adduser(){
|
||||
//TODO clean input
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, WRITER) > 0 ) {
|
||||
$ok = true;
|
||||
$errortekst = '';
|
||||
$user = null;
|
||||
$orgid = $this->input->post("orgid");
|
||||
$gnaam=$this->input->post('gnaam');
|
||||
$gnaam = trim($gnaam);
|
||||
if ($this->Users_model->check_username($gnaam) > 0){
|
||||
$errortekst =" Gebruikersnaam is niet toegestaan. Gebruik een andere naam.";
|
||||
$ok = false;
|
||||
};
|
||||
if ($ok) {
|
||||
// maak een user
|
||||
//maak wachtwoord en send email
|
||||
$zout = random_string('alnum', 15);
|
||||
$ww = random_string('alnum', 8);
|
||||
$saltedww = md5($zout.$ww);
|
||||
$data = array("voornaam" =>$this->input->post('voornaam'),
|
||||
"tussenvoegsel" =>$this->input->post('tussenvoegsel'),
|
||||
"achternaam" =>$this->input->post('achternaam'),
|
||||
"email" =>$this->input->post('email'),
|
||||
"gnaam" =>$gnaam,
|
||||
"zout" =>$zout,
|
||||
"wachtwoord" =>$saltedww);
|
||||
$userid = $this->Users_model->insert_record($data);
|
||||
$this->sendmail($userid,$ww,$orgid);
|
||||
// maak een orguser
|
||||
$data = array( "user_id" => $userid,
|
||||
"organisatie_id" => $orgid);
|
||||
$orguserid = $this->Orgusers_model->insert_record($data);
|
||||
//maak autorisatie
|
||||
$data = array( "nivo_id" =>$this->input->post('autorisatienivoid'),
|
||||
"orguser_id" =>$orguserid);
|
||||
$this->Autorisaties_model->insert_record($data);
|
||||
//get user gegevens om op te nemen in de view
|
||||
$user=$this->Users_model->getorggebruikers($orgid, $userid);
|
||||
|
||||
} // if ok
|
||||
}
|
||||
else {
|
||||
$ok =false;
|
||||
$errortekst ="U bent niet geautoriseerd voor deze handeling.";
|
||||
$user ='';
|
||||
}; // if geen writer
|
||||
echo json_encode(array('ok' =>$ok,
|
||||
'errortekst' => $errortekst,
|
||||
'user' => $user));
|
||||
}
|
||||
|
||||
function getBijlage($orgid){
|
||||
|
||||
$org = $this->Organisaties_model->get(['id'=>$orgid],false, true);
|
||||
|
||||
if (! $org->randomname && $org->id != $org->valtonder_id){
|
||||
return $this->getBijlage($org->valtonder_id);
|
||||
}
|
||||
else return $org;
|
||||
|
||||
}
|
||||
|
||||
function sendmail($userid, $ww, $orgid){
|
||||
$user = $this->Users_model->get_record_by_id($userid);
|
||||
$data = array('username'=>$user->gnaam, 'password'=>$ww, 'fullname'=>$this->Users_model->get_fullname($userid));
|
||||
$org = $this->getBijlage($orgid);
|
||||
$this->load->library('email');
|
||||
|
||||
$this->email->from('noreply@framework.nl', 'Framework+ MonPas');
|
||||
$this->email->to($user->email);
|
||||
$this->email->subject('Inloggegevens MonPas');
|
||||
$this->email->message($this->load->view('emails/newuser_mail', $data, TRUE));
|
||||
$this->email->bcc("rfranke@framework-ed.nl");
|
||||
if ($org->randomname)
|
||||
$this->email->attach('./../docs/'.$org->randomname,'attachment', $org->bijlagefile);
|
||||
$this->email->send();
|
||||
}
|
||||
|
||||
function updateuser2(){
|
||||
// TODO sanitize input
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, WRITER) > 0 ) {
|
||||
$ok = true;
|
||||
$errortekst = '';
|
||||
$user = null;
|
||||
$fullname ='';
|
||||
$userid = $this->input->post("id");
|
||||
$orgid = $this->input->post("orgid");
|
||||
$gnaam = trim($this->input->post('gnaam'));
|
||||
// controleer gebruikersnaam
|
||||
if ($this->Users_model->check_username($gnaam, $userid) > 0){
|
||||
$errortekst =" Gebruikersnaam is niet toegestaan. Gebruik een andere naam.";
|
||||
$ok = false;
|
||||
};
|
||||
|
||||
if ($ok) {
|
||||
$data = array("voornaam" =>$this->input->post('voornaam'),
|
||||
"tussenvoegsel" =>$this->input->post('tussenvoegsel'),
|
||||
"achternaam" =>$this->input->post('achternaam'),
|
||||
"email" =>$this->input->post('email'),
|
||||
"gnaam" =>$gnaam);
|
||||
$this->Users_model->update_record($data, $userid);
|
||||
|
||||
//update autorisatie
|
||||
$where = array('user_id' =>$userid, 'organisatie_id'=>$orgid);
|
||||
$orguserid = $this->Orgusers_model->get_records_where($where, true);
|
||||
$orguserid = $orguserid->id;
|
||||
$data = array( "nivo_id" =>$this->input->post('autorisatienivoid'));
|
||||
$where = array('orguser_id' => $orguserid);
|
||||
$this->Autorisaties_model->update_record_where($data, $where);
|
||||
//get user gegevens om op te nemen in de view
|
||||
$user=$this->Users_model->getorggebruikers($orgid, $userid);
|
||||
// als de veranderde user = glob user : pas fullname onder menu aan
|
||||
if ($userid == $this->userid){
|
||||
$fullname = $this->Users_model->get_fullname($userid);
|
||||
}
|
||||
if ($this->input->post("status") == 3){
|
||||
//stuur email aan de gebruiker
|
||||
$zout = random_string('alnum', 15);
|
||||
$ww = random_string('alnum', 8);
|
||||
$saltedww = md5($zout.$ww);
|
||||
$data=array('zout' => $zout, "wachtwoord" =>$saltedww);
|
||||
$this->Users_model->update_record($data, $userid);
|
||||
$this->sendmail($userid,$ww,$orgid);
|
||||
}
|
||||
} // if ok
|
||||
|
||||
//get user gegevens om op te nemen in de view
|
||||
$user=$this->Users_model->getorggebruikers($orgid, $userid);
|
||||
}
|
||||
else {$ok = false;
|
||||
$errortekst = "U bent niet geautoriseerd voor deze handeling." ;
|
||||
$user = '';
|
||||
$fullname = '';
|
||||
}; // geen write rechten
|
||||
echo json_encode(array('ok' => $ok,
|
||||
'errortekst' => $errortekst,
|
||||
'user' => $user,
|
||||
'fullname' => $fullname));
|
||||
}
|
||||
function deleteuser(){
|
||||
//TODO sanitize input
|
||||
$user=FALSE;
|
||||
$userid= $this->uri->segment(4);
|
||||
$orgid= $this->uri->segment(5);
|
||||
$orguser = $this->Orgusers_model->get_records_where(array("user_id"=>$userid, "organisatie_id"=>$orgid),true);
|
||||
$ok = true;
|
||||
$errortekst = '';
|
||||
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, WRITER) <=0 ) {
|
||||
$ok = false;
|
||||
$errortekst = "U bent niet geautoriseerd tot verwijderen.";
|
||||
}
|
||||
elseif ($userid == $this->userid){
|
||||
$ok = false;
|
||||
$errortekst .=" U mag de huidige gebruiker niet verwijderen.";
|
||||
}
|
||||
elseif ($this->Filledversions_model->check_for_record(array("user_id"=>$userid , "organisatie_id"=>$orgid)) ||
|
||||
$this->Groepenxusers_model->check_for_record(array("orguser_id"=>$orguser->id)) ){
|
||||
$errortekst .="Er zijn invulgegevens van deze gebruiker; en/of groepen gekoppeld aan deze gebruiker. Gebruiker is gearchiveerd";
|
||||
$this->Autorisaties_model->update_record_where(array("nivo_id"=>100),array("orguser_id"=>$orguser->id));
|
||||
$user = $this->Users_model->getorggebruikers($orgid,$userid);
|
||||
}
|
||||
else {
|
||||
$orguser = $this->Orgusers_model->get_records_where(array("user_id" => $userid, "organisatie_id"=>$orgid), true);
|
||||
$this->Autorisaties_model->delete_record_where(array("orguser_id"=>$orguser->id));
|
||||
$this->Orgusers_model->delete_record($orguser->id);
|
||||
|
||||
// wordt de user nog bij een andere organisatie gebruikt?
|
||||
$orguser=$this->Orgusers_model->get_records_where(array("user_id"=>$userid));
|
||||
if (!$orguser){
|
||||
$this->Users_model->delete_record($userid);
|
||||
}
|
||||
}
|
||||
echo json_encode(array('ok'=>$ok, 'errortekst'=>$errortekst,'user'=>$user));
|
||||
}
|
||||
public function savestatus(){
|
||||
// TODO sanitize input
|
||||
if ($this->Autorisaties_model->check_autorisatie($this->userrole, SUPERUSER) > 0){
|
||||
$userid =$this->clean_input('userid');
|
||||
$status =$this->clean_input('status');
|
||||
$this->Users_model->update_record(array("actief"=>$status), $userid);
|
||||
}
|
||||
}
|
||||
function SendNewWW(){
|
||||
//TODO sanitize input
|
||||
$userid = $this->uri->segment(4);
|
||||
$ok = true;
|
||||
$errortekst = '';
|
||||
|
||||
$user = $this->Users_model->get_record_by_id($userid);
|
||||
$ww = random_string('alnum', 8);
|
||||
$saltedww = md5($user->zout.$ww);
|
||||
// update user
|
||||
$this->Users_model->update_record(array('wachtwoord'=>$saltedww),$userid);
|
||||
$data = array('username'=>$user->gnaam, 'password'=>$ww, 'fullname'=>$this->Users_model->get_fullname($userid));
|
||||
|
||||
$this->load->library('email');
|
||||
|
||||
$this->email->from('noreply@framework.nl', 'Framework+ MonPas');
|
||||
$this->email->to($user->email);
|
||||
$this->email->subject('Inloggegevens MonPas');
|
||||
$this->email->message($this->load->view('emails/newpassword_mail', $data, TRUE));
|
||||
$this->email->bcc("rfranke@framework-ed.nl");
|
||||
$this->email->send();
|
||||
|
||||
echo json_encode(array('ok'=>$ok, 'errortekst'=>$errortekst));
|
||||
}
|
||||
|
||||
function geteigenorgs($valtonderid){
|
||||
|
||||
}
|
||||
private function getswv($orgid){
|
||||
$organisatie =$this->Organisaties_model->get_record_by_id($orgid);
|
||||
if ($organisatie) {
|
||||
if ($organisatie->soort ==1 ) {
|
||||
return $organisatie->id;
|
||||
}
|
||||
else{
|
||||
$orgid = $this->getswv($organisatie->valtonder_id);
|
||||
};
|
||||
}
|
||||
else {
|
||||
return $orgid= null;
|
||||
}
|
||||
return $orgid;
|
||||
}
|
||||
|
||||
function getorglist($orgid,$orglist){
|
||||
|
||||
$orgs = $this->Organisaties_model->getorgsvanaf($orgid);
|
||||
if ($orgs){
|
||||
|
||||
foreach($orgs as $org){
|
||||
if ($org->soort < 4 && $org->soort != 1){
|
||||
$orglist .=$org->id.',';
|
||||
$orglist=$this->getorglist($org->id,$orglist);
|
||||
|
||||
}
|
||||
else {
|
||||
$orglist.= $org->id.',';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $orglist;
|
||||
}
|
||||
|
||||
function getotherusers(){
|
||||
//TODO clean input
|
||||
// haal de gebruikers op van andere organisaties onder het SWV
|
||||
$orgid= $this->uri->segment(4);
|
||||
$swvid = $this->getswv($orgid);
|
||||
$orgids='';
|
||||
|
||||
$orgids = $this->getorglist($swvid, $swvid.',');
|
||||
|
||||
$orgids=substr($orgids, 0, strlen($orgids) - 1);
|
||||
$ousers= $this->Users_model->otherusers($orgid,$orgids);
|
||||
echo json_encode($ousers);
|
||||
}
|
||||
function savecopyuser(){
|
||||
//TODO clean input
|
||||
$userid = $this->input->post("userid");
|
||||
$orgid = $this->input->post("orgid");
|
||||
$data = array( "user_id" => $userid,
|
||||
"organisatie_id" => $orgid);
|
||||
$orguserid = $this->Orgusers_model->insert_record($data);
|
||||
//maak autorisatie
|
||||
$data = array( "nivo_id" =>$this->input->post('autorisatie'),
|
||||
"orguser_id" =>$orguserid);
|
||||
$this->Autorisaties_model->insert_record($data);
|
||||
//get user gegevens om op te nemen in de view
|
||||
$user=$this->Users_model->getorggebruikers($orgid, $userid);
|
||||
echo json_encode($user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user