r1032: - Removing concat $feed variable in place of just echo()ing out content
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 14 Aug 2006 21:42:31 +0000 (21:42 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 14 Aug 2006 21:42:31 +0000 (21:42 +0000)
- Include bug.initialreport information in the output
- Use a table to format data
- Convert all angle brackets to entities in <content> to make things render in RSS browsers

syndicate.php

index 1537cb8a63e5dbac742eaa518e2e3f04862d17e5..226825d09f162aa3e03341849610e963d9e69bab 100644 (file)
@@ -45,24 +45,47 @@ $timestamp = (can_perform('canviewhidden', 0, fetch_guest_user()) ? 'lastposttim
 $lastupdated = 0;
 $buglist = array();
 $bugs_fetch = $db->query("
-       SELECT * FROM " . TABLE_PREFIX . "bug
-       WHERE product IN (" . fetch_on_bits('canviewbugs', fetch_guest_user()) . ")
-               AND (!hidden OR (hidden AND product IN (" . fetch_on_bits('canviewhidden', fetch_guest_user()) . ")))
-       ORDER BY " . (can_perform('canviewhidden', 0, fetch_guest_user()) ? "lastposttime" : "hiddenlastposttime") . " DESC
+       SELECT bug.*, comment.comment_parsed
+       FROM " . TABLE_PREFIX . "bug
+       LEFT JOIN " . TABLE_PREFIX . "comment
+               ON (bug.initialreport = comment.commentid)
+       WHERE bug.product IN (" . fetch_on_bits('canviewbugs', fetch_guest_user()) . ")
+               AND (!bug.hidden OR (bug.hidden AND bug.product IN (" . fetch_on_bits('canviewhidden', fetch_guest_user()) . ")))
+       ORDER BY " . (can_perform('canviewhidden', 0, fetch_guest_user()) ? "bug.lastposttime" : "bug.hiddenlastposttime") . " DESC
        LIMIT " . $bugsys->options['syndicateditems']
 );
 while ($bug = $db->fetch_array($bugs_fetch))
 {
-       $bug['storytext'] = sprintf($lang->string('<div><strong>Bug ID:</strong> %1$s</div>
-<div><strong>Summary:</strong> %2$s</div>
-<div><strong>Product/Component/Version:</strong> %3$s</div>
-<div><strong>Status:</strong> %4$s</div>
-<div><strong>Severity:</strong> %5$s</div>'),
+       $bug['storytext'] = sprintf(str_replace(array('<', '>'), array('&lt;', '&gt;'),
+               $lang->string('<table cellspacing="0" cellpadding="3" border="0">
+<tr>
+       <td><strong>Bug ID:</strong></td>
+       <td>%1$s<//td>
+</tr>
+<tr>
+       <td><strong>Summary:</strong></td>
+       <td>%2$s</td>
+</tr>
+<tr>
+       <td><strong>Product/Component/Version:</strong></td>
+       <td>%3$s</td>
+</tr>
+<tr>
+       <td><strong>Status:</strong></td>
+       <td>%4$s</td>
+</tr>
+<tr>
+       <td><strong>Severity:</strong></td>
+       <td>%5$s</td>
+</table>
+
+<p>%6$s</p>')),
                $bug['bugid'],
                $bug['summary'],
                $bugsys->datastore['product']["$bug[product]"]['title'] . '/' . (($bug['component']) ? $bugsys->datastore['product']["$bug[component]"]['title'] . '/' : '') . $bugsys->datastore['version']["$bug[version]"]['version'],
                $bugsys->datastore['status']["$bug[status]"]['status'],
-               $bugsys->datastore['severity']["$bug[severity]"]['severity']
+               $bugsys->datastore['severity']["$bug[severity]"]['severity'],
+               $bug['comment_parsed']
        );
        $buglist["$bug[bugid]"] = $bug;
        $lastupdated = $bug["$timestamp"];
@@ -73,7 +96,9 @@ while ($bug = $db->fetch_array($bugs_fetch))
 
 if (SYND_TYPE == 'atom')
 {
-       $feed = '<?xml version="1.0" encoding="utf-8"?>
+       header('Content-type: application/xml');
+       
+       echo '<?xml version="1.0" encoding="utf-8"?>
 <feed xmlns="http://www.w3.org/2005/Atom">
 
        <title>' . sprintf($lang->string('%1$s Syndication Feed'), $bugsys->options['trackertitle']) . '</title>
@@ -85,7 +110,7 @@ if (SYND_TYPE == 'atom')
        
        foreach ($buglist AS $bug)
        {
-               $feed .= '
+               echo '
        <entry>
                <id>' . $bugsys->options['trackertitle'] . '/showreport.php?bugid=' . $bug['bugid'] . '</id>
                <title>' . $bug['summary'] . '</title>
@@ -94,21 +119,16 @@ if (SYND_TYPE == 'atom')
                        <name>' . $bug['username'] . '</name>
                </author>
                <content>' . $bug['storytext'] . '</content>
-               <summary>
-                       <!-- firstreport goes here -->
-               </summary>
+               <summary>' . htmlspecialchars($bug['comment_parsed']) . '</summary>
                <link rel="alternate" href="' . $bugsys->options['trackerurl'] . '/showreport.php?bugid=' . $bug['bugid'] . '"/>
        </entry>';
        }
        
-       $feed .= '
+       echo '
        <!-- / entries -->
 
 </feed>';
-       
-       header('Content-type: application/xml');
-       echo $feed;
-       
+
        exit;
 }