mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 22:38:52 +00:00
[ticket/11103] Types now all send notifications as per user setting
PHPBB3-11103
This commit is contained in:
parent
48ccc9eb93
commit
858201cc1f
8 changed files with 72 additions and 46 deletions
|
@ -85,7 +85,7 @@ class phpbb_notifications_type_approve_post extends phpbb_notifications_type_pos
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . USER_NOTIFICATIONS_TABLE . "
|
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']);
|
AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
|
@ -85,7 +85,7 @@ class phpbb_notifications_type_approve_topic extends phpbb_notifications_type_to
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . USER_NOTIFICATIONS_TABLE . "
|
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']);
|
AND " . $db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
|
@ -62,28 +62,23 @@ class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post
|
||||||
|
|
||||||
$users = array();
|
$users = array();
|
||||||
|
|
||||||
/* todo
|
|
||||||
* find what type of notification they'd like to receive
|
|
||||||
*/
|
|
||||||
$sql = 'SELECT user_id
|
$sql = 'SELECT user_id
|
||||||
FROM ' . BOOKMARKS_TABLE . '
|
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);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$users[$row['user_id']] = array('');
|
$users[] = $row['user_id'];
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// Never notify the poster
|
|
||||||
unset($users[$post['poster_id']]);
|
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
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))
|
if (empty($auth_read))
|
||||||
{
|
{
|
||||||
|
@ -92,10 +87,21 @@ class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post
|
||||||
|
|
||||||
$notify_users = array();
|
$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;
|
return $notify_users;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,23 +93,21 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
||||||
$sql = 'SELECT user_id
|
$sql = 'SELECT user_id
|
||||||
FROM ' . TOPICS_WATCH_TABLE . '
|
FROM ' . TOPICS_WATCH_TABLE . '
|
||||||
WHERE topic_id = ' . (int) $post['topic_id'] . '
|
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);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$users[$row['user_id']] = array('');
|
$users[] = $row['user_id'];
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// Never notify the poster
|
|
||||||
unset($users[$post['poster_id']]);
|
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
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))
|
if (empty($auth_read))
|
||||||
{
|
{
|
||||||
|
@ -118,10 +116,21 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
||||||
|
|
||||||
$notify_users = array();
|
$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;
|
return $notify_users;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class phpbb_notifications_type_post_in_queue extends phpbb_notifications_type_po
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . USER_NOTIFICATIONS_TABLE . "
|
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']);
|
AND " . $db->sql_in_set('user_id', $auth_approve[$topic['forum_id']]['m_approve']);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
|
@ -81,28 +81,23 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post
|
||||||
|
|
||||||
$users = array();
|
$users = array();
|
||||||
|
|
||||||
/* todo
|
|
||||||
* find what type of notification they'd like to receive
|
|
||||||
*/
|
|
||||||
$sql = 'SELECT user_id
|
$sql = 'SELECT user_id
|
||||||
FROM ' . USERS_TABLE . '
|
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);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$users[$row['user_id']] = array('');
|
$users[] = $row['user_id'];
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// Never notify the poster
|
|
||||||
unset($users[$post['poster_id']]);
|
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
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))
|
if (empty($auth_read))
|
||||||
{
|
{
|
||||||
|
@ -111,10 +106,21 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post
|
||||||
|
|
||||||
$notify_users = array();
|
$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;
|
return $notify_users;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,30 +86,24 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
||||||
|
|
||||||
$users = array();
|
$users = array();
|
||||||
|
|
||||||
/* todo
|
|
||||||
* find what type of notification they'd like to receive
|
|
||||||
* make sure not to send duplicate notifications
|
|
||||||
*/
|
|
||||||
$sql = 'SELECT user_id
|
$sql = 'SELECT user_id
|
||||||
FROM ' . FORUMS_WATCH_TABLE . '
|
FROM ' . FORUMS_WATCH_TABLE . '
|
||||||
WHERE forum_id = ' . (int) $topic['forum_id'] . '
|
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);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$users[$row['user_id']] = array('');
|
$users[] = $row['user_id'];
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// Never notify the poster
|
|
||||||
unset($users[$topic['poster_id']]);
|
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
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))
|
if (empty($auth_read))
|
||||||
{
|
{
|
||||||
|
@ -118,10 +112,21 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
||||||
|
|
||||||
$notify_users = array();
|
$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;
|
return $notify_users;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class phpbb_notifications_type_topic_in_queue extends phpbb_notifications_type_t
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . USER_NOTIFICATIONS_TABLE . "
|
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']);
|
AND " . $db->sql_in_set('user_id', $auth_approve[$topic['forum_id']]['m_approve']);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
Loading…
Add table
Reference in a new issue