<?php
require_once(LIB.'Post.class.php');

$user = @$_SESSION['user'];
if (empty($user))
	redirect();

$id = @$params[0];
if (empty($id))
	redirect();

$post = new Post();
$favorite = $post->readFavoriteCache($id);
if ($user['id'] != $favorite['user_id'])
	redirect(); 

//TODO: 初回のみ
$update_ret = $post->updateFavoritePost($id);
//$contents = $post->favorite($id);
$contents = $post->get(array('favorite' => $id));
$title = 'お気に入り: '.$favorite['name'];
$box = get_show_boxes(__FILE__);

$script = <<<EOD
	$(function() {
		$("#post-btn").val("このテーマに投稿");
		T.readOpt.favorite = {$id};
		T.initRead();
	});
EOD;

include LAYOUTS.'header.inc.php';
include LAYOUTS.'control.inc.php';
include LAYOUTS.'content.inc.php';
include LAYOUTS.'footer.inc.php';
?>