Exemple #1
0
 /**
  * Populates visible milestones inside the project
  *
  * @return void
  */
 protected function _populateVisibleMilestones()
 {
     if ($this->_visible_milestones === null) {
         $this->_visible_milestones = array();
         if ($res = tables\VisibleMilestones::getTable()->getAllByProjectID($this->getID())) {
             while ($row = $res->getNextRow()) {
                 try {
                     $milestone = new \thebuggenie\core\entities\Milestone($row->get(tables\Milestones::ID), $row);
                     if ($milestone->hasAccess()) {
                         $this->_visible_milestones[$milestone->getID()] = $milestone;
                     }
                 } catch (\Exception $e) {
                 }
             }
         }
     }
 }
Exemple #2
0
 /**
  * Milestone actions
  *
  * @Route(url="/milestone/:milestone_id/*")
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runMilestone(framework\Request $request)
 {
     $milestone_id = $request['milestone_id'] ? $request['milestone_id'] : null;
     $milestone = new \thebuggenie\core\entities\Milestone($milestone_id);
     try {
         if (!$this->getUser()->canManageProject($this->selected_project) || !$this->getUser()->canManageProjectReleases($this->selected_project)) {
             throw new \Exception($this->getI18n()->__("You don't have access to modify milestones"));
         }
         switch (true) {
             case $request->isDelete():
                 $milestone->delete();
                 $no_milestone = new \thebuggenie\core\entities\Milestone(0);
                 $no_milestone->setProject($milestone->getProject());
                 return $this->renderJSON(array('issue_count' => $no_milestone->countIssues(), 'hours' => $no_milestone->getHoursEstimated(), 'points' => $no_milestone->getPointsEstimated()));
             case $request->isPost():
                 $this->_saveMilestoneDetails($request, $milestone);
                 $board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
                 if ($request->hasParameter('issues') && $request['include_selected_issues']) {
                     \thebuggenie\core\entities\tables\Issues::getTable()->assignMilestoneIDbyIssueIDs($milestone->getID(), $request['issues']);
                 }
                 $message = framework\Context::getI18n()->__('Milestone saved');
                 return $this->renderJSON(array('message' => $message, 'component' => $this->getComponentHTML('agile/milestonebox', array('milestone' => $milestone, 'board' => $board)), 'milestone_id' => $milestone->getID()));
             default:
                 return $this->renderJSON(array('content' => framework\Action::returnComponentHTML('agile/milestonebox', array('milestone' => $milestone)), 'milestone_id' => $milestone->getID(), 'milestone_name' => $milestone->getName(), 'milestone_order' => array_keys($milestone->getProject()->getMilestonesForRoadmap())));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Exemple #3
0
 /**
  * Milestone actions
  *
  * @Route(url="/:project_key/milestone/:milestone_id/actions/*", name='project_milestone')
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runMilestone(framework\Request $request)
 {
     $milestone_id = $request['milestone_id'] ? $request['milestone_id'] : null;
     $milestone = new \thebuggenie\core\entities\Milestone($milestone_id);
     $action_option = str_replace($this->selected_project->getKey() . '/milestone/' . $request['milestone_id'] . '/', '', $request['url']);
     try {
         if (!($this->getUser()->canAddScrumSprints($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project) && $this->getUser()->canManageProject($this->selected_project))) {
             throw new \Exception($this->getI18n()->__("You don't have access to modify milestones"));
         }
         switch (true) {
             case $request->isDelete():
                 $milestone->delete();
                 $no_milestone = new \thebuggenie\core\entities\Milestone(0);
                 $no_milestone->setProject($milestone->getProject());
                 return $this->renderJSON(array('issue_count' => $no_milestone->countIssues(), 'hours' => $no_milestone->getHoursEstimated(), 'points' => $no_milestone->getPointsEstimated()));
             case $request->isPost():
                 $this->_saveMilestoneDetails($request, $milestone);
                 if ($request->hasParameter('issues') && $request['include_selected_issues']) {
                     \thebuggenie\core\entities\tables\Issues::getTable()->assignMilestoneIDbyIssueIDs($milestone->getID(), $request['issues']);
                 }
                 $event = \thebuggenie\core\framework\Event::createNew('project', 'runMilestone::post', $milestone);
                 $event->triggerUntilProcessed();
                 if ($event->isProcessed()) {
                     $component = $event->getReturnValue();
                 } else {
                     $component = $this->getComponentHTML('project/milestonebox', array('milestone' => $milestone, 'include_counts' => true));
                 }
                 $message = framework\Context::getI18n()->__('Milestone saved');
                 return $this->renderJSON(array('message' => $message, 'component' => $component, 'milestone_id' => $milestone->getID()));
             case $action_option == 'details':
                 \thebuggenie\core\framework\Context::performAction(new \thebuggenie\core\modules\project\controllers\Main(), 'project', 'MilestoneDetails');
                 return true;
             default:
                 return $this->forward($this->getRouting()->generate('project_roadmap', array('project_key' => $this->selected_project->getKey())));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }