PabloVallejo
2/5/2014 - 8:00 PM

Email_Model::get_notification_body

Email_Model::get_notification_body

<?php 

/**
* Return the body of a notification
*
* @param { str } notification slug
* @param { arr } arguments to pass to the notification
* @return { str || bool } email body, or false on error
*/
function get_notification_body( $slug = null, $args = array() ) {

	if ( $slug == null )
		return false;

	// Take args out of the arr
	if ( is_array( $args ) )
		extract( $args );

	// Does notification exist?
	if ( ! $this->notification_exists( $slug ) )
		return false;


	// Signup confirmation
	if ( $slug == 'signup_confirmation' )
		return ( object ) array(

				'body' => Mustache::make()->render( 'signup_confirmation', $args )
			,	'subject' => 'Signup confirmation'
			,	'receiver' => _either( $receiver, $this->receiver )

		);

	// Flag request
	else if ( $slug == 'flag' )
		return ( object ) array(
				'body' => Mustache::make()->render( 'flag', $args )
			,	'subject' => 'Flag Request'
			,	'receiver' => _either( $receiver, $this->receiver )
		);

	// Email Download
	else if ( $slug == 'email_download' )
		return ( object ) array(
				'body' => Mustache::make()->render( 'email_download', $args )
			,	'subject' => 'Your File Is Ready To Download'
			,	'receiver' => _either( $receiver, $this->receiver )
		);

	// Post submission
	else if ( $slug == 'post_submission' )
		return ( object ) array(
				'body' => Mustache::make()->render( 'post_submission', $args )
			,	'subject' => 'New post suggestion'
			,	'receiver' => _either( $receiver, $this->receiver )
		);

	// List suggestion
	else if ( $slug == 'list_suggestion' )
		return ( object ) array(
				'body' => Mustache::make()->render( 'list_suggestion', $args )
			,	'subject' => 'New list suggestion'
			,	'receiver' => _either( $receiver, $this->receiver )
		);

}

?>