From ac190e223514f144a608a5ee8b2f07c11ef6fc0e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 29 Jun 2006 03:28:28 +0000 Subject: [PATCH] r876: Adding the Atom feed system --- syndicate.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 syndicate.php diff --git a/syndicate.php b/syndicate.php new file mode 100644 index 0000000..13695fb --- /dev/null +++ b/syndicate.php @@ -0,0 +1,124 @@ +in['type'], array('rss', 'atom'))) +{ + define('SYND_TYPE', $bugsys->in['type']); +} + +if (!defined('SYND_TYPE')) +{ + define('SYND_TYPE', 'atom'); +} + +// ################################################################### +// get the syndicated items and prepare their content + +$timestamp = (can_perform('canviewhidden', 0, fetch_guest_user()) ? 'lastposttime' : 'hiddenlastposttime'); +$lastupdated = 0; +$buglist = array(); +$bugs_fetch = $db->query(" + SELECT * FROM " . TABLE_PREFIX . "bug + WHERE productid IN (" . fetch_on_bits('canviewbugs', fetch_guest_user()) . ") + AND (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden', fetch_guest_user()) . "))) + ORDER BY " . (can_perform('canviewhidden', 0, fetch_guest_user()) ? "lastposttime" : "hiddenlastposttime") . " DESC + LIMIT 10" // #*# let this be a setting +); +while ($bug = $db->fetch_array($bugs_fetch)) +{ + $bug['storytext'] = sprintf($lang->string('
Bug ID: %1$s
+
Summary: %2$s
+
Product/Component/Version: %3$s
+
Status: %4$s
+
Severity: %5$s
'), + $bug['bugid'], + $bug['summary'], + $bugsys->datastore['product']["$bug[productid]"]['title'] . '/' . (($bug['componentid']) ? $bugsys->datastore['product']["$bug[componentid]"]['title'] . '/' : '') . $bugsys->datastore['version']["$bug[versionid]"]['version'], + $bugsys->datastore['status']["$bug[status]"]['status'], + $bugsys->datastore['severity']["$bug[severity]"]['severity'] + ); + $buglist["$bug[bugid]"] = $bug; + $lastupdated = $bug["$timestamp"]; +} + +// ################################################################### +// ATOM + +if (SYND_TYPE == 'atom') +{ + $feed = ' + + + ' . sprintf($lang->string('%1$s Syndication Feed'), $bugsys->options['trackertitle']) . ' + + ' . $datef->format('Y-m-d\TH:i:s\Z', $lastupdated) . ' + + + '; + + foreach ($buglist AS $bug) + { + $feed .= ' + + ' . $bugsys->options['trackertitle'] . '/showreport.php?bugid=' . $bug['bugid'] . ' + ' . $bug['summary'] . ' + ' . $datef->format('Y-m-d\TH:i:s\Z', $bug["$timestamp"]) . ' + + ' . $bug['username'] . ' + + ' . $bug['storytext'] . ' + + + + + '; + } + + $feed .= ' + + +'; + + header('Content-type: application/xml'); + echo $feed; + + exit; +} + +// ################################################################### +// RSS + +else if (SYND_TYPE == 'rss') +{ + // not going to be implemented in 1.1 because I don't want to clutter the templates with multiple feed icons and such... +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.43.5