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

/**
 * Saves a new member alias.
 * 
 *
 * @author Matthew Lindberg
 */
class InsertNewAlias extends Action
{
	
	/**
	 * 
	 *
	 * @access public
	 * @return boolean
	 */
	function execute(& $context)
	{
		global $__CS;
		$__CS->EnterMethod("execute:InsertNewAlias");
		
		$session 	=& $context->getEntry(__SESSION);
		$request	=& $context->getEntry(__REQUEST);
		$timer		=& $context->getEntry(__TIMER);
		$control	=& $context->getEntry(__CONTROLLER);
		
		$member_id = $request->get("memberid");
		
		include_once('core/members/forms/AliasEditForm.php');
		$alias_form 	=& new AliasEditForm(& $session, & $request);
		$alias_form->loadFromRequest();
		
		$model 		=& $context->getEntry(__MODEL);
		
		if( !$model->saveNewAliasFromForm(& $alias_form, $member_id)) {
			die("Error saving new member in InsertNewAlias");
		}
		
		$request->set( "section", "aliassection" );
		$request->set( "id",	$member_id );
		$request->set( __ACTION, __MEMBER_EDIT );
		$request->addFeedback("new alias has been successfully created");
		
		$control->processRequest(& $request);
		$__CS->ExitMethod("execute:EditMember");
		return false;
	}
}
?>