#3087 - Banned members still receiving email notifications

This is a spacer post for a website comment topic. The content this topic relates to: #3087 - Banned members still receiving email notifications
Going to test the following implementation in sources/mail.php:

FIND (in function mail_wrap):

if (@$GLOBALS['SITE_INFO']['no_email_output'] === '1') {
return null;
}

AFTER, ADD:

if ($priority != 1)
{
foreach ($to_email as $key => $email)
{
if ($GLOBALS['FORUM_DRIVER']->is_banned($GLOBALS['FORUM_DRIVER']->get_member_from_email_address($email))) {
unset($to_email[$key]);
}
}
}

The goal of this is to remove the email addresses of all members who have been marked as banned UNLESS mail priority is 1 (critical/urgent). The reason for this priority bypass is because without it, members will not get notifications of private topics telling them that they were banned (I'll be hacking the warnings module to make private topics generated by warnings to have priority 1).
Not able to hack the warnings system to do the desired operation, but since the warnings system sends posts as emphasised, I did something else.

sources/cns_topics_action2.php

FIND (in function send_pt_notification):

if (is_null($post_comcode)) {
$post_comcode = get_translated_text($GLOBALS['FORUM_DB']->query_select_value('f_posts', 'p_post', array('id' => $post_id)), $GLOBALS['FORUM_DB']);
}

AFTER, ADD:

$emphasised = ($GLOBALS['SITE_DB']->query_select_value('f_posts', 'p_is_emphasised', array('id' => $post_id)) == 1);

FIND:

dispatch_notification('cns_new_pt', null, $msubject, $mmessage, array($to_id), $from_id);

CHANGE TO:

dispatch_notification('cns_new_pt', null, $msubject, $mmessage, array($to_id), $from_id, ($emphasised) ? 1 : 3);

Will let you know how the hack goes.
The code seems to work well, although I did tweak the modification I used in mail.php to this:

if ($priority != 1 && !is_null($to_email))
{
foreach ($to_email as $key => $email)
{
if ($GLOBALS['FORUM_DRIVER']->is_banned($GLOBALS['FORUM_DRIVER']->get_member_from_email_address($email))) {
unset($to_email[$key]);
}

if (is_null($to_email) || count($to_email) == 0)
return null;
}
}

I'll get some kind of workaround as I agree with the core issue, but it would be very simple to workaround without a panic. You could just delete the account, or edit the account to have a different email address.
i.e. if a user is threatening legal action, I can't see any reason to continue to maintain any relationship with that user vis-a-vis an account tied to their email address. Unless it's an extreme situation, like government records.
Your fix is very good. I like the emphasised priority, even without the banned situation it is good.

I've made only a couple of changes:
1) I've improved get_member_from_email_address to prioritise non-banned and newer accounts (in case a duplicate account was banned)
2) I have disabled starting PTs and using contact-member in the UI to a banned member (nobody should do that as logging in to see the PTs won't be possible - it should be taken off the site via direct e-mail)
Sounds good. For 2, did you ensure this will not clash with the warnings module... eg. the warnings system sends the PT before the ban is registered?
Yeah, it's at the UI level only, i..e the forms to explicitly start these.
Ouch, I just realised something. Here's a problematic situation:

1. A user breaks the rules and earns a ban.
2. The user is set not to receive email notifications for private topics.
3. A staff member uses the warnings system to send them a PT informing them of their ban, and issues the ban.
4. The user is banned, but doesn't know about it and doesn't know why because a) no email was sent, and b) they cannot log in to view their warning PT.
I'll force the notification to email for banned members.
0 guests and 0 members have recently viewed this.