3 * sf_tracker_export.php
5 * SourceForge Exports: Export tracker contents in XML
8 * SourceForge: Breaking Down the Barriers to Open Source Development
9 * Copyright 1999-2001 (c) VA Linux Systems
10 * http://sourceforge.net
12 * @author Darrell Brogdon <dbrogdon@valinux.com>
15 require_once('../env.inc.php');
16 require_once $gfwww.'include/pre.php';
17 require_once $gfcommon.'tracker/Artifact.class.php';
18 require_once $gfcommon.'tracker/Artifacts.class.php';
19 require_once $gfcommon.'tracker/ArtifactFile.class.php';
20 require_once $gfcommon.'tracker/ArtifactType.class.php';
21 require_once $gfcommon.'tracker/ArtifactCanned.class.php';
23 function beginDocument() {
25 header("Content-Type: text/plain");
26 echo '<tracker version="1.0" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://'.forge_get_config('web_host').'/export/tracker.xsd">'."\n";
29 function displayError($errorMessage) {
30 echo '<error>'.$errorMessage.'</error>'."\n";
33 function endDocument() {
38 function endOnError($errorMessage) {
39 displayError($errorMessage);
47 $group_id = getIntFromRequest('group_id');
48 $atid = getIntFromRequest('atid');
49 $offset = getIntFromRequest('offset');
51 if ($group_id && $atid) {
53 // get the Group object
55 $group =& group_get_object($group_id);
58 if (!$group || !is_object($group)) {
59 endOnError('Could not get the Group object');
60 } elseif ($group->isError()) {
61 endOnError($group->getErrorMessage());
65 // Add checks to see if they have perms to view this
67 if (!$group->isPublic()) {
68 if (!session_loggedin()) {
69 endOnError('Permission Denied');
71 } elseif (!user_ismember($group_id)) {
72 endOnError('Permission Denied');
76 // Create the ArtifactType object
78 $ath = new ArtifactType($group,$atid);
79 if (!$ath || !is_object($ath)) {
80 endOnError('ArtifactType could not be created');
81 } elseif ($ath->isError()) {
82 endOnError($ath->getErrorMessage());
86 // Create the Artifacts object
88 $artifacts = new Artifacts($ath);
89 if (!$artifacts || !is_object($ath)) {
90 endOnError('Artifacts could not be created');
92 if ($artifacts->isError()) {
93 endOnError($artifacts->getErrorMessage());
97 // Loop through each artifact object and show the results
99 if (!$alist =& $artifacts->getArtifacts($offset)) {
100 displayError($artifacts->getErrorMessage());
108 for ($i=0; $i<count($alist); $i++) {
110 <artifact id="<?php echo $alist[$i]->getID(); ?>">
111 <submitted_by><?php echo $alist[$i]->getSubmittedUnixName(); ?></submitted_by>
112 <submitted_date><?php echo date( _('Y-m-d H:i'), $alist[$i]->getOpenDate() ); ?></submitted_date>
113 <artifact_type id="<?php echo $ath->getID(); ?>"><?php echo $ath->getID(); ?></artifact_type>
114 <assigned_to><?php echo $alist[$i]->getAssignedRealName(); ?></assigned_to>
115 <priority id="<?php echo $alist[$i]->getPriority(); ?>"><?php echo $alist[$i]->getPriority(); ?></priority>
116 <status><?php echo $alist[$i]->getStatusName(); ?></status>
117 <resolution><?php echo $alist[$i]->getResolutionName(); ?></resolution>
118 <summary><?php echo $alist[$i]->getSummary(); ?></summary>
119 <detail><?php echo $alist[$i]->getDetails(); ?></detail>
121 $result = $alist[$i]->getMessages();
122 $rows = db_numrows($result);
127 for ($x=0; $x<$rows; $x++) {
130 <date><?php echo db_result($result, $x, 'adddate'); ?></date>
131 <sender><?php echo db_result($result, $x, 'user_name'); ?></sender>
132 <text><?php echo db_result($result, $x, 'body'); ?></text>
141 $file_list =& $alist[$i]->getFiles();
142 $count=count($file_list);
147 for ($x=0; $x<$count; $x++) {
150 <id><?php echo $file_list[$x]->getID(); ?></id>
151 <name><?php echo $file_list[$x]->getName(); ?></name>
152 <description><?php echo $file_list[$x]->getDescription(); ?></description>
153 <filesize><?php echo $file_list[$x]->getSize(); ?></filesize>
154 <filetype><?php echo $file_list[$x]->getType(); ?></filetype>
155 <adddate><?php echo $file_list[$x]->getDate(); ?></adddate>
156 <submitted_by><?php echo $file_list[$x]->getSubmittedBy(); ?></submitted_by>
165 $result = $alist[$i]->getHistory();
166 $rows = db_numrows($result);
172 for ($x=0; $x<$rows; $x++) {
175 <field><?php echo db_result($result, $x, 'field_name'); ?></field>
176 <old_value><?php echo db_result($result, $x, 'old_value'); ?></old_value>
177 <date><?php echo db_result($result, $x, 'entrydate'); ?></date>
178 <by><?php echo db_result($result, $x, 'user_name'); ?></by>
193 displayError('Group ID or Artifact ID Not Set');