diff --git a/phpBB/includes/notifications/type/approve_post.php b/phpBB/includes/notifications/type/approve_post.php index 91fb4106b1..faa88e862c 100644 --- a/phpBB/includes/notifications/type/approve_post.php +++ b/phpBB/includes/notifications/type/approve_post.php @@ -85,7 +85,7 @@ class phpbb_notifications_type_approve_post extends phpbb_notifications_type_pos $sql = 'SELECT * FROM ' . USER_NOTIFICATIONS_TABLE . " - WHERE item_type = 'moderation_queue' + WHERE item_type = '" . self::$notification_option['id'] . "' AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/includes/notifications/type/approve_topic.php b/phpBB/includes/notifications/type/approve_topic.php index 7da6fde747..fbe44c8a2c 100644 --- a/phpBB/includes/notifications/type/approve_topic.php +++ b/phpBB/includes/notifications/type/approve_topic.php @@ -85,7 +85,7 @@ class phpbb_notifications_type_approve_topic extends phpbb_notifications_type_to $sql = 'SELECT * FROM ' . USER_NOTIFICATIONS_TABLE . " - WHERE item_type = 'moderation_queue' + WHERE item_type = '" . self::$notification_option['id'] . "' AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/includes/notifications/type/bookmark.php b/phpBB/includes/notifications/type/bookmark.php index 9f2c2e26dc..0e5358b105 100644 --- a/phpBB/includes/notifications/type/bookmark.php +++ b/phpBB/includes/notifications/type/bookmark.php @@ -62,28 +62,23 @@ class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post $users = array(); - /* todo - * find what type of notification they'd like to receive - */ $sql = 'SELECT user_id FROM ' . BOOKMARKS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $post['topic_id']); + WHERE ' . $db->sql_in_set('topic_id', $post['topic_id']) . ' + AND user_id <> ' . (int) $post['poster_id']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - $users[$row['user_id']] = array(''); + $users[] = $row['user_id']; } $db->sql_freeresult($result); - // Never notify the poster - unset($users[$post['poster_id']]); - if (empty($users)) { return array(); } - $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); + $auth_read = $phpbb_container->get('auth')->acl_get_list($users, 'f_read', $post['forum_id']); if (empty($auth_read)) { @@ -92,10 +87,21 @@ class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post $notify_users = array(); - foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id) + $sql = 'SELECT * + FROM ' . USER_NOTIFICATIONS_TABLE . " + WHERE item_type = '" . self::get_item_type() . "' + AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $notify_users[$user_id] = $users[$user_id]; + if (!isset($rowset[$row['user_id']])) + { + $notify_users[$row['user_id']] = array(); + } + + $notify_users[$row['user_id']][] = $row['method']; } + $db->sql_freeresult($result); return $notify_users; } diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 17a7a6863a..bf41d2b05e 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -93,23 +93,21 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $sql = 'SELECT user_id FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND notify_status = ' . NOTIFY_YES; + AND notify_status = ' . NOTIFY_YES . ' + AND user_id <> ' . (int) $post['poster_id']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - $users[$row['user_id']] = array(''); + $users[] = $row['user_id']; } $db->sql_freeresult($result); - // Never notify the poster - unset($users[$post['poster_id']]); - if (empty($users)) { return array(); } - $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); + $auth_read = $phpbb_container->get('auth')->acl_get_list($users, 'f_read', $post['forum_id']); if (empty($auth_read)) { @@ -118,10 +116,21 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $notify_users = array(); - foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id) + $sql = 'SELECT * + FROM ' . USER_NOTIFICATIONS_TABLE . " + WHERE item_type = '" . self::get_item_type() . "' + AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $notify_users[$user_id] = $users[$user_id]; + if (!isset($rowset[$row['user_id']])) + { + $notify_users[$row['user_id']] = array(); + } + + $notify_users[$row['user_id']][] = $row['method']; } + $db->sql_freeresult($result); return $notify_users; } diff --git a/phpBB/includes/notifications/type/post_in_queue.php b/phpBB/includes/notifications/type/post_in_queue.php index 0043a38944..ca02b8d85a 100644 --- a/phpBB/includes/notifications/type/post_in_queue.php +++ b/phpBB/includes/notifications/type/post_in_queue.php @@ -92,7 +92,7 @@ class phpbb_notifications_type_post_in_queue extends phpbb_notifications_type_po $sql = 'SELECT * FROM ' . USER_NOTIFICATIONS_TABLE . " - WHERE item_type = 'needs_approval' + WHERE item_type = '" . self::$notification_option['id'] . "' AND " . $db->sql_in_set('user_id', $auth_approve[$topic['forum_id']]['m_approve']); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/includes/notifications/type/quote.php b/phpBB/includes/notifications/type/quote.php index 2079617510..be149673c2 100644 --- a/phpBB/includes/notifications/type/quote.php +++ b/phpBB/includes/notifications/type/quote.php @@ -81,28 +81,23 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post $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); + WHERE ' . $db->sql_in_set('username_clean', $usernames) . ' + AND user_id <> ' . (int) $post['poster_id']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - $users[$row['user_id']] = array(''); + $users[] = $row['user_id']; } $db->sql_freeresult($result); - // Never notify the poster - unset($users[$post['poster_id']]); - if (empty($users)) { return array(); } - $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); + $auth_read = $phpbb_container->get('auth')->acl_get_list($users, 'f_read', $post['forum_id']); if (empty($auth_read)) { @@ -111,10 +106,21 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post $notify_users = array(); - foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id) + $sql = 'SELECT * + FROM ' . USER_NOTIFICATIONS_TABLE . " + WHERE item_type = '" . self::get_item_type() . "' + AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $notify_users[$user_id] = $users[$user_id]; + if (!isset($rowset[$row['user_id']])) + { + $notify_users[$row['user_id']] = array(); + } + + $notify_users[$row['user_id']][] = $row['method']; } + $db->sql_freeresult($result); return $notify_users; } diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php index 733b2108cc..32d30bc142 100644 --- a/phpBB/includes/notifications/type/topic.php +++ b/phpBB/includes/notifications/type/topic.php @@ -86,30 +86,24 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base $users = array(); - /* todo - * find what type of notification they'd like to receive - * make sure not to send duplicate notifications - */ $sql = 'SELECT user_id FROM ' . FORUMS_WATCH_TABLE . ' WHERE forum_id = ' . (int) $topic['forum_id'] . ' - AND notify_status = ' . NOTIFY_YES; + AND notify_status = ' . NOTIFY_YES . ' + AND user_id <> ' . (int) $topic['poster_id']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - $users[$row['user_id']] = array(''); + $users[] = $row['user_id']; } $db->sql_freeresult($result); - // Never notify the poster - unset($users[$topic['poster_id']]); - if (empty($users)) { return array(); } - $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $topic['forum_id']); + $auth_read = $phpbb_container->get('auth')->acl_get_list($users, 'f_read', $topic['forum_id']); if (empty($auth_read)) { @@ -118,10 +112,21 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base $notify_users = array(); - foreach ($auth_read[$topic['forum_id']]['f_read'] as $user_id) + $sql = 'SELECT * + FROM ' . USER_NOTIFICATIONS_TABLE . " + WHERE item_type = '" . self::get_item_type() . "' + AND " . $db->sql_in_set('user_id', $auth_read[$topic['forum_id']]['f_read']); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $notify_users[$user_id] = $users[$user_id]; + if (!isset($rowset[$row['user_id']])) + { + $notify_users[$row['user_id']] = array(); + } + + $notify_users[$row['user_id']][] = $row['method']; } + $db->sql_freeresult($result); return $notify_users; } diff --git a/phpBB/includes/notifications/type/topic_in_queue.php b/phpBB/includes/notifications/type/topic_in_queue.php index dda647d18e..559af3e505 100644 --- a/phpBB/includes/notifications/type/topic_in_queue.php +++ b/phpBB/includes/notifications/type/topic_in_queue.php @@ -92,7 +92,7 @@ class phpbb_notifications_type_topic_in_queue extends phpbb_notifications_type_t $sql = 'SELECT * FROM ' . USER_NOTIFICATIONS_TABLE . " - WHERE item_type = 'needs_approval' + WHERE item_type = '" . self::$notification_option['id'] . "' AND " . $db->sql_in_set('user_id', $auth_approve[$topic['forum_id']]['m_approve']); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result))