[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
This commit is contained in:
Nathan Guse 2012-09-12 21:23:24 -05:00
parent 9b1de1e487
commit e145956212
2 changed files with 28 additions and 4 deletions

View file

@ -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) 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(); return array();
} }

View file

@ -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) 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(); return array();
} }