mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/8323] Allow sending PMs to temporarily banned users
Added an argument to the phpbb_get_banned_user_ids() function to allow specifying a banned end time (default true for current functionality, false for only permanent bans, timestamp to find banned until a specified time) PHPBB3-8323
This commit is contained in:
parent
0f4956b280
commit
362ba43f18
5 changed files with 39 additions and 18 deletions
|
@ -269,46 +269,46 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
|
|||
case RULE_IS_LIKE:
|
||||
$result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_IS_NOT_LIKE:
|
||||
$result = !preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_IS:
|
||||
$result = ($check0 == $rule_row['rule_string']);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_IS_NOT:
|
||||
$result = ($check0 != $rule_row['rule_string']);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_BEGINS_WITH:
|
||||
$result = preg_match("/^" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_ENDS_WITH:
|
||||
$result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '$/i', $check0);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_IS_FRIEND:
|
||||
case RULE_IS_FOE:
|
||||
case RULE_ANSWERED:
|
||||
case RULE_FORWARDED:
|
||||
$result = ($check0 == 1);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_IS_USER:
|
||||
$result = ($check0 == $rule_row['rule_user_id']);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_IS_GROUP:
|
||||
$result = in_array($rule_row['rule_group_id'], $check0);
|
||||
break;
|
||||
|
||||
|
||||
case RULE_TO_GROUP:
|
||||
$result = (in_array('g_' . $message_row[$check_ary['check2']], $check0) || in_array('g_' . $message_row[$check_ary['check2']], $message_row[$check_ary['check1']]));
|
||||
break;
|
||||
|
||||
|
||||
case RULE_TO_ME:
|
||||
$result = (in_array('u_' . $user_id, $check0) || in_array('u_' . $user_id, $message_row[$check_ary['check1']]));
|
||||
break;
|
||||
|
@ -1828,11 +1828,12 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i
|
|||
return;
|
||||
}
|
||||
|
||||
// Get permanently banned users (do not allow sending to these users)
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
$banned_users = phpbb_get_banned_user_ids(array_keys($recipients));
|
||||
$banned_users = phpbb_get_banned_user_ids(array_keys($recipients), false);
|
||||
$recipients = array_diff(array_keys($recipients), $banned_users);
|
||||
|
||||
if (!sizeof($recipients))
|
||||
|
|
|
@ -3668,9 +3668,12 @@ function remove_newly_registered($user_id, $user_data = false)
|
|||
*
|
||||
* @param array $user_ids Array of users' ids to check for banning,
|
||||
* leave empty to get complete list of banned ids
|
||||
* @param bool|int $ban_end Bool True to get users currently banned
|
||||
* Bool False to only get permanently banned users
|
||||
* Int Unix timestamp to get users banned until that time
|
||||
* @return array Array of banned users' ids if any, empty array otherwise
|
||||
*/
|
||||
function phpbb_get_banned_user_ids($user_ids = array())
|
||||
function phpbb_get_banned_user_ids($user_ids = array(), $ban_end = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -3682,9 +3685,26 @@ function phpbb_get_banned_user_ids($user_ids = array())
|
|||
$sql = 'SELECT ban_userid
|
||||
FROM ' . BANLIST_TABLE . "
|
||||
WHERE $sql_user_ids
|
||||
AND ban_exclude <> 1
|
||||
AND (ban_end > " . time() . '
|
||||
AND ban_exclude <> 1";
|
||||
|
||||
if ($ban_end === true)
|
||||
{
|
||||
// Banned currently
|
||||
$sql .= " AND (ban_end > " . time() . '
|
||||
OR ban_end = 0)';
|
||||
}
|
||||
else if ($ban_end === false)
|
||||
{
|
||||
// Permanently banned
|
||||
$sql .= " AND ban_end = 0";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Banned until a specified time
|
||||
$sql .= " AND (ban_end > " . (int) $ban_end . '
|
||||
OR ban_end = 0)';
|
||||
}
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
|
|
|
@ -1270,7 +1270,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
|
|||
// Only check if not a moderator or admin, since they are allowed to override this user setting
|
||||
if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
|
||||
{
|
||||
$banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']));
|
||||
$banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false);
|
||||
|
||||
if (!empty($banned_user_list))
|
||||
{
|
||||
|
|
|
@ -1696,7 +1696,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
|
|||
}
|
||||
|
||||
// Can this user receive a Private Message?
|
||||
$can_receive_pm = ($data['user_type'] <> USER_IGNORE && $data['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id))))) ? true : false;
|
||||
$can_receive_pm = ($data['user_type'] <> USER_IGNORE && $data['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id, false))))) ? true : false;
|
||||
|
||||
// Dump it out to the template
|
||||
return array(
|
||||
|
|
|
@ -1321,8 +1321,8 @@ if ($bbcode_bitfield !== '')
|
|||
$can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm');
|
||||
$can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm'];
|
||||
|
||||
// Get the list of banned users
|
||||
$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache));
|
||||
// Get the list of permanently banned users
|
||||
$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false);
|
||||
|
||||
$i_total = sizeof($rowset) - 1;
|
||||
$prev_post_id = '';
|
||||
|
|
Loading…
Add table
Reference in a new issue