<?php
// SetAliasAsMain.php
include_once('core/base/Action.php');

/**
 *
 * @author Matthew Lindberg
 * @todo Make execute functon set ErrorView in controller on error instead of triggering error.
 */
class SetAliasAsMain extends Action
{
	/**
	 * 
	 *
	 * @access public
	 * @return boolean
	 */
	function execute(& $context)
	{
		global $__CS;
		$__CS->EnterMethod("execute");
		
		$request	=& $context->getEntry(__REQUEST);
		$model 		=& $context->getEntry(__MODEL);
		$controller =& $context->getEntry(__CONTROLLER);
		
		$member_id = $request->get("memberid");
		$alias_id = $request->get("aliasid");
		
		if( !$model->setAsMainCharacter($member_id,$alias_id)) {
			trigger_error(__ERROR."Could not update alias in UpdateAlias.php");
		}
		
		$request->addFeedback("new main character has been set");
		$request->set(__ACTION,__MEMBER_EDIT);
		$request->set("id",$member_id);
		$request->set("section","aliassection");
		
		$controller->processRequest(& $request);
		$__CS->ExitMethod("execute");
		return false;
	}
}
?>