Created
February 5, 2014 20:00
-
-
Save PabloVallejo/8831825 to your computer and use it in GitHub Desktop.
Email_Model::get_notification_body
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment