<?
	function forum_sitemap($module)
	{
		$result=array();
		
		$link=Db::instance()->selectCell("SELECT path FROM ?_tree t JOIN ?_includes i ON t.tree_id=i.tree_id WHERE module_id=? LIMIT 1", $module['module_id']);
		
		$result[$link]=array('changefreq'=>'hourly','lastmod'=>time());
		
		$themes=Db::instance()->selectCol("SELECT theme_id AS ARRAY_KEY, UNIX_TIMESTAMP(last_post) as last_post FROM ?_forum_themes ORDER BY last_post DESC LIMIT 10000");
		if ($themes)
		foreach($themes as $theme_id=>$date)
		{
			$changefreq=getFreq($date);
			$lastmod=date("Y-m-d", $date);
			$loc=LabCMS::instance()->url($theme_id, 'theme', false, $link);
			$result[$loc]=array('changefreq'=>$changefreq,'lastmod'=>$lastmod);
		}
		
		$posts=Db::instance()->selectCol("SELECT post_id AS ARRAY_KEY, UNIX_TIMESTAMP(putdate) as last_post FROM ?_forum_posts ORDER BY post_id DESC");
		$allowPosting=isAllowedPosting($module['module_id']);
		if($posts)
		foreach($posts as $post_id=>$date)
		{
			$changefreq=getFreq($date);
			$lastmod=date("Y-m-d", $date);
			$loc=LabCMS::instance()->url($post_id, 'post', false, $link);
			$result[$loc]=array('changefreq'=>$changefreq,'lastmod'=>$lastmod);
			if ($allowPosting) 
			{
				$loc=LabCMS::instance()->url($post_id, 'reply', false, $link);
				$result[$loc]=array('changefreq'=>$changefreq,'lastmod'=>$lastmod);
			}
		}
		return $result;
	}
	
	function isAllowedPosting($module_id)
	{
		if (file_exists(LAB_PATH_DATA.'/configs/-1_'.$module_id.'.conf'))
		{
			include LAB_PATH_DATA.'/configs/-1_'.$module_id.'.conf';
			return $access['add'];
		}
	}