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; }
protected function fillObject($data) { $object = parent::fillObject($data); $areamodel = new areaModel(); $areas = $areamodel->getfromId($object->getAreaid()); if (count($areas) == 1) { $object->setAreaname($areas[0]->getName()); } $pagemodel = new pageModel(); $pages = $pagemodel->getfromId($object->getPageid()); if (count($pages) == 1) { $object->setPagename($pages[0]->getTitle()); } $modulemodel = new moduleModel(); $modules = $modulemodel->getfromId($object->getModuleid()); if (count($modules) == 1) { $module = $modules[0]; $object->setModuletitle($module->getTitle()); $object->setModulename($module->getName()); $object->setModuleaction($module->getAction()); $args = $module->getArguments(); $contr = new mymoduleadminController(); $options = $contr->getOptions($module->getName(), $module->getAction()); foreach ($args as $key => $value) { if (isset($options[$key][$value])) { $value = $options[$key][$value]; } $arguments .= '<strong>' . $key . ': </strong> ' . $value . '<br />'; } $object->setModuleargs($arguments); } return $object; }
public function deletemodule($parameters = array()) { $view = new ui($this); $flash = new popupController(); $model = new processedmoduleModel(); $modules = $model->getfromId($parameters['moduleid']); if (count($modules) == 1) { $module = $modules[0]; $linkmodel = new modulepageModel(); $links = $linkmodel->getfromModuleid($parameters['moduleid']); $pages = array(); if (count($links) > 0) { $all = false; foreach ($links as $link) { $pageids[] = $link->getPageid(); if ($link->getPageid() == -1) { $all = true; } } $pagemodel = new pageModel(); $pages = $pagemodel->get(array('id' => array('mode' => 'IN', 'value' => $pageids))); if ($all) { $newpage = new pageObject(); $newpage->setId(-1); $newpage->setTitle('Alle pagina\'s'); array_unshift($pages, $newpage); } } if ($parameters['sure'] == 'sure') { try { $linkmodel->deletebyModuleid($parameters['moduleid']); $model->delete($module); } catch (Exception $e) { $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De module werd niet goed verwijderd!')); return false; } $flash->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De module werd goed verwijderd.')); $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', ''); return true; } else { $view->assign('module', $module); $view->assign('pages', $pages); return $view->fetch('mymoduleadmin_deletemodule.tpl'); } } else { $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De module werd niet gevonden!')); return false; } }
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 addpage($parameters = array()) { $view = new ui($this); $form = new mygridform($parameters, $parameters['-gridid-'], 'edit'); $form->addField(new hiddenField('parentid', $parameters['parentid'])); $form->addField(new textField('title', 'Titel', '', array('required'))); if ($form->validate()) { $pagemodel = new pageModel(); $newpage = new pageObject(); $newpage->setTemplate('page.tpl'); $newpage->setParentid($parameters['parentid']); $newpage->setTitle($parameters['title']); $newpage->setOrder($pagemodel->getmax('order', array('parentid' => array('mode' => '=', 'value' => $parameters['parentid']))) + 1); $flash = new popupController(); try { $pagemodel->save($newpage); } 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.')); $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', ''); return true; } elseif (!$form->isSent()) { $view->assign('form', $form); return $view->fetch('mypageadmin_addpage.tpl'); } }