Exemplo n.º 1
0
 private function getBacklogTrackersFiltered(array $trackers, array $kanban_tracker_ids, Planning $planning)
 {
     $trackers_filtered = array();
     foreach ($this->getPlanningTrackerPresenters($trackers, $planning) as $tracker_presenter) {
         $trackers_filtered[] = array('name' => $tracker_presenter->getName(), 'id' => $tracker_presenter->getId(), 'selected' => $tracker_presenter->selectedIfBacklogTracker(), 'disabled' => in_array($tracker_presenter->getId(), $kanban_tracker_ids) || $this->hierarchy_checker->isKanbanHierarchy($tracker_presenter->getTracker()));
     }
     return $trackers_filtered;
 }
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;
 }
Exemplo n.º 3
0
 public function itReturnsDeniedTrackersIfTheSelectedTrackerIsOfAKanbanHierarchyOrConcernedByKanban()
 {
     $hierarchy42_78_68 = stub('Tracker_Hierarchy')->flatten()->returns(array(42, 78, 68));
     $tracker42 = aMockTracker()->withId(42)->build();
     stub($tracker42)->getHierarchy()->returns($hierarchy42_78_68);
     $tracker78 = aMockTracker()->withId(78)->build();
     stub($tracker78)->getHierarchy()->returns($hierarchy42_78_68);
     $tracker68 = aMockTracker()->withId(68)->build();
     stub($tracker68)->getHierarchy()->returns($hierarchy42_78_68);
     $tracker34 = aMockTracker()->withId(34)->build();
     stub($tracker34)->getHierarchy()->returns($this->hierarchy);
     $tracker55 = aMockTracker()->withId(55)->build();
     stub($tracker55)->getHierarchy()->returns($this->hierarchy);
     stub($this->tracker)->getHierarchy()->returns($this->hierarchy);
     stub($this->tracker_factory)->getTrackersByGroupIdUserCanView()->returns(array(12 => $this->tracker, 42 => $tracker42, 78 => $tracker78, 68 => $tracker68, 34 => $tracker34, 55 => $tracker55));
     stub($this->kanban_factory)->getKanbanTrackerIds()->returns(array(12, 34, 55));
     stub($this->planning_factory)->getPlanningTrackerIdsByGroupId()->returns(array());
     stub($this->planning_factory)->getBacklogTrackerIdsByGroupId()->returns(array(42));
     stub($this->hierarchy)->flatten()->returns(array(12, 34, 55));
     $this->assertEqual(array_keys($this->hierarchy_checker->getDeniedTrackersForATrackerHierarchy($this->tracker, $this->user)), array(42, 78, 68));
 }
 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();
 }