<?php

class Inbox_EnvelopeController extends Inbox_Controller_Base
{
	public function init()
	{
		parent::init();
		$this->_columns = array(
			"Account" => null,
         "isNew" => null,
			"attachments" => null,
			"emailBcc" => null,
			"emailBodyHtml" => null,
			"emailCc" => null,
			"emailSubject" => null,
			"emailTo" => null,
         "emailFrom" => null,
			"isDraft" => null,
			"relatedDraftUID" => null
		);
	}

	public function indexAction(){
		$this->methodNotAllowed();
	}

	public function getAction(){
		$this->methodNotAllowed();
	}

	public function putAction(){
		$this->methodNotAllowed();
	}

	public function deleteAction(){
		$this->methodNotAllowed();
	}

	public function postAction(){
		$this->populateParameters();
		$arr = array();

		try
		{
			$compose = new compose( array('Account' => $this->_Account, 'helper' => $this->_helper, 'view' => $this->view) );
		
			if( $this->_restParameters['isDraft'] ){
				
				$arr = $compose->saveDraft( $this->_restParameters );
				$arr = array_merge((array)$this->_restParameters, (array)$arr);
			} else {
				$arr = $compose->sendMessage( $this->_restParameters );
			}

			return $this->renderJson( $arr );

		} catch (Exception $e) {
			$this->renderJsonError( $e->getMessage() );
		}
	}
}
?>
