<?php
// UpdateAlias.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 UpdateAlias 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");
		
		include_once('core/members/forms/AliasEditForm.php');
		$alias_form =& new AliasEditForm(& $session, & $request);
		$alias_form->loadFromRequest();
		
		if( !$model->updateAlias(& $alias_form, $member_id, $alias_id) ) {
			trigger_error(__ERROR."Could not update alias in UpdateAlias.php");
		}
		
		$request->addFeedback("alias has been updated successfully");
		//$request->set(__ACTION,__MEMBER_ALIAS_EDIT);
		//$request->set("memberid",$member_id);
		//$request->set("section","aliassection");
		$request->set(__ACTION,__MEMBER_SEARCH);
		
		$controller->processRequest(& $request);
		$__CS->ExitMethod("execute");
		return false;
	}
}
?>