]> src.bluestatic.org Git - bugdar.git/blob - syndicate.php
r924: Making sure that we have an APIError() callback set
[bugdar.git] / syndicate.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 define('NO_TEMPLATES', 1);
23
24 require_once('./global.php');
25
26 if (in_array($bugsys->in['type'], array('rss', 'atom')))
27 {
28 define('SYND_TYPE', $bugsys->in['type']);
29 }
30
31 if (!defined('SYND_TYPE'))
32 {
33 define('SYND_TYPE', 'atom');
34 }
35
36 if (!can_perform('canviewbugs'))
37 {
38 $message->error_permission();
39 }
40
41 // ###################################################################
42 // get the syndicated items and prepare their content
43
44 $timestamp = (can_perform('canviewhidden', 0, fetch_guest_user()) ? 'lastposttime' : 'hiddenlastposttime');
45 $lastupdated = 0;
46 $buglist = array();
47 $bugs_fetch = $db->query("
48 SELECT * FROM " . TABLE_PREFIX . "bug
49 WHERE productid IN (" . fetch_on_bits('canviewbugs', fetch_guest_user()) . ")
50 AND (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden', fetch_guest_user()) . ")))
51 ORDER BY " . (can_perform('canviewhidden', 0, fetch_guest_user()) ? "lastposttime" : "hiddenlastposttime") . " DESC
52 LIMIT " . $bugsys->options['syndicateditems']
53 );
54 while ($bug = $db->fetch_array($bugs_fetch))
55 {
56 $bug['storytext'] = sprintf($lang->string('<div><strong>Bug ID:</strong> %1$s</div>
57 <div><strong>Summary:</strong> %2$s</div>
58 <div><strong>Product/Component/Version:</strong> %3$s</div>
59 <div><strong>Status:</strong> %4$s</div>
60 <div><strong>Severity:</strong> %5$s</div>'),
61 $bug['bugid'],
62 $bug['summary'],
63 $bugsys->datastore['product']["$bug[productid]"]['title'] . '/' . (($bug['componentid']) ? $bugsys->datastore['product']["$bug[componentid]"]['title'] . '/' : '') . $bugsys->datastore['version']["$bug[versionid]"]['version'],
64 $bugsys->datastore['status']["$bug[status]"]['status'],
65 $bugsys->datastore['severity']["$bug[severity]"]['severity']
66 );
67 $buglist["$bug[bugid]"] = $bug;
68 $lastupdated = $bug["$timestamp"];
69 }
70
71 // ###################################################################
72 // ATOM
73
74 if (SYND_TYPE == 'atom')
75 {
76 $feed = '<?xml version="1.0" encoding="utf-8"?>
77 <feed xmlns="http://www.w3.org/2005/Atom">
78
79 <title>' . sprintf($lang->string('%1$s Syndication Feed'), $bugsys->options['trackertitle']) . '</title>
80 <link href="' . $bugsys->options['trackerurl'] . '"/>
81 <updated>' . gmdate('Y-m-d\TH:i:s\Z', $lastupdated) . '</updated>
82
83 <!-- entries -->
84 ';
85
86 foreach ($buglist AS $bug)
87 {
88 $feed .= '
89 <entry>
90 <id>' . $bugsys->options['trackertitle'] . '/showreport.php?bugid=' . $bug['bugid'] . '</id>
91 <title>' . $bug['summary'] . '</title>
92 <updated>' . gmdate('Y-m-d\TH:i:s\Z', $bug["$timestamp"]) . '</updated>
93 <author>
94 <name>' . $bug['username'] . '</name>
95 </author>
96 <content>' . $bug['storytext'] . '</content>
97 <summary>
98 <!-- firstreport goes here -->
99 </summary>
100 <link rel="alternate" href="' . $bugsys->options['trackerurl'] . '/showreport.php?bugid=' . $bug['bugid'] . '"/>
101 </entry>';
102 }
103
104 $feed .= '
105 <!-- / entries -->
106
107 </feed>';
108
109 header('Content-type: application/xml');
110 echo $feed;
111
112 exit;
113 }
114
115 // ###################################################################
116 // RSS
117
118 else if (SYND_TYPE == 'rss')
119 {
120 // not going to be implemented in 1.1 because I don't want to clutter the templates with multiple feed icons and such...
121 }
122
123 /*=====================================================================*\
124 || ###################################################################
125 || # $HeadURL$
126 || # $Id$
127 || ###################################################################
128 \*=====================================================================*/
129 ?>