Example #1
0
 public function testGetLevelShouldReturnOForEachRoots()
 {
     $hierarchy = new Tracker_Hierarchy();
     $hierarchy->addRelationship(112, 111);
     $hierarchy->addRelationship(1002, 1050);
     $level = $hierarchy->getLevel(112);
     $this->assertEqual(0, $level);
     $level = $hierarchy->getLevel(1002);
     $this->assertEqual(0, $level);
 }
 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();
     $hierarchy = new Tracker_Hierarchy();
     if (!$user->isAdmin($this->group_id)) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('global', 'perm_denied'));
         return;
     }
     if ($this->kanban_manager->doesKanbanExistForTracker($tracker)) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_tracker_used'));
         $this->redirectToHome();
         return;
     }
     try {
         $hierarchy->getLevel($tracker_id);
         $is_in_hierarchy = true;
     } catch (Tracker_Hierarchy_NotInHierarchyException $exeption) {
         $is_in_hierarchy = false;
     }
     if ((count($this->planning_factory->getPlanningsByBacklogTracker($tracker)) > 0 || count($this->planning_factory->getPlanningByPlanningTracker($tracker)) > 0) && !$is_in_hierarchy) {
         $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'tracker_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();
 }