<?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, 'bug_list'.$project_id)) return;
		
	$url=getServerName();
	
	$rss=array('title'=>'Багтрекер - '.LabConfig::get('site_name'),
						'link'=>$url.LabCMS::i()->url(),
						'description'=>"Сообщения багтрекера ".LabConfig::get('site_name'));
	
	$bugs=Db::i()->select("SELECT bug_id, summary, UNIX_TIMESTAMP(bug_date) as bug_date, `type`, IF(b.version_id=-1, 'HEAD', version) version, author_id, a.login as author,  b.status, importance
										FROM ?_bt_bugs b
										JOIN ?_users a ON a.user_id=b.author_id
										LEFT JOIN ?_bt_versions v ON b.version_id=v.version_id
										WHERE b.project_id=?
										ORDER BY bug_date DESC
										LIMIT ?d", $project_id, 
										LabConfig::$mcfg['bugs_at_page']);
	if (is_array($bugs))
	foreach($bugs as $key=>$bug)
	{
		$bug['summary_html']=getbb($bug['summary'], 'nolinks');
		
		$rss['feed'][]=array('title'=>$bug['summary_html'].' ['.date("d/m/Y H:i",$bug['bug_date']).']',
							'description'=>	'Тип: '.$bug_types[$bug['type']].
											'<br />Статус: '.$statuses[$bug['status']].
											'<br />Важность: '.$importances[$bug['importance']].
											'<br />Версия: '.$bug['version'].
											'<br />Автор: '.$bug['author'],
							'link'=>$url.LabCMS::i()->url($bug['bug_id'], 'item').'#'.$bug['bug_date'],
							'pubDate'=>$bug['bug_date']);
							
	}

	$xml=genereteFeed($rss);
	Tpl::i()->assign('xml', $xml);
