From 6f4538c676ebd3b6e299a606a04f672698ebc487 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 4 Jul 2012 10:34:09 -0500 Subject: [PATCH] [ticket/8323] Hide the Send PM link if users cannot receive the PM Updated memberlist/viewtopic to the new rules PHPBB3-8323 --- phpBB/memberlist.php | 10 +++++++++- phpBB/viewtopic.php | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index ed87b6c448..8e2ce4d818 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1690,6 +1690,14 @@ 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 && (($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; + // Dump it out to the template return array( 'AGE' => $age, @@ -1719,7 +1727,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&sr=posts") : '', 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&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&mode=warn_user&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&mode=compose&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&mode=compose&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 b75f4aeccf..10ec6f4ee7 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(); @@ -1108,6 +1109,7 @@ while ($row = $db->sql_fetchrow($result)) $id_cache[] = $poster_id; $user_cache[$poster_id] = array( + 'user_type' => $row['user_type'], 'joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, @@ -1315,6 +1317,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 banned users +$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache)); + $i_total = sizeof($rowset) - 1; $prev_post_id = ''; @@ -1487,6 +1496,9 @@ 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 && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users))) ? true : false; + // $postrow = 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']), @@ -1527,7 +1539,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&mode=compose&action=quotepost&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&mode=compose&action=quotepost&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'],