/** * Forward the user with HTTP status code 403 and an (optional) message * based on a boolean check * * @param boolean $condition * @param string $message [optional] The message */ public function forward403unless($condition, $message = null) { if (!$condition) { $message = $message === null ? Context::getI18n()->__("You are not allowed to access this page") : htmlentities($message); if (Context::getUser()->isGuest()) { Context::setMessage('login_message_err', $message); Context::setMessage('login_force_redirect', true); Context::setMessage('login_referer', Context::getRouting()->generate(Context::getRouting()->getCurrentRouteName(), Context::getRequest()->getParameters())); $this->forward(Context::getRouting()->generate('login_page'), 403); } else { $this->getResponse()->setHttpStatus(403); $this->getResponse()->setTemplate('main/forbidden'); } } }
/** * Return the i18n object * * @return \thebuggenie\core\framework\I18n */ protected function getI18n() { return Context::getI18n(); }
public function getPredefinedBreadcrumbLinks($type, $project = null) { $i18n = Context::getI18n(); $links = array(); switch ($type) { case 'main_links': $links[] = array('url' => Context::getRouting()->generate('home'), 'title' => $i18n->__('Frontpage')); $links[] = array('url' => Context::getRouting()->generate('dashboard'), 'title' => $i18n->__('Personal dashboard')); $links[] = array('title' => $i18n->__('Issues')); if (Context::getUser()->hasPageAccess('teamlist')) { $links[] = array('url' => make_url('team_list'), 'title' => $i18n->__('Teams')); } if (Context::getUser()->hasPageAccess('clientlist')) { $links[] = array('url' => make_url('client_list'), 'title' => $i18n->__('Clients')); } $links = Event::createNew('core', 'breadcrumb_main_links', null, array(), $links)->trigger()->getReturnList(); if (Context::getUser()->canAccessConfigurationPage()) { $links[] = array('url' => make_url('configure'), 'title' => $i18n->__('Configure %sitename', array('%sitename' => Settings::getSiteHeaderName()))); } $links[] = array('url' => Context::getRouting()->generate('about'), 'title' => $i18n->__('About %sitename', array('%sitename' => Settings::getSiteHeaderName()))); $links[] = array('url' => Context::getRouting()->generate('account'), 'title' => $i18n->__('Account details')); $root_projects = array_merge(\thebuggenie\core\entities\Project::getAllRootProjects(true), \thebuggenie\core\entities\Project::getAllRootProjects(false)); $first = true; foreach ($root_projects as $project) { if (!$project->hasAccess()) { continue; } if ($first) { $first = false; $links[] = array('separator' => true); } $links[] = array('url' => Context::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $project->getName()); } break; case 'project_summary': $links['project_dashboard'] = array('url' => Context::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $i18n->__('Dashboard')); $links['project_releases'] = array('url' => Context::getRouting()->generate('project_releases', array('project_key' => $project->getKey())), 'title' => $i18n->__('Releases')); $links['project_roadmap'] = array('url' => Context::getRouting()->generate('project_roadmap', array('project_key' => $project->getKey())), 'title' => $i18n->__('Roadmap')); $links['project_team'] = array('url' => Context::getRouting()->generate('project_team', array('project_key' => $project->getKey())), 'title' => $i18n->__('Team overview')); $links['project_statistics'] = array('url' => Context::getRouting()->generate('project_statistics', array('project_key' => $project->getKey())), 'title' => $i18n->__('Statistics')); $links['project_timeline'] = array('url' => Context::getRouting()->generate('project_timeline', array('project_key' => $project->getKey())), 'title' => $i18n->__('Timeline')); $links['project_issues'] = array('url' => Context::getRouting()->generate('project_issues', array('project_key' => $project->getKey())), 'title' => $i18n->__('Issues')); $links = Event::createNew('core', 'breadcrumb_project_links', null, array(), $links)->trigger()->getReturnList(); $links['project_release_center'] = array('url' => Context::getRouting()->generate('project_release_center', array('project_key' => $project->getKey())), 'title' => $i18n->__('Release center')); $links['project_settings'] = array('url' => Context::getRouting()->generate('project_settings', array('project_key' => $project->getKey())), 'title' => $i18n->__('Settings')); break; case 'client_list': foreach (\thebuggenie\core\entities\Client::getAll() as $client) { if ($client->hasAccess()) { $links[] = array('url' => Context::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName()); } } break; case 'team_list': foreach (\thebuggenie\core\entities\Team::getAll() as $team) { if ($team->hasAccess()) { $links[] = array('url' => Context::getRouting()->generate('team_dashboard', array('team_id' => $team->getID())), 'title' => $team->getName()); } } break; case 'configure': $config_sections = Settings::getConfigSections($i18n); foreach ($config_sections as $key => $sections) { foreach ($sections as $section) { if ($key == Settings::CONFIGURATION_SECTION_MODULES) { $url = is_array($section['route']) ? make_url($section['route'][0], $section['route'][1]) : make_url($section['route']); $links[] = array('url' => $url, 'title' => $section['description']); } else { $links[] = array('url' => make_url($section['route']), 'title' => $section['description']); } } } break; } return $links; }
public function getPredefinedBreadcrumbLinks($type, $project = null) { $i18n = Context::getI18n(); $links = array(); switch ($type) { case 'main_links': $links[] = array('url' => Context::getRouting()->generate('home'), 'title' => $i18n->__('Frontpage')); $links[] = array('url' => Context::getRouting()->generate('dashboard'), 'title' => $i18n->__('Personal dashboard')); $links[] = array('title' => $i18n->__('Issues')); $links[] = array('title' => $i18n->__('Teams')); $links[] = array('title' => $i18n->__('Clients')); $links = Event::createNew('core', 'breadcrumb_main_links', null, array(), $links)->trigger()->getReturnList(); if (Context::getUser()->canAccessConfigurationPage()) { $links[] = array('url' => make_url('configure'), 'title' => $i18n->__('Configure %sitename', array('%sitename' => Settings::getSiteHeaderName()))); } $links[] = array('url' => Context::getRouting()->generate('about'), 'title' => $i18n->__('About %sitename', array('%sitename' => Settings::getSiteHeaderName()))); $links[] = array('url' => Context::getRouting()->generate('account'), 'title' => $i18n->__('Account details')); break; case 'project_summary': $links['project_dashboard'] = array('url' => Context::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $i18n->__('Dashboard')); $links['project_releases'] = array('url' => Context::getRouting()->generate('project_release_center', array('project_key' => $project->getKey())), 'title' => $i18n->__('Releases')); $links['project_roadmap'] = array('url' => Context::getRouting()->generate('project_roadmap', array('project_key' => $project->getKey())), 'title' => $i18n->__('Roadmap')); $links['project_team'] = array('url' => Context::getRouting()->generate('project_team', array('project_key' => $project->getKey())), 'title' => $i18n->__('Team overview')); $links['project_statistics'] = array('url' => Context::getRouting()->generate('project_statistics', array('project_key' => $project->getKey())), 'title' => $i18n->__('Statistics')); $links['project_timeline'] = array('url' => Context::getRouting()->generate('project_timeline', array('project_key' => $project->getKey())), 'title' => $i18n->__('Timeline')); $links['project_issues'] = array('url' => Context::getRouting()->generate('project_issues', array('project_key' => $project->getKey())), 'title' => $i18n->__('Issues')); $links = Event::createNew('core', 'breadcrumb_project_links', null, array(), $links)->trigger()->getReturnList(); $links['project_release_center'] = array('url' => Context::getRouting()->generate('project_release_center', array('project_key' => $project->getKey())), 'title' => $i18n->__('Release center')); $links['project_settings'] = array('url' => Context::getRouting()->generate('project_settings', array('project_key' => $project->getKey())), 'title' => $i18n->__('Settings')); break; case 'client_list': foreach (\thebuggenie\core\entities\Client::getAll() as $client) { if ($client->hasAccess()) { $links[] = array('url' => Context::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName()); } } break; case 'team_list': foreach (\thebuggenie\core\entities\Team::getAll() as $team) { if ($team->hasAccess()) { $links[] = array('url' => Context::getRouting()->generate('team_dashboard', array('team_id' => $team->getID())), 'title' => $team->getName()); } } break; } return $links; }
/** * Forward the user with HTTP status code 403 and an (optional) message * based on a boolean check * * @param boolean $condition * @param string $message [optional] The message */ public function forward403unless($condition, $message = null) { if (!$condition) { $message = $message === null ? Context::getI18n()->__("You are either not allowed to access this page or don't have access to perform this action") : $message; if (Context::getUser()->isGuest()) { Context::setMessage('login_message_err', htmlentities($message)); Context::setMessage('login_force_redirect', true); Context::setMessage('login_referer', Context::getRouting()->generate(Context::getRouting()->getCurrentRouteName(), Context::getRequest()->getParameters())); $this->forward(Context::getRouting()->generate('login_page'), Response::HTTP_STATUS_FORBIDDEN); } elseif (Context::getRequest()->isAjaxCall()) { $this->getResponse()->setHttpStatus(Response::HTTP_STATUS_FORBIDDEN); throw new \Exception($message); } else { throw new \thebuggenie\core\framework\exceptions\ActionNotAllowedException($message); } } }