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

$trackObj = new TrackObj();

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

	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		$trackObj->ProfileId = $_POST['ProfileId'];
		$trackObj->AlbumId = $_POST['AlbumId'];
		$trackObj->TrackId = $_POST['TrackId'];
		$trackObj->TrackName = $_POST['TrackName'];
		$trackObj->TrackLength = $_POST['TrackLength'];
		$trackObj->ReleaseDate = $_POST['ReleaseDate'];
		$trackObj->Producer = $_POST['Producer'];
		$trackObj->IsFeatured = $_POST['IsFeatured'];
		$trackObj->IsSingle = $_POST['IsSingle'];
		
		$trackMsg = $trackObj->UpdateTrack();
		if(strpos($trackMsg, 'error'))
		{
			$template -> assign_block_vars('page_error', array());
			$template -> assign_block_vars('page_error.error_msg', array(
				'ERROR_MSG' => $trackMsg
			));
		} else {
			$template -> assign_block_vars('page_msg', array());
			$template -> assign_block_vars('page_msg.msg', array(
				'MSG' => $trackMsg
			));
		}
		
		foreach ($trackObj as $key => $value)
		{
			$trackObj->$key = stripslashes($value);
		}
	}
	else
	{
		if (isset($_GET['TrackId']))
		{
			$trackObj->TrackId = $_GET['TrackId'];
			$trackObj->GetTrack();
		}
		else
		{
			$trackObj->ProfileId = $_SESSION['UserProfileId'];
		}
	}
	
	$template -> assign_vars(array(
		'PROFILE_ID' => $trackObj->ProfileId,
		'ALBUM_ID' => $trackObj->AlbumId,
		'TRACK_ID' => $trackObj->TrackId,
		'TRACK_NAME' => $trackObj->TrackName,
		'TRACK_LENGTH' => $trackObj->TrackLength,
		'RELEASE_DATE' => $trackObj->ReleaseDate,
		'PRODUCER' => $trackObj->Producer,
		'IS_FEATURED' => $trackObj->IsFeatured,
		'IS_SINGLE' => $trackObj->IsSingle,
		));
?>