<?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
*/


if ($mode=='hide_post')
{
	User::checkToken();
	Db::i()->query("INSERT IGNORE INTO ?_forum_hposts SELECT * FROM ?_forum_posts WHERE post_id=?",$forum_info['post_id']);
	Db::i()->query("UPDATE ?_forum_hposts SET edited=? WHERE post_id=?", User::i()->login, $forum_info['post_id']);
	Db::i()->query("DELETE FROM ?_forum_posts WHERE post_id=?", $forum_info['post_id']);
	Db::i()->query("UPDATE ?_forum_themes SET total_posts=total_posts-1 WHERE theme_id=?", $forum_info['theme_id']);
	refresh('', LabCMS::i()->url(array($forum_info['theme_id'], 999), 'theme')."#last");
}
elseif ($mode=='unhide_post')
{
	User::checkToken();
	Db::i()->query("INSERT IGNORE INTO ?_forum_posts SELECT * FROM ?_forum_hposts WHERE post_id=?", $forum_info['post_id']);
	Db::i()->query("UPDATE ?_forum_posts SET edited=NULL WHERE post_id=?", $forum_info['post_id']);
	Db::i()->query("DELETE FROM ?_forum_hposts WHERE post_id=?", $forum_info['post_id']);
	Db::i()->query("UPDATE ?_forum_themes SET total_posts=total_posts+1 WHERE theme_id=?", $forum_info['theme_id']);
	refresh('', LabCMS::i()->url(array($forum_info['theme_id'], 999), 'theme')."#last");
}
elseif ($mode=='hide_theme')
{
	User::checkToken();
	Db::i()->query("INSERT IGNORE INTO ?_forum_hthemes SELECT * FROM ?_forum_themes WHERE theme_id=?",$forum_info['theme_id']);
	Db::i()->query("UPDATE ?_forum_hthemes SET hidden=? WHERE theme_id=?", User::i()->id, $forum_info['theme_id']);
	Db::i()->query("DELETE FROM ?_forum_themes WHERE theme_id=?", $forum_info['theme_id']);
	Db::i()->query("UPDATE ?_forum_forums SET total_themes=total_themes-1 WHERE forum_id=?", $forum_info['forum_id']);
	refresh('', LabCMS::i()->url($forum_info['forum_id']));
}
elseif ($mode=='unhide_theme')
{
	User::checkToken();
	Db::i()->query("INSERT IGNORE INTO ?_forum_themes SELECT * FROM ?_forum_hthemes WHERE theme_id=?",$forum_info['theme_id']);
	Db::i()->query("UPDATE ?_forum_themes SET hidden=NULL WHERE theme_id=?", $forum_info['theme_id']);
	Db::i()->query("DELETE FROM ?_forum_hthemes WHERE theme_id=?", $forum_info['theme_id']);
	Db::i()->query("UPDATE ?_forum_forums SET total_themes=total_themes+1 WHERE forum_id=?", $forum_info['forum_id']);
	refresh('', LabCMS::i()->url($forum_info['forum_id']));
}