/** * @param PFUser $current_user * @return Tracker_Artifact_Presenter_ArtifactLinkPresenter[] */ private function fetchArtifactLinks(PFUser $current_user) { $linked_artifacts = $this->artifact->getLinkedArtifacts($current_user); $links = array(); foreach ($linked_artifacts as $artifact) { $artifact_title = $artifact->getTitle(); $artifact_link = new Tracker_Artifact_Presenter_ArtifactLinkPresenter($artifact->getTracker()->getItemName(), $artifact->getTracker()->getProject()->getID(), $artifact->getId(), $artifact_title ? $artifact_title : ''); $links[] = $artifact_link; } return $links; }
/** * Given an artifact, return a numerical value of the field for this artifact. * * @param User $user The user who see the results * @param Tracker_Artifact $artifact The artifact on which the value is computed * @param Array $computed_artifact_ids Hash map to store artifacts already computed (avoid cycles) * * @return float */ public function getComputedValue(User $user, Tracker_Artifact $artifact, $timestamp = null, &$computed_artifact_ids = array()) { $sum = null; foreach ($artifact->getLinkedArtifacts($user) as $linked_artifact) { $value = $this->getUniqueFieldValue($user, $linked_artifact, $timestamp, $computed_artifact_ids); $sum = $this->sumIfNotNull($sum, $value); } return $sum; }
private function isParentLinkedToParentMilestone(Tracker_Artifact $artifact_added, Tracker_Artifact $parent_milestone_artifact, PFUser $user) { $parent = $artifact_added->getParent($user); if (!$parent) { return false; } $linked_artifacts = $parent_milestone_artifact->getLinkedArtifacts($user); foreach ($linked_artifacts as $linked_artifact) { if ($linked_artifact->getId() === $parent->getId()) { return true; } } return false; }
/** * Returns linked artifacts * * @param Tracker_Artifact $artifact * * @return Array of Tracker_Artifact * * @throws Exception */ private function getLinkedArtifacts(Tracker_Artifact $artifact, User $user) { $linked_artifacts = $artifact->getLinkedArtifacts($user); if (count($linked_artifacts)) { return $linked_artifacts; } throw new Tracker_FormElement_Field_BurndownException('burndown_no_linked_artifacts'); }
/** * Returns linked artifacts * * @param Tracker_Artifact $artifact * * @return Array of Tracker_Artifact * * @throws Tracker_FormElement_Field_BurndownException */ private function getLinkedArtifacts(Tracker_Artifact $artifact, PFUser $user) { $linked_artifacts = $artifact->getLinkedArtifacts($user); if (count($linked_artifacts)) { return $linked_artifacts; } throw new Tracker_FormElement_Field_BurndownException($GLOBALS['Language']->getText('plugin_tracker', 'burndown_no_linked_artifacts')); }