public function exportToXml($group_id, SimpleXMLElement $xml_content) { $exported_trackers = array(); $xml_field_mapping = array(); $xml_trackers = $xml_content->addChild('trackers'); foreach ($this->tracker_factory->getTrackersByGroupId($group_id) as $tracker) { if ($tracker->isActive()) { $exported_trackers[] = $tracker; $child = $xml_trackers->addChild('tracker'); $tracker->exportToXML($child, $xml_field_mapping); } } // Cross tracker stuff needs to be exported after to ensure all references exists $triggers_xml = $xml_trackers->addChild('triggers'); foreach ($exported_trackers as $tracker) { $this->trigger_rules_manager->exportToXml($triggers_xml, $xml_field_mapping, $tracker); } try { $this->rng_validator->validate($xml_trackers, dirname(TRACKER_BASE_DIR) . '/www/resources/trackers.rng'); return $xml_trackers; } catch (XML_ParseException $exception) { foreach ($exception->getErrors() as $parse_error) { fwrite(STDERR, $parse_error . PHP_EOL); } } }
/** * * @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); }
/** * 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; }
/** * getTrackerList - returns an array of Tracker that belongs to the project identified by group_id * * @param string $session_key the session hash associated with the session opened by the person who calls the service * @param int $group_id the ID of the group we want to retrieve the list of trackers * @return array the array of SOAPTracker that belongs to the project identified by $group_id, or a soap fault if group_id does not match with a valid project. */ public function getTrackerList($session_key, $group_id) { try { $current_user = $this->soap_request_validator->continueSession($session_key); $project = $this->getProjectById($group_id, 'getTrackerList'); $this->checkUserCanAccessProject($current_user, $project); // The function getTrackersByGroupId returns all trackers, // even those the user is NOT allowed to view -> we will filter in trackerlist_to_soap $trackers = $this->tracker_factory->getTrackersByGroupId($group_id); return $this->trackerlist_to_soap($trackers, $current_user); } catch (Exception $e) { return new SoapFault((string) $e->getCode(), $e->getMessage()); } }
/** * Retrieve the project trackers that can be used as planning trackers. * * @param Planning $planning The planning for which we want to know the available trackers. * * @return Array of Tracker */ public function getAvailablePlanningTrackers(PFUser $user, $group_id) { $potential_planning_trackers = $this->getPotentialPlanningTrackerIds($user, $group_id); if (count($potential_planning_trackers) > 0) { $existing_plannings = $this->getPlanningTrackerIdsByGroupId($group_id); $trackers = array(); foreach ($potential_planning_trackers as $tracker_id) { if (!in_array($tracker_id, $existing_plannings)) { $trackers[] = $this->tracker_factory->getTrackerById($tracker_id); } } return $trackers; } else { return array_values($this->tracker_factory->getTrackersByGroupId($group_id)); } }
/** * @return array of Tracker */ public function getTrackers(Tracker $tracker) { $trackers = $this->tracker_factory->getTrackersByGroupId($tracker->getGroupId()); return array_diff($trackers, array($tracker)); }
/** * @param int $group_id the project id the trackers to retrieve belong to * * @return Array of Tracker */ public function getAvailableTrackers($group_id) { return array_values($this->tracker_factory->getTrackersByGroupId($group_id)); }