[ticket/11103] Types now all send notifications as per user setting

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-09-27 18:41:07 -05:00
parent 48ccc9eb93
commit 858201cc1f
8 changed files with 72 additions and 46 deletions

View file

@ -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))

View file

@ -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))

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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))

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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))