From e14595621259edb093a8bb984a95747ede2041ff Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 12 Sep 2012 21:23:24 -0500 Subject: [PATCH] [ticket/11103] Use the Topic/Forum Subscriptions system Using the Topic/Forum Subscription system that already exists is going to save many hours of work. If it is desired, it can always be easily converted over to the new USER_NOTIFICATIONS_TABLE later (for the same amount of work). PHPBB3-11103 --- phpBB/includes/notifications/type/post.php | 16 ++++++++++++++-- phpBB/includes/notifications/type/topic.php | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 3568b9d478..b951b79fa6 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -54,9 +54,21 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base */ public static function find_users_for_notification(ContainerBuilder $phpbb_container, $post) { - $users = parent::_find_users_for_notification($phpbb_container, $post['topic_id']); + // Let's continue to use the phpBB subscriptions system, at least for now. + // It may not be the nicest thing, but it is already working and it would be significant work to replace it + //$users = parent::_find_users_for_notification($phpbb_container, $post['topic_id']); - if (!sizeof($users)) + $db = $phpbb_container->get('dbal.conn'); + + $sql = 'SELECT user_id + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . (int) $post['topic_id'] . ' + AND notify_status = ' . NOTIFY_YES; + $result = $db->sql_query($sql); + $users = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + if (empty($users)) { return array(); } diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php index 51a95d5e19..58a3740e3a 100644 --- a/phpBB/includes/notifications/type/topic.php +++ b/phpBB/includes/notifications/type/topic.php @@ -54,9 +54,21 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base */ public static function find_users_for_notification(ContainerBuilder $phpbb_container, $topic) { - $users = parent::_find_users_for_notification($phpbb_container, $topic['forum_id']); + // Let's continue to use the phpBB subscriptions system, at least for now. + // It may not be the nicest thing, but it is already working and it would be significant work to replace it + //$users = parent::_find_users_for_notification($phpbb_container, $topic['forum_id']); - if (!sizeof($users)) + $db = $phpbb_container->get('dbal.conn'); + + $sql = 'SELECT user_id + FROM ' . FORUMS_WATCH_TABLE . ' + WHERE forum_id = ' . (int) $topic['forum_id'] . ' + AND notify_status = ' . NOTIFY_YES; + $result = $db->sql_query($sql); + $users = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + if (empty($users)) { return array(); }