aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_privmsgs.php11
-rw-r--r--phpBB/includes/functions_user.php26
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php53
-rw-r--r--phpBB/language/en/ucp.php1
-rw-r--r--phpBB/memberlist.php16
-rw-r--r--phpBB/viewtopic.php22
6 files changed, 122 insertions, 7 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index ba939d490e..57c872d91a 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1884,6 +1884,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i
return;
}
+ // Get currently banned users (do not notify these users)
if (!function_exists('phpbb_get_banned_user_ids'))
{
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
@@ -1891,12 +1892,18 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i
$banned_users = phpbb_get_banned_user_ids(array_keys($recipients));
$recipients = array_diff(array_keys($recipients), $banned_users);
+ // Get the list of users who can read PMs (only notify those who can read PMs)
+ $can_read = $auth->acl_get_list($recipients, 'u_readpm');
+ $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm'];
+ $recipients = array_intersect($recipients, $can_read);
+
if (!sizeof($recipients))
{
return;
}
- $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
+ // Get the list of users who want to receive notifications, are "normal" and not deactivated, and have a non-blank email address
+ $sql = 'SELECT user_id, username, user_type, user_inactive_reason, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $recipients);
$result = $db->sql_query($sql);
@@ -1904,7 +1911,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i
$msg_list_ary = array();
while ($row = $db->sql_fetchrow($result))
{
- if ($row['user_notify_pm'] == 1 && trim($row['user_email']))
+ if ($row['user_notify_pm'] == 1 && $row['user_type'] != USER_IGNORE && !($row['user_type'] == USER_INACTIVE && $row['user_inactive_reason'] == INACTIVE_MANUAL) && trim($row['user_email']))
{
$msg_list_ary[] = array(
'method' => $row['user_notify_type'],
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 8f9c9198f4..aeb9c8dd5c 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -3817,9 +3817,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;
@@ -3831,9 +3834,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))
{
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 5577e8dab3..f6192a3588 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -1246,6 +1246,59 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
$error[] = $user->lang['PM_USERS_REMOVED_NO_PM'];
}
}
+
+ // Administrator deactivated users check
+ $sql = 'SELECT user_id
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . '
+ AND user_type = ' . USER_INACTIVE . '
+ AND user_inactive_reason = ' . INACTIVE_MANUAL;
+ $result = $db->sql_query($sql);
+
+ $removed = false;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $removed = true;
+ unset($address_list['u'][$row['user_id']]);
+ }
+ $db->sql_freeresult($result);
+
+ // print a notice about users not being added who do not want to receive pms
+ if ($removed)
+ {
+ $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
+ }
+
+ if (!sizeof(array_keys($address_list['u'])))
+ {
+ return;
+ }
+
+ // Check if users have permission to read PMs
+ $can_read = $auth->acl_get_list(array_keys($address_list['u']), 'u_readpm');
+ $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm'];
+ $cannot_read_list = array_diff(array_keys($address_list['u']), $can_read);
+ if (!empty($cannot_read_list))
+ {
+ foreach ($cannot_read_list as $cannot_read)
+ {
+ unset($address_list['u'][$cannot_read]);
+ }
+
+ $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
+ }
+
+ // Check if users are banned
+ $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false);
+ if (!empty($banned_user_list))
+ {
+ foreach ($banned_user_list as $banned_user)
+ {
+ unset($address_list['u'][$banned_user]);
+ }
+
+ $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
+ }
}
}
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 267ae00710..936bad7a99 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -368,6 +368,7 @@ $lang = array_merge($lang, array(
'PM_SENTBOX' => 'Sent messages',
'PM_SUBJECT' => 'Message subject',
'PM_TO' => 'Send to',
+ 'PM_USERS_REMOVED_NO_PERMISSION' => 'Some users couldn’t be added as they do not have permission to read private messages.',
'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.',
'POPUP_ON_PM' => 'Pop up window on new private message',
'POST_EDIT_PM' => 'Edit message',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index d9ba147c70..1320a2c02e 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -1712,6 +1712,20 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
}
}
+ if (!function_exists('phpbb_get_banned_user_ids'))
+ {
+ include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
+ }
+
+ // Can this user receive a Private Message?
+ $can_receive_pm = (
+ $data['user_type'] != USER_IGNORE && // They must be a "normal" user
+ ($data['user_type'] != USER_INACTIVE && $data['user_inactive_reason'] == INACTIVE_MANUAL) && // They must not be deactivated by the administrator
+ sizeof($auth->acl_get_list($user_id, 'u_readpm')) && // They must be able to read PMs
+ !sizeof(phpbb_get_banned_user_ids($user_id, false)) && // They must not be permanently banned
+ (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM
+ ) ? true : false;
+
// Dump it out to the template
$template_data = array(
'AGE' => $age,
@@ -1741,7 +1755,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&amp;sr=posts") : '',
'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $user_id, true, $user->session_id) : '',
'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_user&amp;u=' . $user_id, true, $user->session_id) : '',
- 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '',
+ 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '',
'U_EMAIL' => $email,
'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '',
'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '',
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 3fde5b5e03..90cb7e9567 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -16,6 +16,7 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
+include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Start session management
$user->session_begin();
@@ -1137,6 +1138,9 @@ while ($row = $db->sql_fetchrow($result))
$id_cache[] = $poster_id;
$user_cache_data = array(
+ 'user_type' => $row['user_type'],
+ 'user_inactive_reason' => $row['user_inactive_reason'],
+
'joined' => $user->format_date($row['user_regdate']),
'posts' => $row['user_posts'],
'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
@@ -1368,6 +1372,13 @@ if ($bbcode_bitfield !== '')
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
+// Get the list of users who can receive private messages
+$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 permanently banned users
+$permanently_banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false);
+
$i_total = sizeof($rowset) - 1;
$prev_post_id = '';
@@ -1540,6 +1551,15 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
!$row['post_edit_locked']
)));
+ // Can this user receive a Private Message?
+ $can_receive_pm = (
+ $user_cache[$poster_id]['user_type'] != USER_IGNORE && // They must be a "normal" user
+ ($user_cache[$poster_id]['user_type'] != USER_INACTIVE && $user_cache[$poster_id]['user_inactive_reason'] == INACTIVE_MANUAL) && // They must not be deactivated by the administrator
+ in_array($poster_id, $can_receive_pm_list) && // They must be able to read PMs
+ !in_array($poster_id, $permanently_banned_users) && // They must not be permanently banned
+ (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM
+ ) ? true : false;
+
//
$post_row = array(
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
@@ -1580,7 +1600,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'U_PROFILE' => $user_cache[$poster_id]['profile'],
'U_SEARCH' => $user_cache[$poster_id]['search'],
- 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']) : '',
+ 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']) : '',
'U_EMAIL' => $user_cache[$poster_id]['email'],
'U_WWW' => $user_cache[$poster_id]['www'],
'U_ICQ' => $user_cache[$poster_id]['icq'],