예제 #1
0
 /**
  * The project dashboard
  *
  * @param framework\Request $request
  */
 public function runDashboard(framework\Request $request)
 {
     $this->forward403unless($this->_checkProjectPageAccess('project_dashboard'));
     if ($request->isPost() && $request['setup_default_dashboard'] && $this->getUser()->canEditProjectDetails($this->selected_project)) {
         entities\DashboardView::getB2DBTable()->setDefaultViews($this->selected_project->getID(), entities\DashboardView::TYPE_PROJECT);
         $this->forward($this->getRouting()->generate('project_dashboard', array('project_key' => $this->selected_project->getKey())));
     }
     if ($request['dashboard_id']) {
         foreach ($this->selected_project->getDashboards() as $db) {
             if ($db->getID() == (int) $request['dashboard_id']) {
                 $dashboard = $db;
                 break;
             }
         }
     }
     if (!isset($dashboard) || !$dashboard instanceof entities\Dashboard) {
         $dashboard = $this->selected_project->getDefaultDashboard();
     }
     $this->dashboard = $dashboard;
 }
예제 #2
0
 protected function _upgradeFrom3dot2(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable());
     \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable());
     \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable());
     \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable());
     \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable());
     \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable());
     \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable());
     \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable());
     \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable());
     \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable());
     \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable());
     \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable());
     \thebuggenie\core\entities\Dashboard::getB2DBTable()->create();
     \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable());
     \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create();
     \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create();
     $transaction = \b2db\Core::startTransaction();
     // Upgrade user passwords
     switch ($request['upgrade_passwords']) {
         case 'manual':
             $password = $request['manual_password'];
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 $user->setPassword($password);
                 $user->save();
             }
             break;
         case 'auto':
             $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email';
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 if ($field == 'username' && trim($user->getUsername())) {
                     $user->setPassword(trim($user->getUsername()));
                     $user->save();
                 } elseif ($field == 'email' && trim($user->getEmail())) {
                     $user->setPassword(trim($user->getEmail()));
                     $user->save();
                 }
             }
             break;
     }
     $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1);
     $adminuser->setPassword($request['admin_password']);
     $adminuser->save();
     // Add new settings
     framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1);
     foreach ($request->getParameter('status') as $scope_id => $status_id) {
         $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id);
         if ($scope instanceof \thebuggenie\core\entities\Scope) {
             $epic = new \thebuggenie\core\entities\Issuetype();
             $epic->setName('Epic');
             $epic->setIcon('epic');
             $epic->setDescription('Issue type suited for entering epics');
             $epic->setScope($scope_id);
             $epic->save();
             framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id);
             foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) {
                 $transition = new \thebuggenie\core\entities\WorkflowTransition();
                 $steps = $workflow->getSteps();
                 $step = array_shift($steps);
                 $step->setLinkedStatusID((int) $status_id);
                 $step->save();
                 $transition->setOutgoingStep($step);
                 $transition->setName('Issue created');
                 $transition->setWorkflow($workflow);
                 $transition->setScope($scope);
                 $transition->setDescription('This is the initial transition for issues using this workflow');
                 $transition->save();
                 $workflow->setInitialTransition($transition);
                 $workflow->save();
             }
             \thebuggenie\core\entities\ActivityType::loadFixtures($scope);
         }
     }
     $transaction->commitAndEnd();
     framework\Context::finishUpgrading();
     foreach (framework\Context::getModules() as $module) {
         $module->upgrade();
     }
     $this->upgrade_complete = true;
 }
예제 #3
0
 public function runDashboardView(framework\Request $request)
 {
     $view = entities\DashboardView::getB2DBTable()->selectById($request['view_id']);
     if (!$view instanceof entities\DashboardView) {
         return $this->renderJSON(array('content' => 'invalid view'));
     }
     if ($view->getTargetType() == entities\DashboardView::TYPE_PROJECT) {
         framework\Context::setCurrentProject($view->getDashboard()->getProject());
     }
     return $this->renderJSON(array('content' => $this->returnComponentHTML($view->getTemplate(), array('view' => $view))));
 }
예제 #4
0
 public function componentAddDashboardView()
 {
     $request = framework\Context::getRequest();
     $this->dashboard = entities\Dashboard::getB2DBTable()->selectById($request['dashboard_id']);
     $this->column = $request['column'];
     $this->views = entities\DashboardView::getAvailableViews($this->dashboard->getType());
     $this->savedsearches = tables\SavedSearches::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(framework\Context::getUser()->getID(), $this->dashboard->getProject() instanceof entities\Project ? $this->dashboard->getProject()->getID() : 0);
 }
예제 #5
0
 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;
         }
     }
 }