<?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, 'last_posts'.$forum_info['theme_id'])) return;
	
	$posts=Db::i()->select("SELECT subject, fp.post_id, fp.theme_id, IF (u.user_id>0, login, fp.user_name) as user_name, fp.msg, UNIX_TIMESTAMP(putdate) as `date`
						FROM ?_forum_posts fp 
						JOIN ?_forum_themes ft ON fp.theme_id=ft.theme_id
						LEFT JOIN ?_users u ON fp.user_id=u.user_id
						ORDER BY putdate DESC
						LIMIT 50", $forum_info['theme_id']);
	
	$url=getServerName();
	
	$rss=array('title'=>'Последние сообщения - '.LabConfig::get('site_name'),
						'link'=>$url.LabCMS::i()->url(),
						'description'=>"Последние сообщения в форуме http://".$_SERVER['SERVER_NAME']);
						
	foreach($posts as $key=>$post)
	{
		$post['msg_html']=getbb($post['msg']);
		
		$rss['feed'][]=array('title'=>getbb($post['subject'], 'nolinks'),
							'description'=>'<b>'.htmlspecialchars($post['user_name']).'</b><br />'.$post['msg_html'],
							'link'=>$url.LabCMS::i()->url(array($post['theme_id'], 999), 'theme').'#p'.$post['post_id'],
							'pubDate'=>$post['date']);
	}

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