[ticket/11103] Replace $email_template with get_email_template()

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-10-20 18:55:13 -05:00
parent a93067eb41
commit 0ac9079d1c
18 changed files with 163 additions and 99 deletions

View file

@ -78,6 +78,11 @@ class phpbb_notification_method_email extends phpbb_notification_method_base
// Time to go through the queue and send emails // Time to go through the queue and send emails
foreach ($this->queue as $notification) foreach ($this->queue as $notification)
{ {
if ($notification->get_email_template() === false)
{
continue;
}
$user = $this->notification_manager->get_user($notification->user_id); $user = $this->notification_manager->get_user($notification->user_id);
if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users))
@ -85,7 +90,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base
continue; continue;
} }
$messenger->template($notification->email_template, $user['user_lang']); $messenger->template($notification->get_email_template(), $user['user_lang']);
$messenger->to($user['user_email'], $user['username']); $messenger->to($user['user_email'], $user['username']);

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_approve_post extends phpbb_notification_type_post class phpbb_notification_type_approve_post extends phpbb_notification_type_post
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'post_approved';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -166,4 +159,14 @@ class phpbb_notification_type_approve_post extends phpbb_notification_type_post
return $data; return $data;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'post_approved';
}
} }

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_approve_topic extends phpbb_notification_type_topic class phpbb_notification_type_approve_topic extends phpbb_notification_type_topic
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'topic_approved';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -162,4 +155,14 @@ class phpbb_notification_type_approve_topic extends phpbb_notification_type_topi
return $data; return $data;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'topic_approved';
}
} }

View file

@ -51,13 +51,6 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
/** @var string */ /** @var string */
protected $php_ext = null; protected $php_ext = null;
/**
* Array of user data containing information needed to output the notifications to the template
*
* @var array
*/
protected $users = array();
/** /**
* Notification option data (for outputting to the user) * Notification option data (for outputting to the user)
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_bookmark extends phpbb_notification_type_post class phpbb_notification_type_bookmark extends phpbb_notification_type_post
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/bookmark';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -131,4 +124,14 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
return $notify_users; return $notify_users;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'notifications/bookmark';
}
} }

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_disapprove_post extends phpbb_notification_type_approve_post class phpbb_notification_type_disapprove_post extends phpbb_notification_type_approve_post
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'post_disapproved';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -113,4 +106,14 @@ class phpbb_notification_type_disapprove_post extends phpbb_notification_type_ap
return $data; return $data;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'post_disapproved';
}
} }

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_approve_topic class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_approve_topic
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'topic_disapproved';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -113,4 +106,14 @@ class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_a
return $data; return $data;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'topic_disapproved';
}
} }

View file

@ -122,6 +122,13 @@ interface phpbb_notification_type_interface
*/ */
public function prepare_for_display(); public function prepare_for_display();
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template();
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_pm extends phpbb_notification_type_base class phpbb_notification_type_pm extends phpbb_notification_type_base
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'privmsg_notify';
/** /**
* Get the type of notification this is * Get the type of notification this is
* phpbb_notification_type_ * phpbb_notification_type_
@ -129,6 +122,16 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base
return $this->user->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject')); return $this->user->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject'));
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'privmsg_notify';
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_post extends phpbb_notification_type_base class phpbb_notification_type_post extends phpbb_notification_type_base
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'topic_notify';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -212,6 +205,16 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
); );
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'topic_notify';
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/post_in_queue';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -151,4 +144,14 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
return $data; return $data;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'notifications/post_in_queue';
}
} }

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_quote extends phpbb_notification_type_post class phpbb_notification_type_quote extends phpbb_notification_type_post
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/quote';
/** /**
* regular expression to match to find usernames * regular expression to match to find usernames
* *
@ -201,6 +194,16 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
return true; return true;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'notifications/quote';
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_report_pm extends phpbb_notification_type_pm class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/report_pm';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -139,6 +132,16 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
return $notify_users; return $notify_users;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'notifications/report_pm';
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -68,6 +68,16 @@ class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_p
return array($pm['reporter'] => array('')); return array($pm['reporter'] => array(''));
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return false;
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_report_post extends phpbb_notification_type_post_in_queue class phpbb_notification_type_report_post extends phpbb_notification_type_post_in_queue
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/report_post';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -82,6 +75,16 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i
return $notify_users; return $notify_users;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'notifications/report_post';
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -68,6 +68,16 @@ class phpbb_notification_type_report_post_closed extends phpbb_notification_type
return array($post['reporter'] => array('')); return array($post['reporter'] => array(''));
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return false;
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_topic extends phpbb_notification_type_base class phpbb_notification_type_topic extends phpbb_notification_type_base
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'newtopic_notify';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -179,6 +172,16 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base
); );
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'newtopic_notify';
}
/** /**
* Get email template variables * Get email template variables
* *

View file

@ -23,13 +23,6 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_topic class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_topic
{ {
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/topic_in_queue';
/** /**
* Language key used to output the text * Language key used to output the text
* *
@ -144,4 +137,14 @@ class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_top
return $data; return $data;
} }
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return 'notifications/topic_in_queue';
}
} }