public function exportTrackerData($tracker_id)
 {
     $artifacts_node = $this->node_helper->createElement('artifacts');
     foreach ($this->dao->searchArtifacts($tracker_id) as $row) {
         $artifact_exporter = new ArtifactXMLExporterArtifact($this->dao, $this->attachment_exporter, $this->node_helper, $this->logger);
         $artifact_node = $artifact_exporter->exportArtifact($tracker_id, $row);
         $artifacts_node->appendChild($artifact_node);
     }
     $this->node_helper->appendChild($artifacts_node);
 }
 private function appendPreviousAttachements(DOMElement $field_node, $artifact_id, $submitted_on, $old_value)
 {
     $previous_attachements = array_filter(explode(',', $old_value));
     foreach ($previous_attachements as $attachement) {
         $dar = $this->dao->searchFileBefore($artifact_id, $attachement, $submitted_on);
         if ($dar && $dar->rowCount() == 1) {
             $row_file = $dar->current();
             $field_node->appendChild($this->getNodeValueForFile($row_file['id']));
         }
     }
 }
 public function addFilesToArtifact(DOMElement $artifact_node, $artifact_type_id, $artifact_id)
 {
     $dar = $this->dao->searchFilesForArtifact($artifact_id);
     foreach ($dar as $row) {
         $xml_file_id = ArtifactAttachmentFieldXMLExporter::XML_FILE_PREFIX . $row['id'];
         $file = $this->node_helper->createElement('file');
         $file->setAttribute('id', $xml_file_id);
         $file->appendChild($this->node_helper->getNodeWithValue('filename', $row['filename']));
         $file->appendChild($this->node_helper->getNodeWithValue('path', $this->getPathRelativeToTv3RootPath($artifact_type_id, $row['id'])));
         $file->appendChild($this->node_helper->getNodeWithValue('filesize', $row['filesize']));
         $file->appendChild($this->node_helper->getNodeWithValue('filetype', $row['filetype']));
         $file->appendChild($this->node_helper->getNodeWithValue('description', $row['description']));
         $artifact_node->appendChild($file);
     }
 }
 private function getValueLabel($tracker_id, $artifact_id, $field_name, $value)
 {
     if ($field_name == self::SPECIAL_SEVERITY && $value == 0) {
         return '';
     }
     if ($value == 100) {
         return '';
     }
     $values_list = $this->dao->searchFieldValuesList($tracker_id, $field_name);
     if (!$values_list) {
         return '';
     }
     foreach ($values_list as $row) {
         if ($row['value_id'] == $value) {
             return Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($row['value']);
         }
     }
     throw new Exception_TV3XMLException("Unknown label for {$artifact_id} {$value}");
 }
 private function fetchListValueLabels(array $field_value_row, $tracker_id)
 {
     $field_name = $this->getFieldNameFromRow($field_value_row);
     if (empty($this->labels[$field_name])) {
         $values_label_rows = $this->dao->searchFieldValuesList($tracker_id, $field_name);
         foreach ($values_label_rows as $values_label_row) {
             $this->labels[$field_name][$values_label_row['value_id']] = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($values_label_row['value']);
         }
     }
 }
 private function getListValueLabels(array $field_value_row, $tracker_id)
 {
     $field_name = $field_value_row['field_name'];
     $labels = array();
     $values_label_rows = $this->dao->searchFieldValuesList($tracker_id, $field_name);
     foreach ($values_label_rows as $values_label_row) {
         $labels[$values_label_row['value_id']] = $values_label_row['value'];
     }
     return $labels;
 }
 public function appendNode(DOMElement $artifact_node, $artifact_id)
 {
     $list_of_changesets = $artifact_node->getElementsByTagName('changeset');
     if ($list_of_changesets->length == 0) {
         return;
     }
     $permissions = $this->dao->searchPermsForArtifact($artifact_id);
     if (!count($permissions)) {
         return;
     }
     $last_changeset_node = $list_of_changesets->item($list_of_changesets->length - 1);
     $field_node = $this->node_helper->createElement('field_change');
     $field_node->setAttribute('field_name', 'permissions_on_artifact');
     $field_node->setAttribute('type', 'permissions_on_artifact');
     $field_node->setAttribute('use_perm', '1');
     foreach ($permissions as $row) {
         $ugroup_node = $this->node_helper->createElement('ugroup');
         $ugroup_node->setAttribute('ugroup_id', $row['ugroup_id']);
         $field_node->appendChild($ugroup_node);
     }
     $last_changeset_node->appendChild($field_node);
 }
 public function addFilesToArtifact(DOMElement $artifact_node, $artifact_type_id, $artifact_id)
 {
     $dar = $this->dao->searchFilesForArtifact($artifact_id);
     if (count($dar)) {
         $this->archive->addEmptyDir(ArtifactXMLExporter::ARCHIVE_DATA_DIR);
     }
     foreach ($dar as $row) {
         $xml_file_id = ArtifactAttachmentFieldXMLExporter::XML_FILE_PREFIX . $row['id'];
         $path_in_archive = $this->getFilePathInArchive($xml_file_id);
         if ($this->skip_files) {
             $this->archive->addFromString($path_in_archive, '');
         } else {
             $this->archive->addFile($this->getFilePathOnServer($artifact_type_id, $row['id']), $path_in_archive);
         }
         $file = $this->node_helper->createElement('file');
         $file->setAttribute('id', $xml_file_id);
         $file->appendChild($this->node_helper->getNodeWithValue('filename', $row['filename']));
         $file->appendChild($this->node_helper->getNodeWithValue('path', $this->getFilePathInArchive($xml_file_id)));
         $file->appendChild($this->node_helper->getNodeWithValue('filesize', $row['filesize']));
         $file->appendChild($this->node_helper->getNodeWithValue('filetype', $row['filetype']));
         $file->appendChild($this->node_helper->getNodeWithValue('description', $row['description']));
         $artifact_node->appendChild($file);
     }
 }
 private function getCurrentFieldsValues($tracker_id, $artifact_id, array $artifact_row)
 {
     $fields_values = array(array('field_name' => 'summary', 'display_type' => ArtifactStringFieldXMLExporter::TV3_DISPLAY_TYPE, 'data_type' => ArtifactStringFieldXMLExporter::TV3_DATA_TYPE, 'valueText' => $artifact_row['summary'], 'value_function' => ''));
     if (isset($artifact_row['details'])) {
         $fields_values[] = array('field_name' => 'details', 'display_type' => ArtifactTextFieldXMLExporter::TV3_DISPLAY_TYPE, 'data_type' => ArtifactTextFieldXMLExporter::TV3_DATA_TYPE, 'valueText' => $artifact_row['details'], 'value_function' => '');
     }
     if (isset($artifact_row['severity']) && $artifact_row['severity']) {
         $fields_values[] = array('field_name' => 'severity', 'display_type' => ArtifactStaticListFieldXMLExporter::TV3_DISPLAY_TYPE, 'data_type' => ArtifactStaticListFieldXMLExporter::TV3_DATA_TYPE, 'valueInt' => $artifact_row['severity'], 'value_function' => '');
     }
     if (isset($artifact_row['close_date']) && $artifact_row['close_date']) {
         $fields_values[] = array('field_name' => 'close_date', 'display_type' => ArtifactDateFieldXMLExporter::TV3_DISPLAY_TYPE, 'data_type' => ArtifactDateFieldXMLExporter::TV3_DATA_TYPE, 'valueDate' => $artifact_row['close_date'], 'value_function' => '');
     }
     if (isset($artifact_row['status_id']) && $artifact_row['status_id']) {
         $fields_values[] = array('field_name' => 'status_id', 'display_type' => ArtifactStaticListFieldXMLExporter::TV3_DISPLAY_TYPE, 'data_type' => ArtifactStaticListFieldXMLExporter::TV3_DATA_TYPE, 'valueInt' => $artifact_row['status_id'], 'value_function' => '');
     }
     foreach ($this->dao->searchFieldValues($artifact_id) as $row) {
         $fields_values[$row['field_name']] = $this->field_factory->getCurrentFieldValue($row, $tracker_id);
     }
     return array_filter($fields_values);
 }