3 * Previous Copyright: FusionForge Team
4 * Copyright 2017, Franck Villaume - TrivialDev
5 * http://fusionforge.org/
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 // export a group's tracker bugs per artifact in RSS 2.0
24 // Author: Jutta Horstmann, data in transit <jh@dataintransit.com>
26 // Based on: export/tracker.php, export/rss20_newreleases.php, tracker/ind.php
28 // Date Author Comment
29 // 07.11.07 JH show only public group feeds
31 //TO DO: Translations for error messages
33 // Keep in mind to write "&" in URLs as & in RSS feeds
35 require_once '../env.inc.php';
36 require_once $gfcommon.'include/pre.php';
37 require_once $gfwww.'export/rss_utils.inc';
39 if (isset($_GET['group_id']) && !empty($_GET['group_id']) && is_numeric($_GET['group_id'])) {
40 $group_id = $_GET['group_id'];
42 $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());
51 } elseif (!$group->isPublic()){
53 endOnError('No RSS feed available as group status is set to private.');
56 beginFeed($group->getPublicName(), '/tracker/?group_id='.$group_id);
58 //does tracker exist? do we get a factory?
59 $atf = new ArtifactTypeFactory($group);
60 if (!$atf || !is_object($atf) || $atf->isError()) {
61 endOnError('Could Not Get ArtifactTypeFactory');
64 $at_arr =& $atf->getArtifactTypes();
66 writeFeed($at_arr,$group_id);
72 endOnError('Please supply a Group ID with the request.');
75 //**************************************************************++
76 function beginFeed($groupname = "", $link = "") {
78 header("Content-Type: text/xml");
79 print '<?xml version="1.0" encoding="UTF-8"?>
83 print " <title>".forge_get_config('forge_name')." Project \"".$groupname."\" Bug Trackers</title>\n";
84 print " <link>".util_make_url($link)."</link>\n";
85 print " <description>".forge_get_config('forge_name')." Bug Trackers of \"".$groupname."\"</description>\n";
86 print " <language>en-us</language>\n";
87 print " <copyright>Copyright 2000-".date("Y")." ".forge_get_config('forge_name')."</copyright>\n";
88 print " <webMaster>".forge_get_config('admin_email')."</webMaster>\n";
89 print " <lastBuildDate>".rss_date(time())."</lastBuildDate>\n";
90 print " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
91 print " <generator>".forge_get_config ('forge_name')." RSS generator</generator>\n";
93 print " <url>".util_make_url('/images/icon.png')."</url>\n";
94 print " <title>".forge_get_config('forge_name')."</title>\n";
95 print " <link>".util_make_url()."</link>\n";
96 print " <width>124</width>\n";
97 print " <heigth>32</heigth>\n";
101 function writeFeed($at_arr, $group_id){
104 //if (isset($limit) ||empty($limit)) $limit = 10;
105 //if ($limit > 100) $limit = 100;
107 if (!$at_arr || empty($at_arr)) {
108 endOnError(_("Tracker RSS: No trackers found"));
111 // Put the result set (list of trackers for this group) into feed items
115 //loop through the bug trackers
116 for ($j = 0; $j < count($at_arr); $j++) {
118 if (!is_object($at_arr[$j])) {
120 } elseif ($at_arr[$j]->isError()) {
121 print " <title>"._('Error')."</title>".
122 "<description>".rss_description($at_arr[$j]->getErrorMessage())."</decription>";
124 print " <title>".$at_arr[$j]->getName()."</title>\n";
125 print " <link>".util_make_url("/tracker?atid=".$at_arr[$j]->getID()."&group_id=".$group_id."&func=browse")."</link>\n";
126 print " <description>".
127 rss_description($at_arr[$j]->getDescription()).
128 " - Open Bugs: ".(int) $at_arr[$j]->getOpenCount() .
129 ", Total Count: ". (int) $at_arr[$j]->getTotalCount() .
131 print " <author></author>\n";
132 //print " <comment></comment>\n";
133 //print " <pubDate>".gmdate('D, d M Y G:i:s',time())." GMT</pubDate>\n";
134 //print " <guid></guid>\n";
135 }//else (everything ok)
139 //if ($outputtotal >= $limit) break;
141 }//else (there are trackers)