diff options
-rw-r--r-- | phpBB/includes/functions_posting.php | 2 | ||||
-rw-r--r-- | phpBB/includes/notifications/method/email.php | 14 | ||||
-rw-r--r-- | phpBB/includes/notifications/service.php | 2 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/base.php | 4 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/bookmark.php | 7 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/interface.php | 4 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/pm.php | 28 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/post.php | 30 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/quote.php | 23 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/topic.php | 27 | ||||
-rw-r--r-- | phpBB/language/en/email/notification.txt | 16 | ||||
-rw-r--r-- | phpBB/language/en/email/notifications/bookmark.txt | 20 | ||||
-rw-r--r-- | phpBB/language/en/email/notifications/quote.txt | 20 |
13 files changed, 147 insertions, 50 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e48a2b6bec..fc2c5a47b6 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2229,6 +2229,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'post' : $phpbb_notifications->add_notifications(array('topic', 'quote'), array_merge($data, array( 'post_username' => $username, + 'poster_id' => (int) $user->data['user_id'], ))); break; @@ -2236,6 +2237,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'quote' : $phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), array_merge($data, array( 'post_username' => $username, + 'poster_id' => (int) $user->data['user_id'], ))); break; diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 1bcea13d92..a1ca955ee1 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -82,19 +82,15 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base continue; } - $messenger->template('notification', $user['user_lang']); + $messenger->template($notification->email_template, $user['user_lang']); $messenger->to($user['user_email'], $user['username']); - $messenger->assign_vars(array( - 'USERNAME' => $user['username'], + $messenger->assign_vars(array_merge(array( + 'USERNAME' => $user['username'], - 'MESSAGE' => htmlspecialchars_decode($notification->get_title()), - - 'U_VIEW_MESSAGE' => $notification->get_full_url(), - - 'U_UNSUBSCRIBE' => $notification->get_unsubscribe_url(), - )); + 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=notifications', // todo Update URL + ), $notification->get_email_template_variables())); $messenger->send($this->notify_method); } diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 4933cf0f9a..d2ff20333e 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -153,7 +153,7 @@ class phpbb_notifications_service { foreach ($item_type as $type) { - $this->mark_notifications_read($type, $item_id, $user_id, $time); + $this->mark_notifications_read_by_parent($type, $item_parent_id, $user_id, $time); } return; diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index daca3b43cb..4958e27919 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -157,7 +157,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type public function create_insert_array($type_data) { // Defaults - $data = array_merge(array( + $this->data = array_merge(array( 'item_id' => static::get_item_id($type_data), 'item_type' => $this->get_item_type(), 'item_parent_id' => static::get_item_parent_id($type_data), @@ -168,6 +168,8 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type 'data' => array(), ), $this->data); + $data = $this->data; + $data['data'] = serialize($data['data']); return $data; diff --git a/phpBB/includes/notifications/type/bookmark.php b/phpBB/includes/notifications/type/bookmark.php index 7896703f00..86a99e4ff5 100644 --- a/phpBB/includes/notifications/type/bookmark.php +++ b/phpBB/includes/notifications/type/bookmark.php @@ -26,6 +26,13 @@ if (!defined('IN_PHPBB')) class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post { /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = 'notifications/bookmark'; + + /** * Language key used to output the text * * @var string diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index c1c0eb0b0c..a8c6e4869b 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -31,9 +31,9 @@ interface phpbb_notifications_type_interface public function get_formatted_title(); - public function get_url(); + public function get_email_template_variables(); - public function get_full_url(); + public function get_url(); public function get_unsubscribe_url($method); diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 89f338f3f9..816383949b 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -26,6 +26,13 @@ if (!defined('IN_PHPBB')) class phpbb_notifications_type_pm extends phpbb_notifications_type_base { /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = 'privmsg_notify'; + + /** * Get the type of notification this is * phpbb_notifications_type_ */ @@ -136,23 +143,30 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base } /** - * Get the url to this item + * Get email template variables * - * @return string URL + * @return array */ - public function get_url() + public function get_email_template_variables() { - return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}"); + $user_data = $this->service->get_user($this->get_data('from_user_id')); + + return array( + 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), + 'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))), + + 'U_VIEW_MESSAGE' => generate_board_url() . '/ucp.' . $this->php_ext . "?i=pm&mode=view&p={$this->item_id}", + ); } /** - * Get the full url to this item + * Get the url to this item * * @return string URL */ - public function get_full_url() + public function get_url() { - return generate_board_url() . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$this->item_id}"; + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}"); } /** diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index cc72ab8b1f..13742ee78b 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -26,6 +26,13 @@ if (!defined('IN_PHPBB')) class phpbb_notifications_type_post extends phpbb_notifications_type_base { /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = 'topic_notify'; + + /** * Language key used to output the text * * @var string @@ -175,23 +182,30 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base } /** - * Get the url to this item + * Get email template variables * - * @return string URL + * @return array */ - public function get_url() + public function get_email_template_variables() { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); + return array( + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), + + 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&view=unread#unread", + 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", + 'U_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}", + 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?uid={$this->user_id}&f={$this->get_data('forum_id')}&t={$this->item_parent_id}&unwatch=topic", + ); } /** - * Get the full url to this item + * Get the url to this item * * @return string URL */ - public function get_full_url() + public function get_url() { - return generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}"; + return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); } /** @@ -220,6 +234,8 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $this->set_data('post_username', (($post['post_username'] != $this->phpbb_container->get('user')->data['username']) ? $post['post_username'] : '')); + $this->set_data('forum_id', $post['forum_id']); + $this->set_data('forum_name', $post['forum_name']); return parent::create_insert_array($post); diff --git a/phpBB/includes/notifications/type/quote.php b/phpBB/includes/notifications/type/quote.php index 86d157631d..48d63003dd 100644 --- a/phpBB/includes/notifications/type/quote.php +++ b/phpBB/includes/notifications/type/quote.php @@ -26,6 +26,13 @@ if (!defined('IN_PHPBB')) class phpbb_notifications_type_quote extends phpbb_notifications_type_post { /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = 'notifications/quote'; + + /** * regular expression to match to find usernames * * @var string @@ -161,4 +168,20 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post // return true to continue with the update code in the notifications service (this will update the rest of the notifications) return true; } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + $user_data = $this->service->get_user($this->get_data('poster_id')); + + return array_merge(parent::get_email_template_variables(), array( + 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), + + 'U_QUOTED_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}", + )); + } } diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php index 0fce65a0cf..e31c8d792b 100644 --- a/phpBB/includes/notifications/type/topic.php +++ b/phpBB/includes/notifications/type/topic.php @@ -26,6 +26,13 @@ if (!defined('IN_PHPBB')) class phpbb_notifications_type_topic extends phpbb_notifications_type_base { /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = 'newtopic_notify'; + + /** * Get the type of notification this is * phpbb_notifications_type_ */ @@ -170,23 +177,29 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base } /** - * Get the url to this item + * Get email template variables * - * @return string URL + * @return array */ - public function get_url() + public function get_email_template_variables() { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "f={$this->item_parent_id}&t={$this->item_id}"); + return array( + 'FORUM_NAME' => htmlspecialchars_decode($this->get_data('forum_name')), + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), + + 'U_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->item_parent_id}", + 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?uid={$this->user_id}&f={$this->item_parent_id}&unwatch=forum", + ); } /** - * Get the full url to this item + * Get the url to this item * * @return string URL */ - public function get_full_url() + public function get_url() { - return generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}"; + return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "f={$this->item_parent_id}&t={$this->item_id}"); } /** diff --git a/phpBB/language/en/email/notification.txt b/phpBB/language/en/email/notification.txt deleted file mode 100644 index ed35e96c85..0000000000 --- a/phpBB/language/en/email/notification.txt +++ /dev/null @@ -1,16 +0,0 @@ -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}
\ No newline at end of file diff --git a/phpBB/language/en/email/notifications/bookmark.txt b/phpBB/language/en/email/notifications/bookmark.txt new file mode 100644 index 0000000000..9888008604 --- /dev/null +++ b/phpBB/language/en/email/notifications/bookmark.txt @@ -0,0 +1,20 @@ +Subject: Topic reply notification - "{TOPIC_TITLE}" + +Hello {USERNAME}, + +You are receiving this notification because the topic you bookmarked, "{TOPIC_TITLE}" at "{SITENAME}" has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. + +If you want to view the newest post made since your last visit, click the following link: +{U_NEWEST_POST} + +If you want to view the topic, click the following link: +{U_TOPIC} + +If you want to view the forum, click the following link: +{U_FORUM} + +If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here: + +{U_NOTIFICATION_SETTINGS} + +{EMAIL_SIG}
\ No newline at end of file diff --git a/phpBB/language/en/email/notifications/quote.txt b/phpBB/language/en/email/notifications/quote.txt new file mode 100644 index 0000000000..96fd527c8f --- /dev/null +++ b/phpBB/language/en/email/notifications/quote.txt @@ -0,0 +1,20 @@ +Subject: Topic reply notification - "{TOPIC_TITLE}" + +Hello {USERNAME}, + +You are receiving this notification because "{AUTHOR_NAME}" quoted you in the topic, "{TOPIC_TITLE}" at "{SITENAME}". You can use the following link to view the reply made. + +If you want to view the quoted post, click the following link: +{U_QUOTED_POST} + +If you want to view the topic, click the following link: +{U_TOPIC} + +If you want to view the forum, click the following link: +{U_FORUM} + +If you no longer wish to receive updates about replies quoting you, please update your notification settings here: + +{U_NOTIFICATION_SETTINGS} + +{EMAIL_SIG}
\ No newline at end of file |