3 * http://fusionforge.org/
5 * This file is part of FusionForge. FusionForge is free software;
6 * you can redistribute it and/or modify it under the terms of the
7 * GNU General Public License as published by the Free Software
8 * Foundation; either version 2 of the Licence, or (at your option)
11 * FusionForge is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 // export a group's tracker bugs per artifact in RSS 2.0
23 // Author: Jutta Horstmann, data in transit <jh@dataintransit.com>
25 // Based on: export/tracker.php, export/rss20_newreleases.php, tracker/ind.php
27 // Date Author Comment
28 // 07.11.07 JH show only public group feeds
30 //TO DO: Translations for error messages
32 // Keep in mind to write "&" in URLs as & in RSS feeds
34 require_once '../env.inc.php';
35 require_once $gfcommon.'include/pre.php';
36 require_once $gfwww.'export/rss_utils.inc';
38 if (isset($_GET['group_id'])&&!empty($_GET['group_id'])&&is_numeric($_GET['group_id'])) {
39 $group_id = $_GET['group_id'];
41 $group =& group_get_object($group_id);
44 //does group exist? do we get an object?
45 if (!$group || !is_object($group)) {
47 endOnError('Could not get the Group object');
48 } elseif ($group->isError()) {
50 endOnError($group->getErrorMessage());
52 elseif (!$group->isPublic()){
54 endOnError('No RSS feed available as group status is set to private.');
56 $groupname = $group->getPublicName();
57 $link = "/tracker/?group_id=$group_id";
59 beginFeed($groupname,$link);
61 //does tracker exist? do we get a factory?
62 $atf = new ArtifactTypeFactory($group);
63 if (!$atf || !is_object($atf) || $atf->isError()) {
64 endOnError('Could Not Get ArtifactTypeFactory');
67 $at_arr =& $atf->getArtifactTypes();
69 writeFeed($at_arr,$group_id);
75 displayError('Please supply a Group ID with the request.');
79 //**************************************************************++
80 function beginFeed($groupname = "", $link = "") {
82 header("Content-Type: text/xml");
83 print '<?xml version="1.0" encoding="UTF-8"?>
87 print " <title>".forge_get_config('forge_name')." Project \"".$groupname."\" Bug Trackers</title>\n";
88 print " <link>http://".forge_get_config('web_host').$link."</link>\n";
89 print " <description>".forge_get_config('forge_name')." Bug Trackers of \"".$groupname."\"</description>\n";
90 print " <language>en-us</language>\n";
91 print " <copyright>Copyright 2000-".date("Y")." ".forge_get_config('forge_name')."</copyright>\n";
92 print " <webMaster>".forge_get_config('admin_email')."</webMaster>\n";
93 print " <lastBuildDate>".gmdate('D, d M Y G:i:s',time())." GMT</lastBuildDate>\n";
94 print " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
96 print " <url>http://".forge_get_config('web_host')."/images/bflogo-88.png</url>\n";
97 print " <title>".forge_get_config('forge_name')." Developer</title>\n";
98 print " <link>http://".forge_get_config('web_host')."/</link>\n";
99 print " <width>124</width>\n";
100 print " <heigth>32</heigth>\n";
104 function writeFeed($at_arr, $group_id){
107 //if (isset($limit) ||empty($limit)) $limit = 10;
108 //if ($limit > 100) $limit = 100;
110 if (!$at_arr || count($at_arr) < 1) {
111 endOnError(_("Tracker RSS: No trackers found"));
114 // Put the result set (list of trackers for this group) into feed items
118 //loop through the bug trackers
119 for ($j = 0; $j < count($at_arr); $j++) {
121 if (!is_object($at_arr[$j])) {
123 } elseif ($at_arr[$j]->isError()) {
124 print " <title>Error</title>".
125 "<description>".rss_description($at_arr[$j]->getErrorMessage())."</decription>";
127 print " <title>".$at_arr[$j]->getName()."</title>\n";
128 print " <link>http://".forge_get_config('web_host')."/tracker?atid=".$at_arr[$j]->getID()."&group_id=".$group_id."&func=browse</link>\n";
129 print " <description>".
130 rss_description($at_arr[$j]->getDescription()).
131 " - Open Bugs: ".(int) $at_arr[$j]->getOpenCount() .
132 ", Total Count: ". (int) $at_arr[$j]->getTotalCount() .
134 print " <author></author>\n";
135 //print " <comment></comment>\n";
136 //print " <pubDate>".gmdate('D, d M Y G:i:s',time())." GMT</pubDate>\n";
137 //print " <guid></guid>\n";
138 }//else (everything ok)
142 //if ($outputtotal >= $limit) break;
144 }//else (there are trackers)
148 function displayError($errorMessage) {
149 print " <title>Error</title>".
150 "<description>".rss_description($errorMessage)."</description>";
154 print '</channel></rss>';
158 function endOnError($errorMessage) {
159 displayError($errorMessage);