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

$memberObj = new MemberObj();

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

	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		$memberObj->MainProfileId = $_POST['MainProfileId'];
		$memberObj->MemberProfileId = $_POST['MemberProfileId'];
		$memberObj->MemberId = $_POST['MemberId'];
		$memberObj->MemberName = $_POST['MemberName'];
		$memberObj->Role = $_POST['Role'];
		$memberObj->IsCurrentMember = $_POST['IsCurrentMember'];
		
		$memberMsg = $memberObj->UpdateMember();
		if(strpos($memberMsg, 'error'))
		{
			$template -> assign_block_vars('page_error', array());
			$template -> assign_block_vars('page_error.error_msg', array(
				'ERROR_MSG' => $memberMsg
			));
		} else {
			$template -> assign_block_vars('page_msg', array());
			$template -> assign_block_vars('page_msg.msg', array(
				'MSG' => $memberMsg
			));
		}
		
		foreach ($memberObj as $key => $value)
		{
			$memberObj->$key = stripslashes($value);
		}
	}
	else
	{
		if (isset($_GET['MemberId']))
		{
			$memberObj->MemberId = $_GET['MemberId'];
			$memberObj->GetMember();
		}
		else
		{
			$memberObj->MainProfileId = $_SESSION['UserProfileId'];
		}
	}
	
	$template -> assign_vars(array(
		'MAIN_PROFILE_ID' => $memberObj->MainProfileId,
		'MEMBER_PROFILE_ID' => $memberObj->MemberProfileId,
		'MEMBER_ID' => $memberObj->MemberId,
		'MEMBER_NAME' => $memberObj->MemberName,
		'ROLE' => $memberObj->Role,
		'IS_CURRENT_MEMBER' => $memberObj->IsCurrentMember
		));
	
?>