mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11103] General notification email template.
PHPBB3-11103
This commit is contained in:
parent
4b4ea7c5cd
commit
ff45c9aa7c
8 changed files with 67 additions and 27 deletions
|
@ -83,19 +83,8 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic run queue function.
|
* Empty the queue
|
||||||
* Child methods should override this function if there are more efficient methods to mass-notification
|
|
||||||
*/
|
*/
|
||||||
public function run_queue()
|
|
||||||
{
|
|
||||||
foreach ($this->queue as $notification)
|
|
||||||
{
|
|
||||||
$this->notify($notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->empty_queue();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function empty_queue()
|
protected function empty_queue()
|
||||||
{
|
{
|
||||||
$this->queue = array();
|
$this->queue = array();
|
||||||
|
|
|
@ -33,12 +33,7 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notify($notification)
|
public function notify()
|
||||||
{
|
|
||||||
// email the user
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run_queue()
|
|
||||||
{
|
{
|
||||||
if (!sizeof($this->queue))
|
if (!sizeof($this->queue))
|
||||||
{
|
{
|
||||||
|
@ -80,14 +75,18 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
|
||||||
|
|
||||||
$user = $this->service->get_user($notification->user_id);
|
$user = $this->service->get_user($notification->user_id);
|
||||||
|
|
||||||
$messenger->template('privmsg_notify', $user['user_lang']);
|
$messenger->template('notification', $user['user_lang']);
|
||||||
|
|
||||||
$messenger->to($user['user_email'], $user['username']);
|
$messenger->to($user['user_email'], $user['username']);
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
$messenger->assign_vars(array(
|
||||||
'SUBJECT' => htmlspecialchars_decode($notification->get_title()),
|
'USERNAME' => $user['username'],
|
||||||
|
|
||||||
|
'MESSAGE' => htmlspecialchars_decode($notification->get_title()),
|
||||||
|
|
||||||
'U_VIEW_MESSAGE' => $notification->get_full_url(),
|
'U_VIEW_MESSAGE' => $notification->get_full_url(),
|
||||||
|
|
||||||
|
'U_UNSUBSCRIBE' => $notification->get_unsubscribe_url(),
|
||||||
));
|
));
|
||||||
|
|
||||||
$messenger->send('email');
|
$messenger->send('email');
|
||||||
|
|
|
@ -21,5 +21,5 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
interface phpbb_notifications_method_interface
|
interface phpbb_notifications_method_interface
|
||||||
{
|
{
|
||||||
public function notify($notification);
|
public function notify();
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ class phpbb_notifications_service
|
||||||
// run the queue for each method to send notifications
|
// run the queue for each method to send notifications
|
||||||
foreach ($notification_methods as $method)
|
foreach ($notification_methods as $method)
|
||||||
{
|
{
|
||||||
$method->run_queue();
|
$method->notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
|
||||||
), $options);
|
), $options);
|
||||||
|
|
||||||
$template->assign_block_vars($options['template_block'], array(
|
$template->assign_block_vars($options['template_block'], array(
|
||||||
'TITLE' => $this->get_title(),
|
'TITLE' => $this->get_formatted_title(),
|
||||||
'URL' => $this->get_url(),
|
'URL' => $this->get_url(),
|
||||||
'TIME' => $user->format_date($this->time),
|
'TIME' => $user->format_date($this->time),
|
||||||
|
|
||||||
|
@ -173,4 +173,24 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the formatted title of this notification (fall-back)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_formatted_title()
|
||||||
|
{
|
||||||
|
return $this->get_title();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL to unsubscribe to this notification
|
||||||
|
*
|
||||||
|
* @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item
|
||||||
|
*/
|
||||||
|
public function get_unsubscribe_url($method = false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,13 @@ interface phpbb_notifications_type_interface
|
||||||
|
|
||||||
public function get_title();
|
public function get_title();
|
||||||
|
|
||||||
|
public function get_formatted_title();
|
||||||
|
|
||||||
public function get_url();
|
public function get_url();
|
||||||
|
|
||||||
public function get_full_url();
|
public function get_full_url();
|
||||||
|
|
||||||
|
public function get_unsubscribe_url($method);
|
||||||
|
|
||||||
public function create_insert_array($type_data);
|
public function create_insert_array($type_data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,21 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the title of this notification
|
* Get the HTML formatted title of this notification
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_formatted_title()
|
||||||
|
{
|
||||||
|
$user_data = $this->service->get_user($this->get_data('from_user_id'));
|
||||||
|
|
||||||
|
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
|
||||||
|
|
||||||
|
return $username . ' sent you a private message titled: ' . $this->get_data('message_subject');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plain text title of this notification
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -97,9 +111,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
|
||||||
{
|
{
|
||||||
$user_data = $this->service->get_user($this->get_data('from_user_id'));
|
$user_data = $this->service->get_user($this->get_data('from_user_id'));
|
||||||
|
|
||||||
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
|
return $user_data['username'] . ' sent you a private message titled: ' . $this->get_data('message_subject');
|
||||||
|
|
||||||
return $username . ' sent you a private message titled: ' . $this->get_data('message_subject');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
16
phpBB/language/en/email/notification.txt
Normal file
16
phpBB/language/en/email/notification.txt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Subject: Notification from {SITENAME}
|
||||||
|
|
||||||
|
Hello {USERNAME},
|
||||||
|
|
||||||
|
{MESSAGE}
|
||||||
|
|
||||||
|
You can view this by clicking on the following link:
|
||||||
|
|
||||||
|
{U_VIEW_MESSAGE}
|
||||||
|
|
||||||
|
<!-- IF U_UNSUBSCRIBE -->
|
||||||
|
You may unsubscribe by clicking on the following link:
|
||||||
|
{U_UNSUBSCRIBE}
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
|
{EMAIL_SIG}
|
Loading…
Add table
Reference in a new issue