diff options
-rw-r--r-- | phpBB/includes/functions_posting.php | 4 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_compose.php | 15 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/viewtopic_body.html | 3 | ||||
-rw-r--r-- | phpBB/styles/prosilver/theme/colours.css | 4 | ||||
-rw-r--r-- | phpBB/styles/prosilver/theme/content.css | 4 | ||||
-rw-r--r-- | phpBB/styles/subsilver2/template/viewtopic_body.html | 1 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 2 | ||||
-rw-r--r-- | tests/functional/ucp_allow_pm_test.php | 70 |
8 files changed, 91 insertions, 12 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 547ea69e81..cc46799252 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) function generate_smilies($mode, $forum_id) { global $db, $user, $config, $template, $phpbb_dispatcher; - global $phpEx, $phpbb_root_path, $phpbb_container; + global $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_path_helper; $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id); $pagination = $phpbb_container->get('pagination'); @@ -111,7 +111,7 @@ function generate_smilies($mode, $forum_id) if (sizeof($smilies)) { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); foreach ($smilies as $row) { diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 3219771c93..16b3ca8573 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1226,6 +1226,8 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove // Check for disallowed recipients if (!empty($address_list['u'])) { + $can_ignore_allow_pm = $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'); + // Administrator deactivated users check and we need to check their // PM status (do they want to receive PM's?) // Only check PM status if not a moderator or admin, since they @@ -1233,14 +1235,11 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove $sql = 'SELECT user_id, user_allow_pm 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 . ')'; - - $can_ignore_allow_pm = ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')); - if (!$can_ignore_allow_pm) - { - $sql .= ' OR user_allow_pm = 0'; - } + AND ( + (user_type = ' . USER_INACTIVE . ' + AND user_inactive_reason = ' . INACTIVE_MANUAL . ') + ' . ($can_ignore_allow_pm ? '' : ' OR user_allow_pm = 0') . ' + )'; $result = $db->sql_query($sql); diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 6adb690391..1e5700ba69 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -116,7 +116,7 @@ <!-- BEGIN postrow --> <!-- EVENT viewtopic_body_postrow_post_before --> <!-- IF postrow.S_FIRST_UNREAD --><a id="unread"></a><!-- ENDIF --> - <div id="p{postrow.POST_ID}" class="post <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_POST_DELETED --> deleted<!-- ENDIF --><!-- IF postrow.S_ONLINE and not postrow.S_POST_HIDDEN --> online<!-- ENDIF -->"> + <div id="p{postrow.POST_ID}" class="post <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_POST_DELETED --> deleted<!-- ENDIF --><!-- IF postrow.S_ONLINE and not postrow.S_POST_HIDDEN --> online<!-- ENDIF --><!-- IF postrow.POSTER_WARNINGS --> warned<!-- ENDIF -->"> <div class="inner"> <dl class="postprofile" id="profile{postrow.POST_ID}"<!-- IF postrow.S_POST_HIDDEN --> style="display: none;"<!-- ENDIF -->> @@ -131,6 +131,7 @@ <!-- IF postrow.POSTER_POSTS != '' --><dd class="profile-posts"><strong>{L_POSTS}{L_COLON}</strong> {postrow.POSTER_POSTS}</dd><!-- ENDIF --> <!-- IF postrow.POSTER_JOINED --><dd class="profile-joined"><strong>{L_JOINED}{L_COLON}</strong> {postrow.POSTER_JOINED}</dd><!-- ENDIF --> + <!-- IF postrow.POSTER_WARNINGS --><dd class="profile-warnings"><strong>{L_WARNINGS}{L_COLON}</strong> {postrow.POSTER_WARNINGS}</dd><!-- ENDIF --> <!-- IF postrow.S_PROFILE_FIELD1 --> <!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. --> diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 39f28b4774..f43dfcfcce 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -660,6 +660,10 @@ fieldset.polls dd div { background-image: url("./en/icon_user_online.gif"); } +dd.profile-warnings { + color: #BC2A4D; +} + /* -------------------------------------------------------------- Colours and backgrounds for buttons.css diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 11cc51f954..b66c841d7c 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -735,6 +735,10 @@ fieldset.polls dd div { height: auto !important; } +dd.profile-warnings { + font-weight: bold; +} + dd.profile-contact { overflow: visible; } diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 6ac4e0ea33..862c1a4d0b 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -204,6 +204,7 @@ <span class="postdetails"> <!-- IF postrow.POSTER_JOINED --><br /><b>{L_JOINED}{L_COLON}</b> {postrow.POSTER_JOINED}<!-- ENDIF --> <!-- IF postrow.POSTER_POSTS != '' --><br /><b>{L_POSTS}{L_COLON}</b> {postrow.POSTER_POSTS}<!-- ENDIF --> + <!-- IF postrow.POSTER_WARNINGS --><br /><b>{L_WARNINGS}{L_COLON}</b> {postrow.POSTER_WARNINGS}<!-- ENDIF --> <!-- IF postrow.S_PROFILE_FIELD1 --> <!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. --> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 84040af2bb..a0cd590e58 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1642,7 +1642,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'POSTER_JOINED' => $user_cache[$poster_id]['joined'], 'POSTER_POSTS' => $user_cache[$poster_id]['posts'], 'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'], - 'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'], + 'POSTER_WARNINGS' => $auth->acl_get('m_warn') ? $user_cache[$poster_id]['warnings'] : '', 'POSTER_AGE' => $user_cache[$poster_id]['age'], 'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false), diff --git a/tests/functional/ucp_allow_pm_test.php b/tests/functional/ucp_allow_pm_test.php new file mode 100644 index 0000000000..b433ec8e75 --- /dev/null +++ b/tests/functional/ucp_allow_pm_test.php @@ -0,0 +1,70 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case +{ + static protected $data = array(); + + public function __construct() + { + parent::__construct(); + + $this->backupStaticAttributesBlacklist += array( + 'phpbb_functional_ucp_allow_pm_test' => array('data'), + ); + } + + // user A sends a PM to user B where B accepts PM + public function test_enabled_pm_user_to_user() + { + // setup + $this->create_user('test_ucp_allow_pm_sender'); + $this->login('test_ucp_allow_pm_sender'); + self::$data['recipient_id'] = $this->create_user('test_ucp_allow_pm_recipient'); + self::$data['pm_url'] = "ucp.php?i=pm&mode=compose&u=" . (int) self::$data['recipient_id'] . "&sid={$this->sid}"; + + // the actual test + $this->set_user_allow_pm(self::$data['recipient_id'], 1); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); + } + + // user A sends a PM to user B where B does not accept PM + public function test_disabled_pm_user_to_user() + { + $this->login('test_ucp_allow_pm_sender'); + $this->set_user_allow_pm(self::$data['recipient_id'], 0); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('.error')->text()); + } + + + // An admin sends a PM to user B where B does not accept PM, but cannot + // ignore a PM from an admin + public function test_disabled_pm_admin_to_user() + { + $this->login(); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); + } + + // enable or disable PM for a user, like from ucp + protected function set_user_allow_pm($user_id, $allow) + { + $db = $this->get_db(); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_allow_pm = " . $allow . " + WHERE user_id = " . $user_id; + $result = $db->sql_query($sql); + $db->sql_freeresult($result); + } +} |