1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
<?php
/**
* sf_tracker_export.php
*
* SourceForge Exports: Export tracker contents in XML
*
*
* SourceForge: Breaking Down the Barriers to Open Source Development
* Copyright 1999-2001 (c) VA Linux Systems
* http://sourceforge.net
*
* @author Darrell Brogdon <dbrogdon@valinux.com>
* @version $Id: tracker.php 4192 2005-03-26 04:46:16Z tperdue $
*
*/
require_once('pre.php');
require_once('common/tracker/Artifact.class');
require_once('common/tracker/Artifacts.class');
require_once('common/tracker/ArtifactFile.class');
require_once('common/tracker/ArtifactType.class');
require_once('common/tracker/ArtifactCanned.class');
function beginDocument() {
global $sys_default_domain;
header("Content-Type: text/plain");
echo '<tracker version="1.0" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://'.$sys_default_domain.'/export/tracker.xsd">'."\n";
}
function displayError($errorMessage) {
echo '<error>'.$errorMessage.'</error>'."\n";
}
function endDocument() {
echo '</tracker>';
exit();
}
function endOnError($errorMessage) {
displayError($errorMessage);
endDocument();
}
?>
<?php
$group_id = $_GET['group_id'];
$atid = $_GET['atid'];
if ($group_id && $atid) {
//
// get the Group object
//
$group =& group_get_object($group_id);
beginDocument();
if (!$group || !is_object($group)) {
endOnError('Could not get the Group object');
} elseif ($group->isError()) {
endOnError($group->getErrorMessage());
}
//
// Add checks to see if they have perms to view this
//
if (!$group->isPublic()) {
if (!session_loggedin()) {
endOnError('Permission Denied');
$errors = true;
} elseif (!user_ismember($group_id)) {
endOnError('Permission Denied');
}
}
//
// Create the ArtifactType object
//
$ath = new ArtifactType($group,$atid);
if (!$ath || !is_object($ath)) {
endOnError('ArtifactType could not be created');
} elseif ($ath->isError()) {
endOnError($ath->getErrorMessage());
}
//
// Create the Artifacts object
//
$artifacts = new Artifacts($ath);
if (!$artifacts || !is_object($ath)) {
endOnError('Artifacts could not be created');
}
if ($artifacts->isError()) {
endOnError($artifacts->getErrorMessage());
}
//
// Loop through each artifact object and show the results
//
if (!$alist =& $artifacts->getArtifacts($offset)) {
displayError($artifacts->getErrorMessage());
$errors = true;
}
if ($errors) {
endDocument();
}
for ($i=0; $i<count($alist); $i++) {
?>
<artifact id="<?php echo $alist[$i]->getID(); ?>">
<submitted_by><?php echo $alist[$i]->getSubmittedUnixName(); ?></submitted_by>
<submitted_date><?php echo date( $sys_datefmt, $alist[$i]->getOpenDate() ); ?></submitted_date>
<artifact_type id="<?php echo $ath->getID(); ?>"><?php echo $ath->getID(); ?></artifact_type>
<assigned_to><?php echo $alist[$i]->getAssignedRealName(); ?></assigned_to>
<priority id="<?php echo $alist[$i]->getPriority(); ?>"><?php echo $alist[$i]->getPriority(); ?></priority>
<status><?php echo $alist[$i]->getStatusName(); ?></status>
<resolution><?php echo $alist[$i]->getResolutionName(); ?></resolution>
<summary><?php echo $alist[$i]->getSummary(); ?></summary>
<detail><?php echo $alist[$i]->getDetails(); ?></detail>
<?php
$result = $alist[$i]->getMessages();
$rows = db_numrows($result);
if ($rows > 0) {
?>
<follow_ups>
<?php
for ($x=0; $x<$rows; $x++) {
?>
<item>
<date><?php echo db_result($result, $x, 'adddate'); ?></date>
<sender><?php echo db_result($result, $x, 'user_name'); ?></sender>
<text><?php echo db_result($result, $x, 'body'); ?></text>
</item>
<?php
}
?>
</follow_ups>
<?php
}
$file_list =& $alist[$i]->getFiles();
$count=count($file_list);
if ($count > 0) {
?>
<existingfiles>
<?php
for ($x=0; $x<$count; $x++) {
?>
<file>
<id><?php echo $file_list[$x]->getID(); ?></id>
<name><?php echo $file_list[$x]->getName(); ?></name>
<description><?php echo $file_list[$x]->getDescription(); ?></description>
<filesize><?php echo $file_list[$x]->getSize(); ?></filesize>
<filetype><?php echo $file_list[$x]->getType(); ?></filetype>
<adddate><?php echo $file_list[$x]->getDate(); ?></adddate>
<submitted_by><?php echo $file_list[$x]->getSubmittedBy(); ?></submitted_by>
</file>
<?php
}
?>
</existingfiles>
<?php
}
$result = $alist[$i]->getHistory();
$rows = db_numrows($result);
if ($rows > 0) {
?>
<change_log>
<?php
for ($x=0; $x<$rows; $x++) {
?>
<item>
<field><?php echo db_result($result, $x, 'field_name'); ?></field>
<old_value><?php echo db_result($result, $x, 'old_value'); ?></old_value>
<date><?php echo db_result($result, $x, 'entrydate'); ?></date>
<by><?php echo db_result($result, $x, 'user_name'); ?></by>
</item>
<?php
}
?>
</change_log>
<?php
}
?>
</artifact>
</tracker>
<?php
}
} else {
beginDocument();
displayError('Group ID or Artifact ID Not Set');
endDocument();
}
?>
|