<?
if (!defined('IN_BANDTOPIA'))
{
	exit;
}

$commentObj = new CommentsObj();

$template -> set_filenames(array(
		'page' => MODULE_PATH.'profiles/template/commentAdmin.htm'));

	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		$commentObj->ProfileId = $_POST['ProfileId'];
		$commentObj->CommentId = $_POST['CommentId'];
		$commentObj->PostedDate = $_POST['PostedDate'];
		$commentObj->PostedUserId = $_POST['PostedUserId'];
		$commentObj->Comment = $_POST['Comment'];
		$commentObj->Likes = $_POST['Likes'];
		$commentObj->DisLikes = $_POST['DisLikes'];
		$commentObj->IsHidden = $_POST['IsHidden'];
		$commentObj->IsApproved = $_POST['IsApproved'];
		
		$commentMsg = $commentObj->UpdateComment();
		if(strpos($commentMsg, 'error'))
		{
			$template -> assign_block_vars('page_error', array());
			$template -> assign_block_vars('page_error.error_msg', array(
				'ERROR_MSG' => $commentMsg
			));
		} else {
			$template -> assign_block_vars('page_msg', array());
			$template -> assign_block_vars('page_msg.msg', array(
				'MSG' => $commentMsg
			));
		}
		
		foreach ($commentObj as $key => $value)
		{
			$commentObj->$key = stripslashes($value);
		}
	}
	else
	{
		if (isset($_GET['CommentId']))
		{
			$commentObj->CommentId = $_GET['CommentId'];
			$commentObj->GetComment();
		}
		else
		{
			$commentObj->ProfileId = $_SESSION['UserProfileId'];
		}
	}
	
		
	$template -> assign_vars(array(
		'PROFILE_ID' => $commentObj->ProfileId,
		'COMMENT_ID' => $commentObj->CommentId,
		'POSTED_DATE' => $commentObj->PostedDate,
		'POSTED_USER_ID' => $commentObj->PostedUserId,
		'COMMENT' => $commentObj->Comment,
		'LIKES' => $commentObj->Likes,
		'DISLIKES' => $commentObj->DisLikes,
		'IS_HIDDEN' => $commentObj->IsHidden,
		'IS_APPROVED' => $commentObj->IsApproved
		));


?>