Exemplo n.º 1
0
 public function itReturnsFalseIfNoTrackerIsUsedInScrum()
 {
     stub($this->tracker)->getHierarchy()->returns($this->hierarchy);
     stub($this->planning_factory)->getPlanningTrackerIdsByGroupId()->returns(array(58));
     stub($this->planning_factory)->getBacklogTrackerIdsByGroupId()->returns(array(45));
     stub($this->hierarchy)->flatten()->returns(array(12, 78, 68));
     $this->assertFalse($this->hierarchy_checker->isScrumHierarchy($this->tracker));
 }
Exemplo n.º 2
0
 public function getTrackersWithKanbanUsageAndHierarchy($project_id, PFUser $user)
 {
     $trackers = array();
     $all_trackers = $this->tracker_factory->getTrackersByGroupIdUserCanView($project_id, $user);
     foreach ($all_trackers as $tracker) {
         $tracker_representation = array();
         $tracker_representation['id'] = $tracker->getId();
         $tracker_representation['name'] = $tracker->getName();
         if ($this->doesKanbanExistForTracker($tracker) || $this->hierarchy_checker->isScrumHierarchy($tracker)) {
             $tracker_representation['used'] = true;
             $trackers[] = $tracker_representation;
             continue;
         }
         $tracker_representation['used'] = false;
         $trackers[] = $tracker_representation;
     }
     return $trackers;
 }
 public function createKanban()
 {
     $kanban_name = $this->request->get('kanban-name');
     $tracker_id = $this->request->get('tracker-kanban');
     $tracker = $this->tracker_factory->getTrackerById($tracker_id);
     $user = $this->request->getCurrentUser();
     if (!$user->isAdmin($this->group_id)) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('global', 'perm_denied'));
         return;
     }
     if (!$tracker_id) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'no_tracker_selected'));
         $this->redirectToHome();
         return;
     }
     if ($this->kanban_manager->doesKanbanExistForTracker($tracker)) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_tracker_used'));
         $this->redirectToHome();
         return;
     }
     if ($this->isTrackerUsedInScrum($tracker)) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'tracker_used_in_scrum'));
         $this->redirectToHome();
         return;
     }
     if ($this->hierarchy_checker->isScrumHierarchy($tracker)) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'hierarchy_used_in_scrum'));
         $this->redirectToHome();
         return;
     }
     if ($this->kanban_manager->createKanban($kanban_name, $tracker_id)) {
         $GLOBALS['Response']->addFeedback(Feedback::INFO, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_created', array($kanban_name)));
     } else {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_creation_error', array($kanban_name)));
     }
     $this->redirectToHome();
 }