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

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