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); } } }
public function process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user) { $validator = new Tracker_Workflow_Trigger_TriggerValidator($this->rule_manager); try { $rules_factory = new Tracker_Workflow_Trigger_RulesFactory($this->formelement_factory, $validator); $rule = $rules_factory->getRuleFromJson($this->tracker, $request->getJsonDecodedBody()); $this->rule_manager->add($rule); echo $rule->getId(); } catch (Tracker_Exception $exception) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $exception->getMessage()); $GLOBALS['Response']->sendStatusCode(400); } }
public function process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user) { try { if (!$request->isPost()) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, 'Method must be post'); $GLOBALS['Response']->sendStatusCode(405); return false; } $rule = $this->rule_manager->getRuleById($request->getValidated('id', 'uint', 0)); $this->rule_manager->delete($this->tracker, $rule); } catch (Tracker_Exception $exception) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $exception->getMessage()); $GLOBALS['Response']->sendStatusCode(400); } }
/** * Execute actions after transition happens (if there is one) * * @param PFUser $user The user who changed things * @param Array $fields_data Request field data (array[field_id] => data) * @param Tracker_Artifact_Changeset $new_changeset The changeset that has just been created * @param Tracker_Artifact_Changeset $previous_changeset The changeset just before (null for a new artifact) * * @return void */ public function after(array $fields_data, Tracker_Artifact_Changeset $new_changeset, Tracker_Artifact_Changeset $previous_changeset = null) { $this->logger->defineFingerprint($new_changeset->getArtifact()->getId()); $this->logger->start(__METHOD__, $new_changeset->getId(), $previous_changeset ? $previous_changeset->getId() : 'null'); if (isset($fields_data[$this->getFieldId()])) { $transition = $this->getCurrentTransition($fields_data, $previous_changeset); if ($transition) { $transition->after($new_changeset); } } $this->trigger_rules_manager->processTriggers($new_changeset); $this->logger->end(__METHOD__, $new_changeset->getId(), $previous_changeset ? $previous_changeset->getId() : 'null'); }
/** * @param int $group_id * @param SimpleXMLElement $xml_input * * @throws XML_ParseException * @return Tracker[] */ public function import($group_id, SimpleXMLElement $xml_input) { if (!$xml_input->trackers) { return; } $this->xmlFieldsMapping = array(); $created_trackers_list = array(); $this->rng_validator->validate($xml_input->trackers, dirname(TRACKER_BASE_DIR) . '/www/resources/trackers.rng'); foreach ($this->getAllXmlTrackers($xml_input) as $xml_tracker_id => $xml_tracker) { $created_tracker = $this->instanciateTrackerFromXml($group_id, $xml_tracker_id, $xml_tracker); $created_trackers_list = array_merge($created_trackers_list, $created_tracker); } $this->importHierarchy($xml_input, $created_trackers_list); if (isset($xml_input->trackers->triggers)) { $this->trigger_rulesmanager->createFromXML($xml_input->trackers->triggers, $this->xmlFieldsMapping); } $this->event_manager->processEvent(Event::IMPORT_XML_PROJECT_TRACKER_DONE, array('project_id' => $group_id, 'xml_content' => $xml_input, 'mapping' => $created_trackers_list)); return $created_trackers_list; }
/** * @see Tracker_FormElement_Field_ArtifactLink_PostSaveNewChangesetCommand::execute() */ public function execute(Tracker_Artifact $artifact, PFUser $submitter, Tracker_Artifact_Changeset $new_changeset, Tracker_Artifact_Changeset $previous_changeset = null) { if ($this->hasChanges($new_changeset, $previous_changeset)) { $this->trigger_rules_manager->processChildrenTriggers($artifact); } }