<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
	LabCMS::i()->setModuleTemplate('string:{$xml}');
	LabVars::$break=true;
	LabVars::$template='blank.tpl';
	
	sendXmlHeaders();
	if (LabCMS::i()->is_cached('string:{$xml}', 10*60, 'new_posts')) return;
	
	$url=getServerName();

	$rss=array('title'=>'Багтрекер - '.LabConfig::get('site_name'),
						'link'=>$url.LabCMS::i()->url(),
						'description'=>"Последние комментарии багтрекера ".LabConfig::get('site_name'));
	
	$comments=Db::i()->select("SELECT post_id AS ARRAY_KEY, msg, UNIX_TIMESTAMP(putdate) ut_putdate, putdate, p.user_id, login, summary, p.bug_id FROM ?_bt_posts p JOIN ?_users u ON p.user_id=u.user_id JOIN ?_bt_bugs b ON p.bug_id=b.bug_id ORDER BY putdate DESC LIMIT 50");
	
	if (is_array($comments) && count($comments))
	{
		foreach($comments as $post_id=>$comment)
		{
			$comment['msg_html']=getbb($comment['msg'], 'nolinks');
			$comment['summary_html']=getbb($comment['summary'], 'nolinks');
			
			$rss['feed'][]=array('title'=>$comment['summary_html'],
								'description'=>	$comment['msg_html'],
								'link'=>$url.LabCMS::i()->url($comment['bug_id'], 'item').'#btc'.$post_id,
								'pubDate'=>$comment['ut_putdate']);
		}
	}
	
	$xml=genereteFeed($rss);
	Tpl::i()->assign('xml', $xml);
