public function process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user) { if (!$this->tracker->userCanSubmitArtifact($current_user)) { $this->logsErrorAndRedirectToTracker('plugin_tracker_admin', 'access_denied'); return; } $from_artifact = $this->artifact_factory->getArtifactByIdUserCanView($current_user, $request->get('from_artifact_id')); if (!$from_artifact || $from_artifact->getTracker() !== $this->tracker) { $this->logsErrorAndRedirectToTracker('plugin_tracker_include_type', 'error_missing_param'); return; } $from_changeset = $from_artifact->getChangeset($request->get('from_changeset_id')); if (!$from_changeset) { $this->logsErrorAndRedirectToTracker('plugin_tracker_include_type', 'error_missing_param'); return; } $submitted_values = $request->get('artifact'); if (!is_array($submitted_values)) { $this->logsErrorAndRedirectToTracker('plugin_tracker_include_type', 'error_missing_param'); return; } try { $this->processCopy($from_changeset, $current_user, $submitted_values); } catch (Tracker_XML_Exporter_TooManyChildrenException $exception) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_artifact', 'copy_too_many_children', array(Tracker_XML_ChildrenCollector::MAX))); $this->redirectToArtifact($from_artifact); } }
/** * @return array */ public function getCards(array $artifact_ids, Tracker_ArtifactFactory $artifact_factory) { $cards = array(); foreach ($artifact_ids as $id) { $cards[] = new ArtifactNode($artifact_factory->getArtifactById($id)); } return $cards; }
private function getArtifactsFromArtifactInfo($artifacts_info) { $artifacts = array(); foreach ($artifacts_info as $artifact_info) { $artifacts[] = $this->artifact_factory->getArtifactById($artifact_info['id']); } return $artifacts; }
/** * @return mixed Tracker_Reference || null */ public function getReference($keyword, $artifact_id) { $artifact = $this->artifact_factory->getArtifactById($artifact_id); if (!$artifact) { return null; } return $this->getTrackerReference($artifact, $keyword); }
/** * * @param PFUser $user * @param Tuleap\Tracker\REST\TrackerReference $tracker_reference * @param array $values * @return Tuleap\Tracker\REST\Artifact\ArtifactReference * @throws \Luracast\Restler\RestException */ public function createWithValuesIndexedByFieldName(PFUser $user, Tuleap\Tracker\REST\TrackerReference $tracker_reference, array $values) { $tracker = $this->getTracker($tracker_reference); $fields_data = $this->artifact_validator->getFieldsDataOnCreateFromValuesByField($values, $tracker); $fields_data = $this->artifact_validator->getUsedFieldsWithDefaultValue($tracker, $fields_data, $user); $this->checkUserCanSubmit($user, $tracker); return $this->returnReferenceOrError($this->artifact_factory->createArtifact($tracker, $fields_data, $user, ''), 'by_field'); }
private function linkArtifact(PFUser $current_user, Tracker_Artifact $new_artifact) { $artifact_link_id = $this->request->get('artifact-link-id'); $source_artifact = $this->tracker_artifact_factory->getArtifactById($artifact_link_id); if (!$source_artifact) { return; } $source_artifact->linkArtifact($new_artifact->getId(), $current_user); }
protected function getCardsPresenters(array $artifact_ids) { $cards = array(); foreach ($artifact_ids as $id) { $artifact = $this->artifact_factory->getArtifactById($id); $cards[] = $this->presenter_builder->getCardInCellPresenter($artifact, Cardwall_SwimlineTrackerRenderer::FAKE_SWIMLINE_ID_FOR_TRACKER_RENDERER); } return $cards; }
private function getSourceArtifact() { $source_artifact = null; if ($this->request->get('func') == 'new-artifact-link') { $source_artifact = $this->artifact_factory->getArtifactById($this->request->get('id')); } elseif ($this->request->get('child_milestone')) { $source_artifact = $this->artifact_factory->getArtifactById($this->request->get('child_milestone')); } return $source_artifact; }
public function export(Tracker $tracker, SimpleXMLElement $xml_content, PFUser $user, ZipArchive $archive) { $artifacts_node = $xml_content->addChild('artifacts'); $all_artifacts = $this->artifact_factory->getArtifactsByTrackerId($tracker->getId()); $this->checkThreshold(count($all_artifacts)); foreach ($all_artifacts as $artifact) { $artifact->exportToXML($artifacts_node, $user, $archive); } $this->rng_validator->validate($artifacts_node, realpath(dirname(TRACKER_BASE_DIR) . self::ARTIFACTS_RNG_PATH)); }
/** * Should we move this method outside of changeset creation * so that we can remove the dependency on artifact factory * and enforce SRP ? */ protected function saveArtifactAfterNewChangeset(Tracker_Artifact $artifact, array $fields_data, PFUser $submitter, Tracker_Artifact_Changeset $new_changeset, Tracker_Artifact_Changeset $previous_changeset = null) { if ($this->artifact_factory->save($artifact)) { $used_fields = $this->formelement_factory->getUsedFields($artifact->getTracker()); foreach ($used_fields as $field) { $field->postSaveNewChangeset($artifact, $submitter, $new_changeset, $previous_changeset); } $artifact->getWorkflow()->after($fields_data, $new_changeset, $previous_changeset); return true; } return false; }
public function getPossibleArtifactParents(Tracker $parent_tracker, PFUser $user, $limit, $offset) { $label = ''; $possible_parents = array(); $display_selector = true; EventManager::instance()->processEvent(TRACKER_EVENT_ARTIFACT_PARENTS_SELECTOR, array('user' => $user, 'parent_tracker' => $parent_tracker, 'possible_parents' => &$possible_parents, 'label' => &$label, 'display_selector' => &$display_selector)); if (!$possible_parents) { $label = $GLOBALS['Language']->getText('plugin_tracker_artifact', 'formelement_artifactlink_open_parent', array($parent_tracker->getName())); $possible_parents = $this->artifact_factory->getPaginatedPossibleParentArtifactsUserCanView($user, $parent_tracker->getId(), $limit, $offset); } return array($label, $possible_parents, $display_selector); }
public function exportChildren(SimpleXMLElement $xml) { while ($artifact_id = $this->children_collector->pop()) { $artifact = $this->artifact_factory->getArtifactById($artifact_id); if (!$artifact) { continue; } $last_changeset = $artifact->getLastChangeset(); $this->artifact_xml_updater->exportSnapshotWithoutComments($xml, $last_changeset); $index_last_artifact = count($xml->artifact) - 1; $this->file_xml_updater->update($xml->artifact[$index_last_artifact]); } }
private function getArtifactLinkTitle($id) { if ($artifact = $this->artifact_factory->getArtifactByIdUserCanView($this->user, $id)) { return $artifact->getTitle(); } return ''; }
private function getArtifact($artifact_id) { $artifact = $this->artifact_factory->getArtifactById($artifact_id); if (!$artifact) { throw new Tracker_Artifact_MailGateway_RecipientArtifactDoesNotExistException(); } return $artifact; }
private function getArtifact($artifact_id) { $artifact = $this->artifact_factory->getArtifactById($artifact_id); if ($artifact) { return $artifact; } throw new CardControllerBuilderRequestIdException(); }
public function tearDown() { parent::tearDown(); $_SERVER['REQUEST_URI'] = $this->saved_request_uri; Tracker_ArtifactFactory::clearInstance(); Tracker_Hierarchy_HierarchicalTrackerFactory::clearInstance(); TrackerFactory::clearInstance(); }
/** * * @param int $id * * @return Tracker_Artifact | null */ public function getArtifactByFileInfoId($id) { $row = $this->dao->searchArtifactIdByFileInfoId($id)->getRow(); if (!$row) { return; } return $this->artifact_factory->getArtifactById($row['artifact_id']); }
private function getArtifactById($artifact_id, $user, $method_name) { $artifact = $this->artifact_factory->getArtifactById($artifact_id); if (!$artifact) { throw new SoapFault(get_artifact_fault, 'Could Not Get Artifact', $method_name); } $this->checkUserCanViewArtifact($artifact, $user); return $artifact; }
/** * Get the top most recent milestone (last created artifact in planning tracker) * * @param User $user * @param Integer $planning_id * * @return Planning_Milestone */ public function getCurrentMilestone(User $user, $planning_id) { $planning = $this->planning_factory->getPlanningWithTrackers($planning_id); $artifacts = $this->artifact_factory->getOpenArtifactsByTrackerIdUserCanView($user, $planning->getPlanningTrackerId()); if (count($artifacts) > 0) { return $this->getMilestoneFromArtifact(array_shift($artifacts)); } return new Planning_NoMilestone($planning->getPlanningTracker()->getProject(), $planning); }
public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query, array $already_planned_artifact_ids, $backlog_tracker_id, Planning $planning, $planning_redirect_parameter) { $report = $this->getReport($user); $criteria = $this->getCriteria($user, $project, $report, $cross_search_query); $tracker_ids = $this->hierarchy_factory->getHierarchy(array($backlog_tracker_id))->flatten(); $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $tracker_ids, $cross_search_query, $already_planned_artifact_ids); $visitor = new Planning_BacklogItemFilterVisitor($backlog_tracker_id, $this->hierarchy_factory, $already_planned_artifact_ids); $artifacts = $artifacts->accept($visitor); return new Planning_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user, $planning, $planning_redirect_parameter); }
public function display($artifact_link_id, $render_with_javascript) { $artifact_to_link = null; $submitted_values = array(); if ($artifact_link_id) { $artifact_to_link = $this->tracker_artifact_factory->getArtifactByid($artifact_link_id); } if ($artifact_to_link) { if ($this->isArtifactInParentTracker($artifact_to_link)) { $submitted_values['disable_artifact_link_field'] = true; } else { $submitted_values['disable_artifact_link_field'] = false; } } $submitted_values['render_with_javascript'] = $render_with_javascript; $form_elements = $this->tracker->fetchSubmitNoColumns($artifact_to_link, $submitted_values); $presenter = new Tracker_Artifact_Presenter_CreateArtifactInPlacePresenter($this->tracker, $artifact_to_link, $form_elements, $render_with_javascript); $this->renderer->renderToPage('create-artifact-modal', $presenter); }
private function initInconsistentItems(PFUser $user, Planning_Milestone $milestone, $redirect_to_self, array $planned) { foreach ($planned as $planned_artifact_id) { if (!$this->all_collection[$milestone->getArtifactId()]->containsId($planned_artifact_id)) { $artifact = $this->artifact_factory->getArtifactByIdUserCanView($user, $planned_artifact_id); if ($artifact) { $this->inconsistent_collection[$milestone->getArtifactId()]->push($this->backlog_item_builder->getItem($artifact, $redirect_to_self)); } } } }
/** * @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); }
/** * @return AgileDashboard_Milestone_Backlog_DescendantItemsCollection */ private function getItemsForUser(PFUser $user, DataAccessResult $result, $found_rows) { $items = new AgileDashboard_Milestone_Backlog_DescendantItemsCollection(); foreach ($result as $row) { $item = $this->artifact_factory->getInstanceFromRow($row); if ($item->userCanView($user)) { $items->push($item); } } $items->setTotalAvaialableSize($found_rows); return $items; }
public function __construct(Cardwall_PaneInfo $info, Planning_Milestone $milestone, Cardwall_OnTop_Config $config, PFUser $user, Planning_MilestoneFactory $milestone_factory) { $this->info = $info; $this->milestone = $milestone; $this->config = $config; $this->user = $user; $this->milestone_factory = $milestone_factory; $this->artifact_factory = Tracker_ArtifactFactory::instance(); $this->tracker_form_element_factory = Tracker_FormElementFactory::instance(); $this->user_manager = UserManager::instance(); $this->planning_factory = PlanningFactory::build(); }
/** * @return Tracker_Artifact_XMLImport */ public function build(User\XML\Import\IFindUserFromXMLReference $user_finder) { $artifact_factory = Tracker_ArtifactFactory::instance(); $formelement_factory = Tracker_FormElementFactory::instance(); $fields_validator = new Tracker_Artifact_Changeset_AtGivenDateFieldsValidator($formelement_factory); $changeset_dao = new Tracker_Artifact_ChangesetDao(); $changeset_comment_dao = new Tracker_Artifact_Changeset_CommentDao(); $logger = new Log_ConsoleLogger(); $send_notifications = false; $artifact_creator = new Tracker_ArtifactCreator($artifact_factory, $fields_validator, new Tracker_Artifact_Changeset_InitialChangesetAtGivenDateCreator($fields_validator, $formelement_factory, $changeset_dao, $artifact_factory, EventManager::instance())); $new_changeset_creator = new Tracker_Artifact_Changeset_NewChangesetAtGivenDateCreator($fields_validator, $formelement_factory, $changeset_dao, $changeset_comment_dao, $artifact_factory, EventManager::instance(), ReferenceManager::instance()); return new Tracker_Artifact_XMLImport(new XML_RNGValidator(), $artifact_creator, $new_changeset_creator, Tracker_FormElementFactory::instance(), $user_finder, new Tracker_FormElement_Field_List_Bind_Static_ValueDao(), $logger, $send_notifications); }
public function setUp() { parent::setUp(); $this->user = mock('PFUser'); $this->dao = mock('Tracker_FormElement_Field_ComputedDao'); $this->field = TestHelper::getPartialMock('Tracker_FormElement_Field_Computed', array('getProperty', 'getDao')); stub($this->field)->getProperty('target_field_name')->returns('effort'); stub($this->field)->getProperty('fast_compute')->returns(1); stub($this->field)->getDao()->returns($this->dao); $this->artifact_factory = mock('Tracker_ArtifactFactory'); Tracker_ArtifactFactory::setInstance($this->artifact_factory); $this->formelement_factory = mock('Tracker_FormElementFactory'); Tracker_FormElementFactory::setInstance($this->formelement_factory); }
private function getContextRepresentation() { $html = ''; if (!is_null($this->context) && $this->context !== self::NO_CONTEXT) { $html .= ' ' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'priority_change_in') . ' '; if ($this->context === '0') { $html .= $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'priority_change_backlog'); } else { $html .= $this->tracker_artifact_factory->getArtifactById($this->context)->fetchColoredXRef(); } $html .= ' '; } return $html; }
public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query, array $already_planned_artifact_ids, array $backlog_tracker_ids, Planning $planning, Planning_BacklogActionsPresenter $backlog_actions_presenter, $planning_redirect_parameter) { $report = $this->getReport($user); $criteria = $this->getCriteria($user, $project, $report, $cross_search_query); $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $backlog_tracker_ids, $cross_search_query, $already_planned_artifact_ids); // The following lines allows to tailor/rebuild the result before display // As of today (aug-12), we decided to display everything and to wait for // user feedback to see if we need to enable one of them. //$visitor = new Planning_BacklogItemFilterVisitor($backlog_tracker_id, $this->hierarchy_factory, $already_planned_artifact_ids); //$artifacts = $artifacts->accept($visitor); //$visitor = new Planning_GroupByParentsVisitor($user); //$artifacts->accept($visitor); return new Planning_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user, $backlog_actions_presenter, $planning, $planning_redirect_parameter); }
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 ); }