private function notAlreadyComputed(Tracker_Artifact $artifact, &$computed_artifact_ids) { if (!isset($computed_artifact_ids[$artifact->getId()])) { $computed_artifact_ids[$artifact->getId()] = true; return true; } return false; }
private function getParentNode(Tracker_Artifact $parent, array &$cache_alreaydy_built_parents) { if (!isset($cache_alreaydy_built_parents[$parent->getId()])) { $parent_node = new TreeNode(); $parent_node->setId($parent->getId()); $parent_node->setObject($parent); $cache_alreaydy_built_parents[$parent->getId()] = $parent_node; } return $cache_alreaydy_built_parents[$parent->getId()]; }
private function getCachedRawMailByChangesetsForArtifact(Tracker_Artifact $artifact) { if (!isset($this->cache[$artifact->getId()])) { $this->cache[$artifact->getId()] = array(); foreach ($this->dao->searchByArtifactId($artifact->getId()) as $row) { $this->cache[$artifact->getId()][$row['changeset_id']] = $row['raw_mail']; } } return $this->cache[$artifact->getId()]; }
private function fetchNewArtifactForm(Codendi_Request $request, PFUser $current_user) { $html = ''; $html .= '<input type="hidden" name="link-artifact-id" value="' . $this->source_artifact->getId() . '" />'; if ($request->get('immediate')) { $html .= '<input type="hidden" name="immediate" value="1" />'; } $html .= $this->fetchFormElements($request, $current_user); $html .= '<input class="btn btn-primary" type="submit" id="tracker_artifact_submit" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; return $html; }
public function getColumnIdOfKanbanItem(Tracker_Artifact $artifact) { $row = $this->item_dao->getColumnIdOfKanbanItem($artifact->getTrackerId(), $artifact->getId())->getRow(); if (!$row) { return null; } return (int) $row['bindvalue_id']; }
/** * @param PFUser $user * @param Tracker_Artifact $artifact * * @return mixed */ private function getCurrentComputedValue(Tracker_Artifact $artifact) { $row = $this->getValueDao()->getLastValue($artifact->getId(), $this->getId()); if ($row) { return $row['value']; } return 0; }
private function createChangesetId(Tracker_Artifact $artifact, PFUser $submitter, $submitted_on) { $email = null; if ($submitter->isAnonymous()) { $email = $submitter->getEmail(); } return $this->changeset_dao->create($artifact->getId(), $submitter->getId(), $email, $submitted_on); }
/** * Get all changesets in a format ready for json conversion * * @param Tracker_Artifact $artifact * @param Integer $changeset_id * @return array */ public function getNewChangesetsFormattedForJson(Tracker_Artifact $artifact, $changeset_id) { $changesets = array(); foreach ($this->dao->searchChangesetNewerThan($artifact->getId(), $changeset_id) as $row) { $changesets[] = $this->json_formatter->format($this->getChangesetFromRow($artifact, $row)); } return $changesets; }
/** * Add to $artifacts_xml the xml structure of an artifact */ public function exportFullHistory(SimpleXMLElement $artifacts_xml, Tracker_Artifact $artifact) { $artifact_xml = $artifacts_xml->addChild('artifact'); $artifact_xml->addAttribute('id', $artifact->getId()); foreach ($artifact->getChangesets() as $changeset) { $this->changeset_exporter->exportFullHistory($artifact_xml, $changeset); } }
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); }
private function fetchArtifactInformations(Tracker_Artifact $artifact) { $html = ""; $html_purifier = Codendi_HTMLPurifier::instance(); $artifact_id = $html_purifier->purify($artifact->getId()); $changeset_id = $html_purifier->purify($artifact->getLastChangeset()->getId()); $html .= '<input type="hidden" id="artifact_informations" data-artifact-id="' . $artifact_id . '" data-changeset-id="' . $changeset_id . '">'; return $html; }
private function recursivelyFindChildrenBelongingToTracker(Tracker_Artifact $source_artifact, Tracker $expected_tracker, User $user, array $hierarchy) { $artifacts = array(); $children = $source_artifact->getLinkedArtifactsOfHierarchy($user); if (isset($hierarchy[$source_artifact->getId()])) { array_walk($children, array($this, 'keepOnlyArtifactsBelongingToParentTracker'), $hierarchy[$source_artifact->getId()]); array_filter($children); } if ($children) { foreach ($children as $child) { if ($child->getTracker() == $expected_tracker) { $artifacts[] = $child; } else { $artifacts = array_merge($artifacts, $this->recursivelyFindChildrenBelongingToTracker($child, $expected_tracker, $user, $hierarchy)); } } } return $artifacts; }
public function __construct(Tracker_Artifact $artifact) { $this->id = $artifact->getId(); $this->title = $artifact->getTitle(); $this->url = $artifact->getUri(); $this->artifact = $artifact; $this->color = $this->artifact->getTracker()->getColor(); $this->type = $this->artifact->getTracker()->getName(); $this->short_type = $this->artifact->getTracker()->getItemName(); }
/** * Retrieves the artifacts planned for the given milestone artifact. * * @param PFUser $user * @param Tracker_Artifact $milestone_artifact * @param Cardwall_OnTop_Config_ColumnCollection $columns * * @return Cardwall_Swimline[] */ private function getSwimlines(PFUser $user, Tracker_Artifact $milestone_artifact, Cardwall_OnTop_Config_ColumnCollection $columns) { $swimlines = array(); foreach ($this->dao->getBacklogArtifacts($milestone_artifact->getId()) as $row) { $swimline_artifact = $this->artifact_factory->getInstanceFromRow($row); if ($swimline_artifact->userCanView($user)) { $swimlines[] = $this->buildSwimlineForArtifact($user, $swimline_artifact, $columns); } } return $swimlines; }
/** * @param Tracker_Artifact $artifact The child * @param Tracker_Artifact $parent The parent * @param Tracker_Semantic_Status $semantic The status semantic used by the corresponding tracker */ public function __construct(Tracker_Artifact $artifact, Tracker_Artifact $parent, Tracker_Semantic_Status $semantic) { $base_url = get_server_url(); $this->xref = $artifact->getXRef(); $this->title = $artifact->getTitle(); $this->id = $artifact->getId(); $this->url = $base_url . $artifact->getUri(); $this->status = $semantic->getStatus($artifact); $this->parent_id = $parent->getId(); $this->has_children = $artifact->hasChildren(); }
public function __construct($follow_ups, $artifact_links, $form_elements, Tracker_Artifact $artifact, PFUser $user) { $this->follow_ups = $follow_ups; $this->artifact_links = $artifact_links; $this->artifact = $artifact; $this->artifact_id = $artifact->getId(); $this->artifact_title = $artifact->getTitle(); $this->artifact_uri = $artifact->getUri(); $this->last_changeset_id = $artifact->getLastChangeset()->getId(); $this->form_elements = $form_elements; $this->user = $user; }
private function getBaseArtifact(Tracker_Artifact $artifact, array &$properties) { $last_changeset = $artifact->getLastChangeset(); $last_changeset_id = $last_changeset ? $last_changeset->getId() : -1; $properties = array('id' => $artifact->getId(), 'group_id' => $artifact->getTracker()->getGroupId(), 'tracker_id' => $artifact->getTrackerId(), 'last_changeset_id' => $last_changeset_id); $this->artifact_properties_extractor->extractTrackerUserGroups($artifact, $properties); $this->artifact_properties_extractor->extractArtifactUserGroups($artifact, $properties); if ($last_changeset) { $this->artifact_properties_extractor->extractArtifactTextFields($artifact, $last_changeset, $properties); $this->artifact_properties_extractor->extractArtifactDateFields($artifact, $last_changeset, $properties); } }
private function updateParent(Tracker_Artifact $parent, Tracker_Artifact $child, Tracker_Workflow_Trigger_TriggerRule $rule) { $target = $rule->getTarget(); try { $comment = '<p>' . $GLOBALS['Language']->getText('workflow_trigger_rules_processor', 'parent_update', array('art #' . $child->getId(), $child->getLastChangeset()->getUri())) . '</p>'; $comment .= '<p>' . $rule->getAsChangesetComment() . '</p>'; $parent->createNewChangeset($target->getFieldData(), $comment, $this->workflow_user, true, Tracker_Artifact_Changeset_Comment::HTML_COMMENT); $this->logger->debug('Parent successfully updated.'); } catch (Tracker_Exception $e) { $this->logger->debug('Error while updating the parent artifact: ' . $e->getMessage()); $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_artifact', 'error_processor_update', array($parent->fetchDirectLinkToArtifact(), $e->getMessage())), CODENDI_PURIFIER_DISABLED); } }
public function linkWithParents(Codendi_Request $request, Tracker_Artifact $artifact) { $user = $request->getCurrentUser(); $ancestors = $artifact->getAllAncestors($user); if (count($ancestors) == 0) { $artifact_id = (int) $request->getValidated('link-artifact-id', 'uint', 0); $source_artifact = $this->artifact_factory->getArtifactById($artifact_id); if ($source_artifact) { foreach ($source_artifact->getAllAncestors($user) as $ancestor) { $ancestor->linkArtifact($artifact->getId(), $user); } } } }
private function calculateRedirectParams($stay, $from_aid) { $redirect_params = array(); if ($stay) { $redirect_params['aid'] = $this->artifact->getId(); $redirect_params['from_aid'] = $from_aid; } else { if ($from_aid) { $redirect_params['aid'] = $from_aid; } else { $redirect_params['tracker'] = $this->artifact->tracker_id; } } return array_filter($redirect_params); }
public function itStoresTheChildrenOfTheFirstArtifact() { $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?> <artifacts> <artifact id="100" tracker_id="22"> <changeset> <field_change field_name="content" type="art_link"> <value>123</value> </field_change> </changeset> </artifact> <artifact id="123" tracker_id="23"> <changeset> <field_change field_name="content" type="art_link"> <value>124</value> </field_change> </changeset> </artifact> <artifact id="124" tracker_id="24"> <changeset> <field_change field_name="content" type="art_link"> <value/> </field_change> </changeset> </artifact> </artifacts>'); stub($this->xml_importer)->importOneArtifactFromXML('*', $xml->artifact[1], '*')->returns($this->created_artifact); stub($this->xml_importer)->importOneArtifactFromXML('*', $xml->artifact[2], '*')->returns($this->another_child_artifact); stub($this->artifacts_imported_mapping)->get(100)->returns($this->root_artifact->getId()); stub($this->artifacts_imported_mapping)->get(123)->returns($this->created_artifact->getId()); stub($this->artifacts_imported_mapping)->get(124)->returns($this->another_child_artifact->getId()); stub($this->artifacts_imported_mapping)->getOriginal($this->root_artifact->getId())->returns(100); stub($this->artifacts_imported_mapping)->getOriginal($this->created_artifact->getId())->returns(123); stub($this->artifacts_imported_mapping)->getOriginal($this->another_child_artifact->getId())->returns(124); $this->importer->importChildren($this->artifacts_imported_mapping, $xml, 'whatever', $this->root_artifact, $this->user); $expected_parents = array(100, 123); $this->assertEqual($expected_parents, $this->children_collector->getAllParents()); }
private function redirectToPlanning(Tracker_Artifact $artifact, $requested_planning, Planning $planning, Tracker_Artifact_Redirect $redirect) { $redirect_to_artifact = $requested_planning[AgileDashboard_PaneRedirectionExtractor::ARTIFACT_ID]; if ($redirect_to_artifact == -1) { $redirect_to_artifact = $artifact->getId(); } $redirect->base_url = '/plugins/agiledashboard/'; $redirect->query_parameters = array('group_id' => $planning->getGroupId(), 'planning_id' => $planning->getId(), 'action' => 'show', 'aid' => $redirect_to_artifact, 'pane' => $requested_planning[AgileDashboard_PaneRedirectionExtractor::PANE]); }
/** * Instanciate a new object based on a artifact * * @param Tracker_Artifact $artifact * * @return Tracker_ArtifactLinkInfo */ public static function buildFromArtifact(Tracker_Artifact $artifact) { $tracker = $artifact->getTracker(); $klass = __CLASS__; return new $klass($artifact->getId(), $tracker->getItemName(), $tracker->getGroupId(), $tracker->getId(), $artifact->getLastChangeset()->getId()); }
/** * Return true if given given artifact refer to the same DB object (basically same id). * * @param Tracker_Artifact $artifact * * @return Boolean */ public function equals(Tracker_Artifact $artifact = null) { return $artifact && $this->id == $artifact->getId(); }
/** * Index an artifact * * @param Tracker_Artifact $artifact The artifact to index */ public function indexArtifactUpdate(Tracker_Artifact $artifact) { $this->initializeMapping($artifact->getTracker()); $this->logger->debug('[Tracker] Elasticsearch index artifact #' . $artifact->getId() . ' in tracker #' . $artifact->getTrackerId()); $this->client->index($artifact->getTrackerId(), $artifact->getId(), $this->tracker_data_factory->getFormattedArtifact($artifact)); }
public function queueArtifactDelete(Tracker_Artifact $artifact) { if ($this->plugin->isAllowed($artifact->getTracker()->getGroupId())) { $this->system_event_manager->createEvent(SystemEvent_FULLTEXTSEARCH_TRACKER_ARTIFACT_DELETE::NAME, $this->implodeParams(array($artifact->getId(), $artifact->getTrackerId())), SystemEvent::PRIORITY_MEDIUM, SystemEvent::OWNER_APP); } }
public function __construct(Tracker_Artifact $artifact, array $data = null) { parent::__construct($data, $artifact->getId()); $this->setObject($artifact); }
private function getArtifactId(Tracker_Artifact $artifact) { return $artifact->getId(); }
public function parent_id() { if ($this->parent) { return $this->parent->getId(); } }
/** @return Tracker_Artifact_Changeset */ private function addFollowUp(PFUser $user, Tracker_Artifact $artifact, $body) { $this->logger->debug("Receiving new follow-up comment from " . $user->getUserName()); if (!$artifact->userCanUpdate($user)) { $this->logger->info("User " . $user->getUnixName() . " has no right to update the artifact #" . $artifact->getId()); $this->notifier->sendErrorMailInsufficientPermissionUpdate($user->getEmail(), $artifact->getId()); return; } return $artifact->createNewChangeset(array(), $body, $user, true, Tracker_Artifact_Changeset_Comment::TEXT_COMMENT); }