mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/10684] Send notifications for users with stale bans
PHPBB3-10684
This commit is contained in:
parent
d67fae0f09
commit
025de9ee19
2 changed files with 48 additions and 17 deletions
|
@ -1180,28 +1180,23 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
|
||||||
$topic_title = ($topic_notification) ? $topic_title : $subject;
|
$topic_title = ($topic_notification) ? $topic_title : $subject;
|
||||||
$topic_title = censor_text($topic_title);
|
$topic_title = censor_text($topic_title);
|
||||||
|
|
||||||
// Get banned User ID's
|
// Exclude guests, current user and banned users from notifications
|
||||||
$sql = 'SELECT ban_userid
|
if (!function_exists('phpbb_get_banned_users_ids'))
|
||||||
FROM ' . BANLIST_TABLE . '
|
|
||||||
WHERE ban_userid <> 0
|
|
||||||
AND ban_exclude <> 1';
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id'];
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
{
|
||||||
$sql_ignore_users .= ', ' . (int) $row['ban_userid'];
|
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$sql_ignore_users = phpbb_get_banned_users_ids();
|
||||||
|
$sql_ignore_users[ANONYMOUS] = ANONYMOUS;
|
||||||
|
$sql_ignore_users[$user->data['user_id']] = $user->data['user_id'];
|
||||||
|
|
||||||
$notify_rows = array();
|
$notify_rows = array();
|
||||||
|
|
||||||
// -- get forum_userids || topic_userids
|
// -- get forum_userids || topic_userids
|
||||||
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
|
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
|
||||||
FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u
|
FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u
|
||||||
WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . "
|
WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . '
|
||||||
AND w.user_id NOT IN ($sql_ignore_users)
|
AND ' . $db->sql_in_set('w.user_id', $sql_ignore_users, true) . '
|
||||||
AND w.notify_status = " . NOTIFY_YES . '
|
AND w.notify_status = ' . NOTIFY_YES . '
|
||||||
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
|
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
|
||||||
AND u.user_id = w.user_id';
|
AND u.user_id = w.user_id';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
@ -1225,16 +1220,23 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
|
||||||
// forum notification is sent to those not already receiving topic notifications
|
// forum notification is sent to those not already receiving topic notifications
|
||||||
if ($topic_notification)
|
if ($topic_notification)
|
||||||
{
|
{
|
||||||
|
// Add users who has been already notified to ignore list
|
||||||
if (sizeof($notify_rows))
|
if (sizeof($notify_rows))
|
||||||
{
|
{
|
||||||
$sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows));
|
foreach ($notify_rows as $user_id => $row)
|
||||||
|
{
|
||||||
|
if (!isset($sql_ignore_users[$user_id]))
|
||||||
|
{
|
||||||
|
$sql_ignore_users[$user_id] = $user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
|
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
|
||||||
FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u
|
FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u
|
||||||
WHERE fw.forum_id = $forum_id
|
WHERE fw.forum_id = $forum_id
|
||||||
AND fw.user_id NOT IN ($sql_ignore_users)
|
AND " . $db->sql_in_set('fw.user_id', $sql_ignore_users, true) . '
|
||||||
AND fw.notify_status = " . NOTIFY_YES . '
|
AND fw.notify_status = ' . NOTIFY_YES . '
|
||||||
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
|
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
|
||||||
AND u.user_id = fw.user_id';
|
AND u.user_id = fw.user_id';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
|
@ -3587,4 +3587,33 @@ function remove_newly_registered($user_id, $user_data = false)
|
||||||
return $user_data['group_id'];
|
return $user_data['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of banned users' ids, ignoring stale buns which were not wiped yet.
|
||||||
|
*
|
||||||
|
* @return array Array of banned users' ids if any, empty array otherwise
|
||||||
|
*/
|
||||||
|
function phpbb_get_banned_users_ids()
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
// Get banned User ID's
|
||||||
|
// Ignore stale bans which were not wiped yet
|
||||||
|
$banned_ids_list = array();
|
||||||
|
$sql = 'SELECT ban_userid
|
||||||
|
FROM ' . BANLIST_TABLE . '
|
||||||
|
WHERE ban_userid <> 0
|
||||||
|
AND ban_exclude <> 1
|
||||||
|
AND (ban_end > ' . time() . '
|
||||||
|
OR ban_end = 0)';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$user_id = (int) $row['ban_userid'];
|
||||||
|
$banned_ids_list[$user_id] = $user_id;
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
return $banned_ids_list;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue