private function getAlreadyExistingTracker() { foreach ($this->reserved_names as $itemname) { if ($this->tracker_factory->isShortNameExists($itemname, $this->project->getId())) { return $itemname; } } }
/** * @throws AgileDashboard_UserNotAdminException * * @return bool */ public function setColumnWipLimit(PFUser $user, AgileDashboard_Kanban $kanban, AgileDashboard_KanbanColumn $column, $wip_limit) { $project_id = $this->tracker_factory->getTrackerById($kanban->getTrackerId())->getGroupId(); if (!$this->permissions_manager->userCanAdministrate($user, $project_id)) { throw new AgileDashboard_UserNotAdminException($user); } return $this->column_dao->setColumnWipLimit($column->getKanbanId(), $column->getId(), $wip_limit); }
private function isUserAllowedToAccessKanban(PFuser $user, $tracker_id) { $tracker = $this->tracker_factory->getTrackerById($tracker_id); if (!$tracker) { throw new AgileDashboard_KanbanNotFoundException(); } return $tracker->userCanView($user); }
private function getTracker(Tuleap\Tracker\REST\TrackerReference $tracker_reference) { $tracker = $this->tracker_factory->getTrackerById($tracker_reference->id); if (!$tracker) { throw new \Luracast\Restler\RestException(404, 'Tracker not found'); } return $tracker; }
/** * @see Cardwall_OnTop_Config_Command::execute() */ public function execute(Codendi_Request $request) { if ($request->get('add_mapping_on')) { $new_mapping_tracker = $this->tracker_factory->getTrackerById($request->get('add_mapping_on')); if ($new_mapping_tracker && $this->dao->create($this->tracker->getId(), $new_mapping_tracker->getId(), null)) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_cardwall', 'on_top_mapping_added', array($new_mapping_tracker->getName()))); } } }
public function getChildren($tracker_id) { if (!isset($this->cache_children_of_tracker[$tracker_id])) { $this->cache_children_of_tracker[$tracker_id] = array(); foreach ($this->hierarchy_dao->searchChildTrackerIds($tracker_id) as $row) { $this->cache_children_of_tracker[$tracker_id][] = $this->tracker_factory->getTrackerById($row['id']); } } return $this->cache_children_of_tracker[$tracker_id]; }
/** * @return Tracker_CrossSearch_SearchView */ public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query) { $report = $this->getReport($user); $service = $this->getService($project); $criteria = $this->getCriteria($user, $project, $report, $cross_search_query); $trackers = $this->tracker_factory->getTrackersByGroupIdUserCanView($project->getGroupId(), $user); $tracker_ids = $this->getTrackersIds($trackers); $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $tracker_ids, $cross_search_query); $content_view = new Tracker_CrossSearch_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user); return new Tracker_CrossSearch_SearchView($project, $service, $criteria, $trackers, $content_view); }
/** * @see Cardwall_OnTop_Config_Command::execute() */ public function execute(Codendi_Request $request) { if (is_array($request->get('custom_mapping'))) { foreach ($request->get('custom_mapping') as $mapping_tracker_id => $is_custom) { $mapping_tracker = $this->tracker_factory->getTrackerById($mapping_tracker_id); if ($this->canDelete($is_custom, $mapping_tracker) && $this->delete($mapping_tracker)) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_cardwall', 'on_top_mapping_removed', array($mapping_tracker->getName()))); } } } }
/** * @return Tracker[] */ public function getTrackersUsedAsKanban(Project $project) { $trackers = array(); foreach ($this->dao->getKanbansForProject($project->getId()) as $row) { $tracker = $this->tracker_factory->getTrackerById($row['tracker_id']); if ($tracker) { $trackers[] = $tracker; } } return $trackers; }
/** * * @param SimpleXMLElement $root * Export in XML the list of tracker with a cardwall */ public function export(SimpleXMLElement $root) { $cardwall_node = $root->addChild(CardwallConfigXml::NODE_CARDWALL); $trackers_node = $cardwall_node->addChild(CardwallConfigXml::NODE_TRACKERS); $trackers = $this->tracker_factory->getTrackersByGroupId($this->project->getId()); foreach ($trackers as $tracker) { $this->addTrackerChild($tracker, $trackers_node); } $rng_path = realpath(CARDWALL_BASE_DIR . '/../www/resources/xml_project_cardwall.rng'); $this->xml_validator->validate($cardwall_node, $rng_path); }
public function exportSingleTrackerToXml(SimpleXMLElement $xml_content, $tracker_id, PFUser $user, ZipArchive $archive) { $xml_field_mapping = array(); $xml_trackers = $xml_content->addChild('trackers'); $tracker = $this->tracker_factory->getTrackerById($tracker_id); if ($tracker->isActive()) { $tracker_xml = $xml_trackers->addChild('tracker'); $tracker->exportToXMLInProjectExportContext($tracker_xml, $xml_field_mapping); $this->artifact_xml_xport->export($tracker, $tracker_xml, $user, $archive); } $this->rng_validator->validate($xml_trackers, dirname(TRACKER_BASE_DIR) . '/www/resources/trackers.rng'); return $xml_trackers; }
/** * Process the system event * * @return Boolean */ public function process() { try { $tracker_id = (int) $this->getRequiredParameter(0); $tracker = $this->tracker_factory->getTrackerById($tracker_id); $this->actions->reIndexTracker($tracker); $this->done('All Tracker artifacts re-indexed correctly'); return true; } catch (Exception $e) { $this->error($e->getMessage()); } return false; }
/** * @return Tracker */ private function getTrackerFromMailHeader($mail_header) { $mail_userpart = $this->extractMailUserParts($mail_header); if (count($mail_userpart) !== 2) { throw new Tracker_Artifact_MailGateway_TrackerIdMissingException(); } $tracker_id = (int) $mail_userpart[1]; $tracker = $this->tracker_factory->getTrackerById($tracker_id); if ($tracker === null) { throw new Tracker_Artifact_MailGateway_TrackerDoesNotExistException(); } return $tracker; }
public function getDeniedTrackersForATrackerHierarchy(Tracker $tracker, PFUser $user) { $concerned_by_scrum = $this->isScrumHierarchy($tracker); $concerned_by_kanban = $this->isKanbanHierarchy($tracker); if (!$concerned_by_scrum && !$concerned_by_kanban) { return array(); } $available_trackers = $this->tracker_factory->getTrackersByGroupIdUserCanView($tracker->getGroupId(), $user); if ($concerned_by_scrum) { $possible_trackers = $this->getTrackersConcernedByScrum($available_trackers, $tracker->getProject()); return array_diff($available_trackers, $possible_trackers); } $possible_trackers = $this->getTrackersConcernedByKanban($available_trackers, $tracker->getProject()); return array_diff($available_trackers, $possible_trackers); }
/** * @see Cardwall_OnTop_Config_Command::execute() */ public function execute(Codendi_Request $request) { if (!is_array($request->get('mapping_field'))) { return; } $mapping_fields = $this->getMappingFields(); foreach ($request->get('mapping_field') as $mapping_tracker_id => $mapping_tracker_info) { if (!isset($mapping_tracker_info['field'])) { continue; } $field_id = (int) $mapping_tracker_info['field']; $mapping_tracker = $this->tracker_factory->getTrackerById($mapping_tracker_id); $field = $this->form_element_factory->getFieldById($field_id); $this->save($mapping_tracker_info, $mapping_fields, $mapping_tracker, $field); } }
/** * The singleton method * * @return Tracker_Hierarchy_HierarchicalTrackerFactory */ public static function instance() { if (!self::$instance) { self::$instance = new Tracker_Hierarchy_HierarchicalTrackerFactory(TrackerFactory::instance(), new Tracker_Hierarchy_Dao()); } return self::$instance; }
private function getTrackerForKanban(AgileDashboard_Kanban $kanban) { $tracker = $this->tracker_factory->getTrackerById($kanban->getTrackerId()); if (!$tracker) { throw new RestException(500, 'The tracker used by the kanban does not exist anymore'); } return $tracker; }
public function __construct(AgileDashboard_Kanban $kanban, PFUser $user, $user_is_kanban_admin, $language, $project_id) { $user_preferences = new AgileDashboard_KanbanUserPreferences(); $kanban_representation_builder = new Tuleap\AgileDashboard\REST\v1\Kanban\KanbanRepresentationBuilder($user_preferences, new AgileDashboard_KanbanColumnFactory(new AgileDashboard_KanbanColumnDao(), $user_preferences), TrackerFactory::instance(), Tracker_FormElementFactory::instance()); $this->kanban_representation = json_encode($kanban_representation_builder->build($kanban, $user)); $this->user_is_kanban_admin = (int) $user_is_kanban_admin; $this->language = $language; $this->project_id = $project_id; }
/** * Process the system event * * @return Boolean */ public function process() { try { $project_id = (int) $this->getRequiredParameter(0); if ($this->system_event_manager->isProjectReindexationAlreadyQueued($project_id)) { $this->done('Skipped duplicate event'); $this->logger->debug("Skipped duplicate event for project {$project_id} : " . self::NAME); return true; } $trackers = $this->tracker_factory->getTrackersByGroupId($project_id); $this->actions->reIndexProjectArtifacts($trackers); $this->done(); return true; } catch (Exception $e) { $this->error($e->getMessage()); } return false; }
public function getChildrenPlanning(Planning $planning) { $children = $this->tracker_factory->getHierarchyFactory()->getChildren($planning->getPlanningTrackerId()); if (count($children) == 0) { return null; } else { $planning_tracker = array_shift($children); return $this->getPlanningByPlanningTracker($planning_tracker); } }
private function getTrackerById($group_id, $tracker_id, $method_name) { $tracker = $this->tracker_factory->getTrackerById($tracker_id); if ($tracker == null) { throw new SoapFault(get_tracker_fault, 'Could not get Tracker.', $method_name); } elseif ($tracker->getGroupId() != $group_id) { throw new SoapFault(get_tracker_fault, 'Could not get Tracker.', $method_name); } return $tracker; }
/** * Epic * `-- Story * `-- Task * getAllParents(Task) -> ['Story', 'Epic'] * * @return Tracker[] */ public function getAllParents(Tracker $tracker) { $hierarchy = $this->getHierarchy(array($tracker->getId())); $parent_tracker_id = $hierarchy->getParent($tracker->getId()); $stack = array(); while ($parent_tracker = $this->tracker_factory->getTrackerById($parent_tracker_id)) { $stack[] = $parent_tracker; $parent_tracker_id = $hierarchy->getParent($parent_tracker->getId()); } return $stack; }
private function instantiateMappingFromRow(Tracker $tracker, array &$mappings, array $row, Cardwall_OnTop_Config_ColumnCollection $columns) { $mapping_tracker = $this->tracker_factory->getTrackerById($row['tracker_id']); if ($mapping_tracker && $mapping_tracker != $tracker) { //TODO: field is used? $available_fields = $this->element_factory->getUsedSbFields($mapping_tracker); $mapping_field = $this->element_factory->getFieldById($row['field_id']); if ($mapping_field) { $mapping = $this->instantiateFreestyleMapping($tracker, $mappings, $mapping_tracker, $available_fields, $mapping_field); } else { $status_field = $mapping_tracker->getStatusField(); if ($status_field) { $mapping = $this->instantiateMappingStatus($tracker, $mappings, $mapping_tracker, $available_fields, $columns); } else { $mapping = $this->instantiateNoFieldMapping($mapping_tracker, $available_fields); } } $mappings[$mapping_tracker->getId()] = $mapping; } }
public function getConfigFactory() { if (!$this->config_factory) { require_once 'OnTop/ConfigFactory.class.php'; require_once TRACKER_BASE_DIR . '/Tracker/TrackerFactory.class.php'; $tracker_factory = TrackerFactory::instance(); $element_factory = Tracker_FormElementFactory::instance(); $this->config_factory = new Cardwall_OnTop_ConfigFactory($tracker_factory, $element_factory); } return $this->config_factory; }
private function createTrackerStructure(PFUser $user, $project_id, $tv3_id, $tracker_name, $tracker_description, $tracker_short_name) { $project = $this->project_manager->getProject($project_id); $this->logger->info('--> Migrate structure '); $new_tracker = $this->tracker_factory->createFromTV3($user, $tv3_id, $project, $tracker_name, $tracker_description, $tracker_short_name); if (!$new_tracker) { throw new Tracker_Exception_Migration_StructureCreationException($tracker_name, $tv3_id); } $this->logger->info('<-- Structure migrated ' . PHP_EOL); return $new_tracker->getId(); }
public function __construct(AgileDashboard_Kanban $kanban, PFUser $user, $user_is_kanban_admin, $language, $project_id) { $user_preferences = new AgileDashboard_KanbanUserPreferences(); $kanban_representation_builder = new Tuleap\AgileDashboard\REST\v1\Kanban\KanbanRepresentationBuilder($user_preferences, new AgileDashboard_KanbanColumnFactory(new AgileDashboard_KanbanColumnDao(), $user_preferences), new AgileDashboard_KanbanActionsChecker(TrackerFactory::instance(), new AgileDashboard_PermissionsManager(), Tracker_FormElementFactory::instance())); $this->kanban_representation = json_encode($kanban_representation_builder->build($kanban, $user)); $this->user_is_kanban_admin = (int) $user_is_kanban_admin; $this->language = $language; $this->project_id = $project_id; $this->user_id = $user->getId(); $this->view_mode = $user->getPreference('agiledashboard_kanban_item_view_mode_' . $kanban->getId()); $this->nodejs_server = ForgeConfig::get('nodejs_server'); }
public function importChildren(Tracker_XML_Importer_ArtifactImportedMapping $artifacts_imported_mapping, SimpleXMLElement $xml_artifacts, $extraction_path, Tracker_Artifact $root_artifact, PFUser $user) { $length = count($xml_artifacts->artifact); if ($length <= 1) { return; } $this->addChildrenFromXML($xml_artifacts->artifact[0]); for ($i = 1; $i < $length; $i++) { $xml_artifact = $xml_artifacts->artifact[$i]; $tracker = $this->tracker_factory->getTrackerById((int) $xml_artifact['tracker_id']); if (!$tracker) { throw new Tracker_XML_Importer_TrackerIdNotDefinedException(); } $artifact = $this->xml_importer->importOneArtifactFromXML($tracker, $xml_artifact, $extraction_path); if ($artifact) { $this->addChildrenFromXML($xml_artifact); $artifacts_imported_mapping->add((int) $xml_artifact['id'], $artifact->getId()); } } $this->createLinksBetweenArtifacts($user, $artifacts_imported_mapping, $root_artifact); }
/** * Return the 'Planning' tracker (tracker we should be able to use artifacts to perform search. * * @param Integer $group_id * * @return Array of Integer */ public function getPlanningTrackers($group_id, User $user) { $trackers = array(); foreach ($this->getPlannings($user, $group_id) as $planning) { $planning = $this->getPlanning($planning->getId()); $tracker_id = $planning->getPlanningTrackerId(); if (!isset($trackers[$tracker_id])) { if ($tracker = $this->tracker_factory->getTrackerById($tracker_id)) { $trackers[$tracker_id] = $tracker; } } } return $trackers; }
private function createUserStory(PFUser $user, $field_i_want_to_value, $field_status_value) { $fields_data = array( $this->tracker_formelement_factory->getFormElementByName(self::USER_STORIES_TRACKER_ID, 'i_want_to')->getId() => $field_i_want_to_value, $this->tracker_formelement_factory->getFormElementByName(self::USER_STORIES_TRACKER_ID, 'status')->getId() => $field_status_value ); $this->tracker_artifact_factory->createArtifact( $this->tracker_factory->getTrackerById(self::USER_STORIES_TRACKER_ID), $fields_data, $user, '', false ); }
public function showKanban() { $kanban_id = $this->request->get('id'); $user = $this->request->getCurrentUser(); try { $kanban = $this->kanban_factory->getKanban($user, $kanban_id); $tracker = $this->tracker_factory->getTrackerById($kanban->getTrackerId()); $user_is_kanban_admin = $this->permissions_manager->userCanAdministrate($user, $tracker->getGroupId()); return $this->renderToString('kanban', new KanbanPresenter($kanban, $user, $user_is_kanban_admin, $user->getShortLocale(), $tracker->getGroupId())); } catch (AgileDashboard_KanbanNotFoundException $exception) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_not_found')); } catch (AgileDashboard_KanbanCannotAccessException $exception) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('global', 'error_perm_denied')); } }