/** * Developer dashboard * * @param \thebuggenie\core\framework\Request $request */ public function runDashboard(framework\Request $request) { $this->forward403unless(!$this->getUser()->isThisGuest() && $this->getUser()->hasPageAccess('dashboard')); if (framework\Settings::isSingleProjectTracker()) { if (($projects = entities\Project::getAll()) && ($project = array_shift($projects))) { framework\Context::setCurrentProject($project); } } if ($request['dashboard_id']) { $dashboard = entities\Dashboard::getB2DBTable()->selectById((int) $request['dashboard_id']); if ($dashboard->getType() == entities\Dashboard::TYPE_PROJECT && !$dashboard->getProject()->hasAccess()) { unset($dashboard); } elseif ($dashboard->getType() == entities\Dashboard::TYPE_USER && $dashboard->getUser()->getID() != framework\Context::getUser()->getID()) { unset($dashboard); } } if (!isset($dashboard) || !$dashboard instanceof entities\Dashboard) { $dashboard = $this->getUser()->getDefaultDashboard(); } if ($request->isPost()) { switch ($request['mode']) { case 'add_view': $sort_order = 1; foreach ($dashboard->getViews() as $view) { if ($view->getColumn() == $request['column']) { $sort_order++; } } $view = new entities\DashboardView(); $view->setDashboard($dashboard); $view->setType($request['view_type']); $view->setDetail($request['view_subtype']); $view->setColumn($request['column']); $view->setSortOrder($sort_order); $view->save(); framework\Context::setCurrentProject($view->getProject()); return $this->renderJSON(array('view_content' => $this->getComponentHTML('main/dashboardview', array('view' => $view, 'show' => false)), 'view_id' => $view->getID())); case 'remove_view': $deleted = 0; foreach ($dashboard->getViews() as $view) { if ($view->getID() == $request['view_id']) { $deleted = $view->getID(); $view->delete(); } } return $this->renderJSON(array('deleted_view' => $deleted)); } } $this->dashboard = $dashboard; }
protected function _postSave($is_new) { if ($is_new) { switch ($this->getType()) { case self::TYPE_USER: $dv_issues = new DashboardView(); $dv_issues->setDashboard($this); $dv_issues->setColumn(1); $dv_issues->setType(DashboardView::VIEW_PROJECTS); $dv_issues->setDetail(0); $dv_issues->save(); $dv_logged = new DashboardView(); $dv_logged->setDashboard($this); $dv_logged->setColumn(2); $dv_logged->setType(DashboardView::VIEW_LOGGED_ACTIONS); $dv_logged->setDetail(0); $dv_logged->save(); break; case self::TYPE_PROJECT: $dv_project_info = new DashboardView(); $dv_project_info->setDashboard($this); $dv_project_info->setColumn(1); $dv_project_info->setType(DashboardView::VIEW_PROJECT_INFO); $dv_project_info->setDetail(0); $dv_project_info->save(); $dv_project_team = new DashboardView(); $dv_project_team->setDashboard($this); $dv_project_team->setColumn(1); $dv_project_team->setType(DashboardView::VIEW_PROJECT_TEAM); $dv_project_team->setDetail(0); $dv_project_team->save(); $dv_project_statistics = new DashboardView(); $dv_project_statistics->setDashboard($this); $dv_project_statistics->setColumn(2); $dv_project_statistics->setType(DashboardView::VIEW_PROJECT_STATISTICS_LAST15); $dv_project_statistics->setDetail(0); $dv_project_statistics->save(); $dv_project_activities = new DashboardView(); $dv_project_activities->setDashboard($this); $dv_project_activities->setColumn(2); $dv_project_activities->setType(DashboardView::VIEW_PROJECT_RECENT_ACTIVITIES); $dv_project_activities->setDetail(0); $dv_project_activities->save(); break; } } }