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; }
/** * @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); }
/** * @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]; }
/** * @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; }
/** * 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 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; }
/** * @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); } }
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; }
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; }
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; } }
private function importArtifactsData($username, $tracker_id, $xml_file_path) { $this->logger->info('--> Import into TV5 '); $this->user_manager->forceLogin($username); $tracker = $this->tracker_factory->getTrackerById($tracker_id); if ($tracker) { $xml_import = $this->getXMLImporter(); $xml_import->importFromFile($tracker, $xml_file_path, ForgeConfig::get('sys_data_dir') . DIRECTORY_SEPARATOR . 'trackerv3'); } $this->logger->info('<-- TV5 imported ' . PHP_EOL); }
/** * 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; }
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); }
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 ); }
/** * 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, PFUser $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; }
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')); } }
/** * @param Tracker $tracker * * @return \Cardwall_OnTop_Config */ public function getOnTopConfigByTrackerId($tracker_id) { $tracker = $this->tracker_factory->getTrackerById($tracker_id); return $this->getOnTopConfig($tracker); }
/** * @return Tracker */ public function getParent(Tracker $tracker) { $hierarchy = $this->getHierarchy(array($tracker->getId())); $parent_tracker_id = $hierarchy->getParent($tracker->getId()); return $this->tracker_factory->getTrackerById($parent_tracker_id); }
/** * Build a Workflow instance * * @param array $row The data describing the workflow * * @return Tracker_Workflow */ public function getInstanceFromRow($row) { $tracker = $this->tracker_factory->getTrackerById($row['tracker_id']); return new Workflow($this->getGlobalRulesManager($tracker), $this->trigger_rules_manager, $this->logger, $row['workflow_id'], $row['tracker_id'], $row['field_id'], $row['is_used']); }
/** * @return Tracker (only the structure) */ public function createTV5FromTV3(Project $project, $name, $description, $itemname, ArtifactType $tv3) { $dao = new Tracker_Migration_V3_Dao(); $logger = new BackendLogger(ForgeConfig::get('codendi_log') . '/' . Tracker_Migration_MigrationManager::LOG_FILE); $log_prefix = '[' . uniqid() . ']'; $logger->info("{$log_prefix} Start migration of tracker v3: " . $tv3->getID()); // 010 & 020 if ($id = $dao->create($project->getId(), $name, $description, $itemname, $tv3->getID())) { $logger->info("{$log_prefix} Tracker v5: " . $id); $logger->info("{$log_prefix} 030 Fieldset"); $fieldset_dao = new Tracker_Migration_V3_FieldsetsDao(); $fieldset_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 040 Fields"); $field_dao = new Tracker_Migration_V3_FieldsDao(); $field_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 045 & 046 Fields Default Values"); $fields_default_values_dao = new Tracker_Migration_V3_FieldsDefaultValuesDao(); $fields_default_values_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 050 Reports"); $reports_dao = new Tracker_Migration_V3_ReportsDao(); $reports_dao->create($tv3->getID(), $id, $project->getId()); $logger->info("{$log_prefix} 060 RenderersTable"); $renderers_table_dao = new Tracker_Migration_V3_RenderersTableDao(); $renderers_table_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 070 RenderersGraph"); $renderers_graph_dao = new Tracker_Migration_V3_RenderersGraphDao(); $renderers_graph_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 075 PermissionsOnArtifactField"); $perms_on_artifact_dao = new Tracker_Migration_V3_PermissionsOnArtifactFieldDao(); $perms_on_artifact_dao->addPermissionsOnArtifactField($id); $logger->info("{$log_prefix} 080 AttachmentField"); $attachment_field_dao = new Tracker_Migration_V3_AttachmentFieldDao(); $attachment_field_dao->addAttachmentField($id); $logger->info("{$log_prefix} 085 ReferenceField"); $reference_dao = new Tracker_Migration_V3_ReferenceFieldDao(); $reference_dao->addReferenceField($id); $logger->info("{$log_prefix} 090 CCField"); $cc_dao = new Tracker_Migration_V3_CcFieldDao(); $cc_dao->addCCField($id); $logger->info("{$log_prefix} 220 Semantic"); $semantic_dao = new Tracker_Migration_V3_SemanticDao(); $semantic_dao->create($id); $logger->info("{$log_prefix} 250 Canned"); $canned_dao = new Tracker_Migration_V3_CannedDao(); $canned_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 260 Fieldset stored as field"); $fieldset_dao->nowFieldsetsAreStoredAsField($id); $logger->info("{$log_prefix} 270 & 280 columns"); $columns_dao = new Tracker_Migration_V3_ColumnsDao(); $columns_dao->create($id); // 300 // useless because transitions already have default permissions $logger->info("{$log_prefix} 310 FieldPerms"); $field_perms_dao = new Tracker_Migration_V3_FieldPermsDao(); $field_perms_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} 320 FieldDependencies"); $field_dependencies_dao = new Tracker_Migration_V3_FieldDependenciesDao(); $field_dependencies_dao->addDependencies($tv3->getID(), $id); $logger->info("{$log_prefix} date reminders"); $reminder_dao = new Tracker_Migration_V3_RemindersDao(); $reminder_dao->create($tv3->getID(), $id); $logger->info("{$log_prefix} Complete"); return $this->tracker_factory->getTrackerById($id); } }