private function prepare($action) { $this->start = microtime(); $this->adapters = $this->helper->getAdapters(); $this->settings = $this->helper->getSettings(); \Admin\Core\API::set("classShortNames", $this->compileShortNames()); \Admin\Core\API::set("action", $action); if ($this->request->hasArgument("being")) { $this->being = $this->request->getArgument("being"); if (!stristr($this->being, "\\")) { $this->being = \Admin\Core\API::get("classShortNames", $this->being); } \Admin\Core\API::set("being", $this->being); $this->adapter = $this->helper->getAdapterByBeing($this->being); \Admin\Core\API::set("adapter", $this->adapter); $this->group = $this->helper->getGroupByBeing($this->being); \Admin\Core\API::set("group", $this->group); } if ($this->request->hasArgument("id")) { $this->id = $this->request->getArgument("id"); if (is_array($this->id)) { $this->id = implode(",", $this->id); } } $user = $this->securityManager->getUser(); if (!isset($user) || !is_object($user)) { $this->securityManager->redirectToLogin(); } else { $allowedBeings = array("view" => array()); try { foreach ($user->getRoles() as $role) { foreach ($role->getGrant() as $policy) { $allowedBeings[$policy->getAction()][] = $policy->getBeing(); } } } catch (\Doctrine\ORM\EntityNotFoundException $e) { unset($user); $this->securityManager->redirectToLogin(); } $this->user = $user; } $groups = $this->helper->getGroups(); ksort($groups); foreach ($groups as $package => $group) { foreach ($group["beings"] as $key => $being) { if (!in_array($being["being"], $allowedBeings["view"])) { if (!$user->isAdmin()) { unset($groups[$package]["beings"][$key]); } } if (!empty($this->adapter)) { if ($being["being"] == $this->being && $being["adapter"] == $this->adapter) { $groups[$package]["beings"][$key]["active"] = true; } else { $groups[$package]["beings"][$key]["active"] = false; } } } if (empty($groups[$package]["beings"])) { unset($groups[$package]); } } $this->view = $this->resolveView(); \Admin\Core\API::set("user", $user); if ($this->view !== NULL) { $this->view->assign('settings', $this->settings); $this->initializeView($this->view); } $this->view->assign('groups', $groups); $this->setTemplate($action); $context = getenv("FLOW3_CONTEXT") ? getenv("FLOW3_CONTEXT") : "Production"; $this->view->assign("context", $context); $hasId = isset($this->id) ? true : false; $topBarActions = $this->getActions($action, $this->being, $hasId); $this->view->assign('topBarActions', $topBarActions); }