diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 64840bfa51..ff0a59a4e3 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2230,6 +2230,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $notifications->add_notifications('topic', array_merge($data, array( 'post_username' => $username, ))); + $notifications->add_notifications('quote', array_merge($data, array( + 'post_username' => $username, + ))); break; case 'reply' : @@ -2237,6 +2240,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $notifications->add_notifications('post', array_merge($data, array( 'post_username' => $username, ))); + $notifications->add_notifications('quote', array_merge($data, array( + 'post_username' => $username, + ))); break; case 'edit_topic' : @@ -2250,6 +2256,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $notifications->update_notifications('post', array_merge($data, array( 'post_username' => $username, ))); + $notifications->add_notifications('quote', array_merge($data, array( + 'post_username' => $username, + ))); break; } } diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index b6255309c7..0f7752446a 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -130,7 +130,7 @@ class phpbb_notifications_service $notify_users = $item_type_class_name::find_users_for_notification($this->phpbb_container, $data); // Never send notifications to the anonymous user or the current user! - $notify_users = array_diff($notify_users, array(ANONYMOUS, $this->phpbb_container->get('user')->data['user_id'])); + unset($notify_users[ANONYMOUS], $notify_users[$this->phpbb_container->get('user')->data['user_id']]); // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item diff --git a/phpBB/includes/notifications/type/quote.php b/phpBB/includes/notifications/type/quote.php new file mode 100644 index 0000000000..8f93c67de1 --- /dev/null +++ b/phpBB/includes/notifications/type/quote.php @@ -0,0 +1,149 @@ +get('dbal.conn'); + + $usernames = false; + preg_match_all(self::$regular_expression_match, $post['message'], $usernames); + + if (empty($usernames[1])) + { + return array(); + } + + $usernames[1] = array_unique($usernames[1]); + + $usernames = array_map('utf8_clean_string', $usernames[1]); + + $users = array(); + + /* todo + * find what type of notification they'd like to receive + */ + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('username_clean', $usernames); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $users[$row['user_id']] = array(''); + } + $db->sql_freeresult($result); + + if (empty($users)) + { + return array(); + } + + $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); + + if (empty($auth_read)) + { + return array(); + } + + $notify_users = array(); + + foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id) + { + $notify_users[$user_id] = $users[$user_id]; + } + + return $notify_users; + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_formatted_title() + { + if ($this->get_data('post_username')) + { + $username = $this->get_data('post_username'); + } + else + { + $user_data = $this->service->get_user($this->get_data('poster_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + } + + return $this->phpbb_container->get('user')->lang( + 'NOTIFICATION_QUOTE', + $username, + censor_text($this->get_data('topic_title')) + ); + } + + /** + * Get the title of this notification + * + * @return string + */ + public function get_title() + { + if ($this->get_data('post_username')) + { + $username = $this->get_data('post_username'); + } + else + { + $user_data = $this->service->get_user($this->get_data('poster_id')); + + $username = $user_data['username']; + } + + return $this->phpbb_container->get('user')->lang( + 'NOTIFICATION_QUOTE', + $username, + censor_text($this->get_data('topic_title')) + ); + } +} diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index a437c924cf..75ca5c0000 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -388,6 +388,7 @@ $lang = array_merge($lang, array( 'NOTIFICATIONS' => '[ Notifications ]', 'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".', 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', + 'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".', 'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".', 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s',