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

$mediaObj = new MediaObj();

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

	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		$mediaObj->ProfileId = $_POST['ProfileId'];
		$mediaObj->MediaGroupId = $_POST['MediaGroupId'];
		$mediaObj->MediaId = $_POST['MediaId'];
		$mediaObj->MediaName = $_POST['MediaName'];
		$mediaObj->MediaLocation = $_POST['MediaLocation'];
		
		$mediaMsg = $mediaObj->UpdateMedia();
		if(strpos($mediaMsg, 'error'))
		{
			$template -> assign_block_vars('page_error', array());
			$template -> assign_block_vars('page_error.error_msg', array(
				'ERROR_MSG' => $mediaMsg
			));
		} else {
			$template -> assign_block_vars('page_msg', array());
			$template -> assign_block_vars('page_msg.msg', array(
				'MSG' => $mediaMsg
			));
		}
		
		foreach ($mediaObj as $key => $value)
		{
			$mediaObj->$key = stripslashes($value);
		}
	}
	else
	{
		if (isset($_GET['MediaId']))
		{
			$mediaObj->MediaId = $_GET['MediaId'];
			$mediaObj->GetMedia();
		}
		else
		{
			$mediaObj->ProfileId = $_SESSION['UserProfileId'];
		}
	}
	
		
	$template -> assign_vars(array(
		'PROFILE_ID' => $mediaObj->ProfileId,
		'MEDIA_GROUP_ID' => $mediaObj->MediaGroupId,
		'MEDIA_ID' => $mediaObj->MediaId,
		'MEDIA_NAME' => $mediaObj->MediaName,
		'MEDIA_LOCATION' => $mediaObj->MediaLocation
		));


?>