<?php
/*
=====================================================
 Модуль создал: REZER (http://rezer.net)
=====================================================
 Файл: my.post.php
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Назначение: вывод всех объявлений пользователя
=====================================================
*/

if( !defined( "DATALIFEENGINE" ) ) die( "Hacking attempt!" );

if( !function_exists( "echoBlock" ) )
	{
		function echoBlock( $id ){
			global $Board, $tpl, $db, $is_logged, $member_id, $config, $_TIME, $user_group;
			
			if( !class_exists( "Board" ) ) require_once( ENGINE_DIR."/inc/board/board.class.php" );
			if( !is_array( $Board->DB['blocks'][ $id ] ) ) return false;
				
			$template = totranslit( $Board->DB['blocks'][ $id ]['template'], false, false );
			
			$sql = array();
			switch( $Board->DB['blocks'][ $id ]['post_type'] ){
				case "vip":
					$sql[] = "`vip_date`>'0'";
					break;
				
				case "super_vip":
					$sql[] = "`super_vip_date`>'0'";
					break;
					
				case "color":
					$sql[] = "`color_date`>'0'";
					break;
					
				default:break;
			}
			
			if( $Board->DB['blocks'][ $id ]['post_photo'] == "yes" ) $sql[] = "`photos`!=''";
			
			$limit = intval( $Board->DB['blocks'][ $id ]['max_post'] ) > 0 ? intval( $Board->DB['blocks'][ $id ]['max_post'] ) : 1;
			$sort = $Board->DB['blocks'][ $id ]['post_sort'] == "desc" ? "DESC" : "ASC";
			
			$allowCat = explode( ",", $Board->DB['blocks'][ $id ]['AllowCats'] );
			if( !in_array( "all", $allowCat ) )
				{
					foreach( $allowCat as $key => $cat )
						{
							$cat = intval( $cat );
							if( $cat ) 
								$allowCat[ $key ] = "'{$cat}'";
							else
								unset( $allowCat[ $key ] );
						}
					
					$allowCat = implode( ",", $allowCat );
					$sql[] = "`category` IN ({$allowCat})";
				}
				
			$sql = count( $sql ) > 0 ? "WHERE ".implode( " AND ", $sql ) : "";
			
			$NewsList = array(
						
				"template"		=> "board/blocks/{$template}.tpl",
				"template_nav"	=> "",
				"template_info"	=> "board/blocks/info.tpl",
				"tpl_compile"	=> "board_block_content",
				"cashe_folder"	=> "",
				"cashe_file"	=> "",
				"cache"			=> false,
				"sql_count"		=> "SELECT COUNT(*) as count FROM ".PREFIX."_board_post {$sql}",
				"sql_query"		=> "SELECT * FROM ".PREFIX."_board_post {$sql} ORDER BY date {$sort} {limit}",
				"num"			=> $limit,
				"nav"			=> false,
				"banners"		=> false,
				"search_info"	=> $SearchInfo,
				"search_text"	=> "Показано {posts} объявлений.",
				"no_news_error" => "Объявлений нет",
							
			);
			
			require( ENGINE_DIR."/modules/board/list.post.php" );	
			echo $tpl->result['board_block_content'];
			unset( $tpl->result['board_block_content'] );
		}
	}

echo echoBlock( $id );

?>