Source for file boards_rss.php
Documentation is available at boards_rss.php
require_once( "../kernel/setup_inc.php" );
$gBitSystem->verifyPackage( 'boards' );
$gBitSystem->verifyPackage( 'rss' );
require_once( RSS_PKG_PATH. "rss_inc.php" );
// Load up the board or topic
require_once( BOARDS_PKG_PATH. 'lookup_inc.php' );
if( !empty( $_REQUEST['t'] ) || !empty($_REQUEST['b'] ) ){
if( $gContent->isValid() ){
$gBitSystem->fatalError(tra("Unknown discussion"), NULL, NULL, HttpStatusCodes::HTTP_GONE );
$gContent->verifyViewPermission();
// check if we want to use the cache file
// HTTP_HOST is needed beacuse people subscribe to RSS via different URLs (docs.bw.o and www.bw.o for example)
// cached versions of other URLs will double posts
// $cacheFile = TEMP_PKG_PATH.RSS_PKG_NAME.'/'.BOARDS_PKG_NAME.'/'.$_SERVER['HTTP_HOST']."_".$cacheFileTail;
$cacheFile = TEMP_PKG_PATH. RSS_PKG_NAME. '/'. BOARDS_PKG_NAME. '/'. $_SERVER['HTTP_HOST'];
// BitTopic acts strange and does not set mContentTypeGuid
switch( $gContent->getField('content_type_guid') ){
$cacheFile .= '_comment'. $_REQUEST['t'];
if( $gContent->isValid() ){
$cacheFile .= '_board'. $_REQUEST['b'];
$cacheFile.= "_". $cacheFileTail;
$rss->useCached( $rss_version_name, $cacheFile, $gBitSystem->getConfig( 'rssfeed_cache_time' ));
$title = tra("Recent Discussions");
$description = tra("All recent forum discussions on ". $gBitSystem->getConfig( 'site_title' ) );
if( $gContent->isValid() ){
$title = $gContent->getField( 'title' ). " Feed";
$description = $gContent->getField( 'parsed_data' );
$rss->description = $description;
$rss->link = $gContent->getDisplayUri();
// get all topics of a board or all recent topics in general
switch( $gContent->getField('content_type_guid') ){
// need to use post class to get list of comments
// pass in a reference to the root object so that we can do proper permissions checks
$gComment->mRootObj = $gContent;
$feeds = $gComment->getComments( $gContent->mContentId, $gBitSystem->getConfig( 'boards_rss_max_records', 10 ), 0, 'commentDate_desc', 'flat' );
if( !empty( $_REQUEST['b'] ) ) {
$pParamHash['b'] = $_REQUEST['b'];
$pParamHash['sort_mode'] = "llc_last_modified_desc";
$pParamHash['max_records'] = $gBitSystem->getConfig( 'boards_rss_max_records', 10 );
$pParamHash['offset'] = 0;
$feeds = $topic->getList( $pParamHash );
// get all the data ready for the feed creator
foreach( $feeds as $feed ) {
$item->title = $feed['title'];
$item->source = 'http://'. $_SERVER['HTTP_HOST']. BIT_ROOT_URL;
switch( $gContent->getField('content_type_guid') ){
$item->link = 'http://'. $_SERVER['HTTP_HOST']. BIT_ROOT_URL. 'index.php?content_id='. $feed['content_id']; //comment paths are tricky, but work automagically through the front door
$item->description = $feed['parsed_data'];
$item->date = ( int ) $feed['last_modified'];
$user = new BitUser($feed['user_id']);
if ($gBitUser->isRegistered()) {
if (!empty($feed['track']['on'])&& $feed['track']['mod']) {
$item->title = "[NEW] " . $item->title;
if( !empty( $feed['th_sticky'] ) ) {
$item->title = "[!] " . $item->title;
if( !empty( $feed['th_locked'] ) ) {
$item->title = "[#] " . $item->title;
$item->link = 'http://'. $_SERVER['HTTP_HOST']. $feed['url'];
$item->description = $data['data'];
//TODO allow proper sort order
//$item->date = ( int )$feed['event_date'];
$item->date = ( int ) $feed['llc_last_modified'];
$user = new BitUser($feed['llc_user_id']);
$item->author = $user->getDisplayName();//$gBitUser->getDisplayName( FALSE, array( 'user_id' => $feed['modifier_user_id'] ) );
$item->authorEmail = $user->mInfo['email'];
$item->descriptionTruncSize = $gBitSystem->getConfig( 'rssfeed_truncate', 1000 );
$item->descriptionHtmlSyndicated = FALSE;
// pass the item on to the rss feed creator
// finally we are ready to serve the data
echo $rss->saveFeed( $rss_version_name, $cacheFile );
|