private function recursivegetpages($parent, $depth) { $output = array(); $pageModel = new pageModel(); $target = new securitytarget(); $target->setId('menu'); $pages = $pageModel->get(array('parentid' => array('mode' => '=', 'value' => $parent)), array('fields' => array('order'), 'type' => 'ASC')); foreach ($pages as $page) { $tmp = array(); if (myacl::isAllowed(myauth::getCurrentuser(), $page, 'view') && myacl::isAllowed($page, $target, 'show', true)) { $tmp['page'] = $page; if ($depth < $this->maxdepth || $this->maxdepth == -1) { $tmp['subpages'] = $this->recursivegetpages($page->getId(), $depth + 1); } if (count($tmp['subpages']) == 0) { unset($tmp['subpages']); $tmp['status_subpages'] = 'nosubpages'; } else { $tmp['status_subpages'] = "subpages"; } if ($page->getId() == myauth::getCurrentpageid()) { $tmp['status'] = 'active'; } elseif (isset($this->tree_id[$page->getId()])) { $tmp['status'] = 'subpage_active'; } else { $tmp['status'] = 'inactive'; } $output[] = $tmp; } } return $output; }
private function resolvePage($pageid, $auth = true) { require FRAMEWORK . DS . 'conf' . DS . 'dispatcher.php'; require FRAMEWORK . DS . 'conf' . DS . 'auth.php'; $currentuser = myauth::getCurrentuser(); $groups = $currentuser->getGroupid(); $groupfound = false; foreach ($groups as $groupname => $groupid) { if (isset($defaultPageids[$groupname])) { $groupfound = true; $defaultPageid = $defaultPageids[$groupname]; } } if (!$groupfound) { $defaultPageid = $defaultPageids['default']; } $pageModel = new pageModel(); try { $page = $pageModel->getfromId($pageid); if (count($page) == 1) { $page = $page[0]; } elseif ($pageid != $defaultPageid) { try { $thepage = $this->resolvePage($defaultPageid); $pageid = $page->getId(); } catch (Exception $e) { //error throw $e; } } else { throw $e; } } catch (Exception $e) { if ($pageid != $defaultPageid) { $pageid = $defaultPageid; // Try the default page try { $page = $this->resolvePage($pageid); $pageid = $page->getId(); } catch (Exception $e) { //error throw $e; } } else { throw $e; } } if ($auth && !myacl::isAllowed(myauth::getCurrentuser(), $page, 'view')) { if (myauth::getCurrentuser()->getId != $defaultUserid && $pageid != $defaultAnonPageid && $pageid != $loginPageid) { $page = $this->resolvePage($defaultAnonPageid); $pageid = $page->getId(); } else { $_SESSION['wantedpage'] = isset($_GET['pageid']) ? $_GET['pageid'] : $defaultPageid; $pageid = $loginPageid; try { $page = $this->resolvePage($pageid, false); } catch (Exception $e) { throw $e; } } } else { if ($page->getRedirectid() != '') { $page = $this->resolvePage($page->getRedirectid()); $pageid = $page->getId(); } } myauth::setCurrentpageid($page->getId()); return $page; }
public function editArticle($parameters = array()) { $view = new ui($this); $articlemodel = new myarticleModel(); $versionmodel = new myarticleversionModel(); $article = $articlemodel->getfromId($parameters['id']); if (count($article) == 1) { $article = $article[0]; $view->assign('article', $article); $aliasform = new mygridform($parameters, $parameters['-gridid-'], 'edit'); $aliasform->addField(new textField('alias', 'Werktitel', $article->getAlias(), array('required'))); $aliasform->addField(new hiddenField('id', $parameters['id'])); $aliasform->addField(new hiddenField('title', $parameters['title'])); if ($aliasform->validate()) { $article->setAlias($aliasform->getFieldvalue('alias')); $flash = new popupController(); try { $articlemodel->save($article); } catch (Exception $e) { $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De aanpassing werd niet doorgevoerd! Contacteer de informaticadienst.')); return false; } $flash->createflash(array('name' => 'error', 'type' => 'success', 'content' => 'De aanpassing werd goed doorgevoerd.')); $gridcontroller = new mygridController(); unset($parameters['hidden_form_id']); $parameters['alias'] = ''; $gridcontroller->editrequest($parameters); return true; } elseif (!$aliasform->isSent()) { $view->assign('aliasform', $aliasform); } else { return false; } $versionsids = $article->getVersion(); $grid = new mygrid('articleversions-' . $article->getId()); $grid->setModel(new myarticleversionModel()); $idcond = array('articleid' => array('mode' => '=', 'value' => $parameters['id'])); $grid->setDefaultconditions($idcond); $grid->setDefaultorder(array('fields' => array('state', 'creationdate'), 'type' => 'DESC')); $grid->registerEditrequest('myarticle', 'editversion', array('id' => '{id}', 'articleid' => $parameters['id'], 'title' => 'Versie aanpassen', 'myacl' => array('target' => $article, 'right' => 'create_newversion', 'default' => false))); $view->assign('grid', $grid); if (myacl::isAllowed(myauth::getCurrentuser(), $article, 'manage_sectionlinks')) { $sectiongrid = new mygrid('sections_' . $article->getId()); $sectiongrid->setModel(new processedmyarticlesectionlinkModel()); $sectiongrid->setDefaultconditions($idcond); $sectiongrid->registerAddrequest('myarticle', 'addsectionlink', array('articleid' => $article->getId(), 'title' => 'Nieuwe sectie linken')); $sectiongrid->registerDeleterequest('myarticle', 'deletesectionlink', array('id' => '{id}', 'title' => 'Link met sectie verwijderen')); $view->assign('sectiongrid', $sectiongrid); } $aclcontroller = new myaclController(); $view->assign('acllist', $aclcontroller->listacl(array('targetoutput' => '_return_', 'objecttype' => 'myarticleObject', 'objectid' => $parameters['id']))); return $view->fetch('myarticle_editarticle.tpl'); } else { return false; } }
public function managepages($parameters = array()) { $view = new ui($this); if (!isset($parameters['parentid'])) { $parentid = 0; } else { $parentid = $parameters['parentid']; } $pagemodel = new pageModel(); if ($parentid != 0) { $currentpage = $pagemodel->getfromId($parentid); if (count($currentpage) == 1) { $currentpage = $currentpage[0]; if (!$parameters['history']) { $this->response->addWaypoint('mypageadmin', 'managepages', 'pageadmin', $parameters); } } } $grid = new mygrid('pagelist_' . $parentid); $grid->setModel($pagemodel); $grid->setDefaultconditions(array('parentid' => array('mode' => '=', 'value' => $parentid))); $grid->setDefaultorder(array('fields' => array('order'), 'type' => 'ASC')); $grid->setOrderfield('order'); $grid->registerRequest('title', 'mypageadmin', 'managepages', array('parentid' => '{id}')); if ($currentpage instanceof pageObject) { $add = myacl::isAllowed(myauth::getCurrentuser(), $currentpage, 'addpage'); } else { $add = myacl::isAllowed(myauth::getCurrentuser(), new securitytarget('pagemanagement'), 'addrootpage'); } if ($add) { $grid->registerAddrequest('mypageadmin', 'addpage', array('title' => 'Pagina toevoegen', 'parentid' => $parentid)); } $view->assign('grid', $grid); $pageid = $currentpage instanceof pageObject ? $currentpage->getId() : -1; $areamodel = new areaModel(); $areas = $areamodel->get(); $modules = array(); $idcond = array('pageid' => array('mode' => '=', 'value' => $pageid)); foreach ($areas as $area) { $areacond = array('areaid' => array('mode' => '=', 'value' => $area->getId())); $grid = new mygrid('modules_page_' . $pageid . '_area_' . $area->getId()); $grid->setModel(new processedmodulepageModel()); $grid->setDefaultconditions(array('AND' => array($idcond, $areacond))); $grid->setDefaultorder(array('fields' => array('order'), 'type' => 'ASC')); $grid->setOrderfield('order'); $grid->registerAddrequest('mypageadmin', 'addmodulepagelink', array('title' => 'Module aan pagina toevoegen', 'areaid' => $area->getId(), 'pageid' => $pageid)); $modules[$area->getName()] = $grid; } $view->assign('modules', $modules); if ($currentpage instanceof pageObject) { $aclcontroller = new myaclController(); $acl = $aclcontroller->listacl(array('targetoutput' => '_return_', 'objecttype' => 'pageObject', 'objectid' => $currentpage->getId())); $view->assign('acl', $acl); $titleform = new form($parameters); $titleform->addField(new textField('title', 'Titel', $currentpage->getTitle(), array('required'))); $titleform->addField(new hiddenField('parentid', $currentpage->getId())); if ($titleform->validate()) { $flash = new popupController(); if ($titleform->getFieldvalue('title') != $currentpage->getTitle()) { $currentpage->setTitle($titleform->getFieldvalue('title')); try { $pagemodel->save($currentpage); } catch (Exception $e) { $flash->createflash(array('name' => 'err', 'type' => 'error', 'content' => 'De gegevens zijn niet goed bewaard! Raadpleeg de informaticadienst.')); return false; } $flash->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De gegevens zijn goed bewaard.')); } else { $flash->createflash(array('name' => 'warning', 'type' => 'warning', 'content' => 'De nieuwe titel is gelijk aan de vorige titel.')); } $view->assign('titleform', $titleform); } elseif (!$titleform->isSent()) { $view->assign('titleform', $titleform); } else { return false; } } $theparentid = $parentid; $path = array(); while ($theparentid != 0) { $parent = $pagemodel->getfromId($theparentid); if (count($parent) == 1) { $parent = $parent[0]; $tmp = array(); $tmp['page'] = $parent; $tmp['request'] = new ajaxrequest('mypageadmin', 'managepages', array('parentid' => $theparentid)); $path[] = $tmp; $theparentid = $parent->getParentid(); } else { $theparentid = 0; } } $rootpage = new pageObject(); $rootpage->setTitle('Root'); $root['page'] = $rootpage; $root['request'] = new ajaxrequest('mypageadmin', 'managepages', array('parentid' => 0)); $path[] = $root; $view->assign('path', array_reverse($path)); $view->assign('currentpage', $currentpage); $this->response->assign($this->self, 'innerHTML', $view->fetch('mypageadmin_managepages.tpl')); }
public function deletegast($parameters) { $gastid = $parameters['gastid']; $popupcontroller = new popupController(); $gastModel = new ingeschrevenModel(); $gast = $gastModel->getfromId($gastid); if (count($gast) == 1) { $gast = $gast[0]; } else { return; } $sure = $parameters['sure']; if ($sure != 'sure') { $template = new ui($this); $template->assign('gast', $gast); $ja = new ajaxrequest('myvoorinschrijving', 'deletegast', array('gastid' => $gastid, 'sure' => 'sure')); $template->assign('ja', $ja); $popupcontroller->create(array('name' => 'confirm', 'content' => $template->fetch('myvoorinschrijving_confirmdelete.tpl'))); } elseif (myacl::isAllowed(myauth::getCurrentuser(), $gast, 'delete')) { $popupcontroller->destroy(array('name' => 'confirm')); $gastModel->deletebyId($gastid); $this->response->remove($gastid . '_rij'); } }
public function showstatus($parameters = array()) { $view = new ui($this); $dienstmodel = new keukendienstModel(); $kamermodel = new keukenkamerModel(); $diensten = $dienstmodel->get(); $adiensten = array(); $kamercond = array(); foreach ($diensten as $dienst) { if (myacl::isAllowed(myauth::getCurrentuser(), $dienst, 'view')) { $adiensten[$dienst->getId()] = $dienst; } } if (count($adiensten > 1)) { $form = new form($parameters); $select = new selectField('dienst', 'Dienst', array('required'), true); $select->addOption(new selectoptionField('Alles', '_all_', true)); foreach ($adiensten as $id => $dienst) { $select->addOption(new selectoptionField($dienst->getName(), $id)); } $form->addField($select); $continue = true; if ($form->validate()) { $all = false; foreach ($form->getFieldvalue('dienst') as $id) { $chosendienst[$id] = $adiensten[$id]; if ($id == '_all_') { $all = true; break; } } if (!$all) { $adiensten = $chosendienst; } $view->assign('form', $form); } elseif (!$form->isSent()) { $view->assign('form', $form); } else { $continue = false; } } if ($continue) { foreach ($adiensten as $id => $dienst) { $kamers = $kamermodel->getfromDienstid($id); foreach ($kamers as $kamer) { $kamercond[] = array('kamer' => array('mode' => '=', 'value' => $kamer->getKamernr())); } } if (count($kamercond) > 0) { $kamercond = array('OR' => $kamercond); } else { //Geen kamers, lege lijst voorzien $kamercond = array('kamer' => array('mode' => '=', 'value' => '-1')); } $model = new keukenpatientModel(); $count = $model->getcount($kamercond); $view->assign('count', $count); $grid = new mygrid('keukenstatus'); $grid->setModel($model); $grid->setDefaultconditions($kamercond); $grid->setDefaultorder(array('fields' => array('kamer', 'bed'), 'type' => 'ASC')); $grid->registerEditrequest('keukenpakket', 'editPatient', array('title' => 'Maaltijdfiche aanpassen', 'id' => '{id}')); $grid->setPagesize(999); $view->assign('grid', $grid); $this->response->assign($this->self, 'innerHTML', $view->fetch('keukenpakket_showstatus.tpl')); } }
public function getRequest($column, $object = NULL) { if (isset($this->request[$column])) { foreach ($this->request[$column]['parameters'] as $key => $param) { $matches = array(); if (preg_match("/(\\{)(.*)(\\})/", $param, $matches)) { if (is_object($object) && $matches[2] != 'this') { $param = $object->_get($matches[2]); } else { return false; } } $params[$key] = $param; } $params['-gridid-'] = $this->getId(); if (isset($this->request[$column]['parameters']['myacl'])) { $acl = $this->request[$column]['parameters']['myacl']; if ($acl['target'] == '{this}' && is_object($object)) { $acl['target'] = $object; } if (myacl::isAllowed(myauth::getCurrentuser(), $acl['target'], $acl['right'], $acl['default'])) { return new ajaxrequest($this->request[$column]['controller'], $this->request[$column]['action'], $params); } else { return false; } } else { return new ajaxrequest($this->request[$column]['controller'], $this->request[$column]['action'], $params); } } else { return false; } }
public function listTicketstome($parameters = array()) { require FRAMEWORK . DS . 'conf' . DS . 'myticket.php'; $view = new ui($this); $mdienstenmodel = new meldingdienstenModel(); $mdiensten = $mdienstenmodel->get(); foreach ($mdiensten as $dienst) { if (myacl::isAllowed(myauth::getCurrentuser(), $dienst, 'view')) { $diensten[$dienst->getId()] = $dienst; } } asort($diensten); foreach ($diensten as $id => $dienst) { $tmp = new mygrid('myticketstome_' . $id); $tmp->setModel(new myticketModel()); $tmp->setDefaultpagesize(15); $cond = array('to' => array('mode' => '=', 'value' => $dienst->getId())); $tmp->setDefaultconditions($cond); $tmp->setDefaultorder(array('fields' => array('time'), 'type' => 'DESC')); $tmp->registerRequest('titel', 'myticket', 'showticket', array('id' => '{id}')); $tickets[$dienst->getName()] = $tmp; } $view->assign('tickets', $tickets); $this->response->assign($this->self, 'innerHTML', $view->fetch('myticket_listmytickets.tpl')); }
public function addacl($parameters) { include FRAMEWORK . DS . 'conf' . DS . 'myacl.php'; $view = new ui($this); $form = new mygridform($parameters, $parameters['-gridid-'], 'edit'); $objecttype = $parameters['objecttype']; $objectid = $parameters['objectid']; $form->addField(new suggestselectField('myacl', 'getRequesterlist', 'requester', 'Aanvrager', '', array('required'), array('objectype' => $objecttype != 'securitytarget' ? $objecttype : $objectid))); if ($objecttype == 'securitytarget') { $rights = $myacl[$objectid]['rights']; } else { $rights = $myacl[$objecttype]['rights']; } $object = new $objecttype(); $object->setId($objectid); if (myacl::isAllowed(myauth::getCurrentuser(), $object, '_ALL_')) { $form->addField(new checkboxField('form_all', 'Full control', '_ALL_', false)); $form->addField(new checkboxField('form_managerights', 'Rechten beheren', 'managerights', false)); } foreach ($rights as $right => $rightconf) { $form->addField(new checkboxField('form_' . $right, $rightconf['description'], $right, false)); } $form->addField(new hiddenField('objecttype', $objecttype)); $form->addField(new hiddenField('objectid', $objectid)); $form->addField(new hiddenField('module', $parameters['module'])); if ($form->validate()) { $requestertypes = $myacl[$objecttype != 'securitytarget' ? $objecttype : $objectid]['requesters']; $requesters = array(); foreach ($form->getFieldvalue('requester') as $requestername) { foreach ($requestertypes as $type => $conf) { $modelname = str_replace('Object', 'Model', $type); $model = new $modelname(); $func = $conf['getfunction']; $res = $model->{$func}($requestername); if (count($res) == 1) { $requesters[] = $res[0]; break; } } } $selectedrights = array(); if ($form->getFieldvalue('form_all') == '_ALL_') { $selectedrights['_ALL_'] = '_ALL_'; } else { if ($form->getFieldvalue('form_managerights') == 'managerights') { $selectedrights['managerights'] = 'managerights'; } foreach ($rights as $right => $rightconf) { if ($form->getFieldvalue('form_' . $right) == $right) { $selectedrights[$right] = $right; if (isset($rightconf['requires'])) { foreach ($rightconf['requires'] as $required) { $selectedrights[$required] = $required; } } } } } try { $object = new $objecttype(); $object->setId($objectid); foreach ($requesters as $requester) { foreach ($selectedrights as $selectedright) { myacl::setAcl($requester, $object, $selectedright, 1); } } } catch (Exception $e) { $flash = new popupController(); $flash->createflash(array('name' => 'err', 'type' => 'error', 'content' => 'De gegevens zijn niet goed doorgevoerd! Raadpleeg de informaticadienst.')); return false; } $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', ''); $flash = new popupController(); $flash->createflash(array('name' => 's', 'type' => 'success', 'content' => 'De gegevens zijn goed doorgevoerd.')); return true; } elseif (!$form->isSent()) { $view->assign('form', $form); return $view->fetch('myacl_addacl.tpl'); } }
public function showspecdetails($parameters = array()) { $view = new ui($this); $specmodel = new wdokterspecialismeModel(); $spec = $specmodel->getfromId($parameters['specid']); if (count($spec) == 1) { $spec = $spec[0]; $view->assign('specialisme', $spec); $closerequest = new ajaxrequest('mydoktervanwacht', 'showoverzicht', array()); $view->assign('closerequest', $closerequest); if ($parameters['history'] != 'history') { $this->response->addWaypoint('mydoktervanwacht', 'showspecdetails', uniqid(), array('specid' => $parameters['specid'], 'startofmonth' => $parameters['startofmonth'], 'endofmonth' => $parameters['endofmonth'])); } $output = array(); $startofmonth = isset($parameters['startofmonth']) ? $parameters['startofmonth'] : mktime(00, 00, 00, date('m'), 01, date('Y')); $endofmonth = isset($parameters['endofmonth']) ? $parameters['endofmonth'] : mktime(00, 00, 00, date('m') + 1, 01, date('Y')) - 1; $wachtdokterModel = new wachtdokterviewModel(); $speccond = array('specialisme' => array('mode' => '=', 'value' => $parameters['specid'])); for ($i = $startofmonth; $i < $endofmonth; $i += 86400) { $start = array('start' => array('mode' => 'BETWEEN', 'value' => $i + 1, 'topvalue' => $i + 86400 - 1)); $stop = array('stop' => array('mode' => 'BETWEEN', 'value' => $i, 'topvalue' => $i + 86400 - 1)); $big = array('AND' => array(array('start' => array('mode' => '<', 'value' => $i + 1)), array('stop' => array('mode' => '>', 'value' => $i + 86400 - 1)))); $cond = array('OR' => array($start, $stop, $big)); $dokters = $wachtdokterModel->get(array('AND' => array($speccond, $cond)), array('fields' => array('start'), 'type' => 'ASC')); $outputdokters = array(); foreach ($dokters as $dokter) { $tmpdok = array(); $tmpdok['dokter'] = $dokter; if (myacl::isAllowed(myauth::getCurrentuser(), $spec, 'managewacht')) { if ($dokter->getStart() > $i - 1) { $tmpdok['request'] = new ajaxrequest('mydoktervanwacht', 'deletedoktervanwacht', array('id' => $dokter->getId(), 'specid' => $parameters['specid'], 'startofmonth' => $startofmonth, 'endofmonth' => $endofmonth)); } } $outputdokters[] = $tmpdok; } $tmp = array(); $tmp['dokters'] = $outputdokters; $tmp['start'] = $i; if (myacl::isAllowed(myauth::getCurrentuser(), $spec, 'managewacht')) { $tmp['addrequest'] = new ajaxrequest('mydoktervanwacht', 'adddoktervanwacht', array('specid' => $parameters['specid'], 'startofmonth' => $startofmonth, 'endofmonth' => $endofmonth, 'start' => $tmp['start'])); } $output[] = $tmp; } $view->assign('list', $output); $prevmonth = date('m', $startofmonth) - 1 < 1 ? 12 : date('m', $startofmonth) - 1; $prevyear = date('m', $startofmonth) - 1 < 1 ? date('Y', $startofmonth) - 1 : date('Y', $startofmonth); $startofprevmonth = mktime(00, 00, 00, $prevmonth, 01, $prevyear); $endofprevmonth = $startofmonth - 1; $prevrequest = new ajaxrequest('mydoktervanwacht', 'showspecdetails', array('specid' => $parameters['specid'], 'startofmonth' => $startofprevmonth, 'endofmonth' => $endofprevmonth)); $view->assign('prevrequest', $prevrequest); $nextmonth = date('m', $startofmonth) + 1 > 12 ? 1 : date('m', $startofmonth) + 1; $nextyear = date('m', $startofmonth) + 1 > 12 ? date('Y', $startofmonth) + 1 : date('Y', $startofmonth); $startofnextmonth = $endofmonth + 1; $endofnextmonth = mktime(00, 00, 00, $nextmonth + 1, 01, $nextyear) - 1; $nextrequest = new ajaxrequest('mydoktervanwacht', 'showspecdetails', array('specid' => $parameters['specid'], 'startofmonth' => $startofnextmonth, 'endofmonth' => $endofnextmonth)); $view->assign('nextrequest', $nextrequest); $this->response->assign($this->self, 'innerHTML', $view->fetch('mydoktervanwacht_specdetails.tpl')); if (myacl::isAllowed(myauth::getCurrentuser(), $spec, 'managerights')) { $aclcontroller = new myaclController(); $aclcontroller->listacl(array('targetoutput' => 'acllist_wachtdokter_' . $parameters['specid'], 'objecttype' => 'wdokterspecialismeObject', 'objectid' => $parameters['specid'])); } } }