mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/12493] Add functional test [ticket/12493] Fix sql query for selection of users that have disabled PM
This commit is contained in:
commit
3a39a99ed6
2 changed files with 77 additions and 8 deletions
|
@ -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);
|
||||
|
||||
|
|
70
tests/functional/ucp_allow_pm_test.php
Normal file
70
tests/functional/ucp_allow_pm_test.php
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue