mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge pull request #1336 from nickvergessen/ticket/11492
[ticket/11492] Fix error on teampage when there are no users.
This commit is contained in:
commit
08e7e8722a
3 changed files with 124 additions and 3 deletions
|
@ -146,7 +146,7 @@ switch ($mode)
|
|||
|
||||
$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
|
||||
|
||||
$user_ary = array();
|
||||
$user_ary = $user_ids = $group_users = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$row['forums'] = '';
|
||||
|
@ -157,11 +157,13 @@ switch ($mode)
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($config['teampage_forums'])
|
||||
$user_ids = array_unique($user_ids);
|
||||
|
||||
if (!empty($user_ids) && $config['teampage_forums'])
|
||||
{
|
||||
$template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true);
|
||||
// Get all moderators
|
||||
$perm_ary = $auth->acl_get_list(array_unique($user_ids), array('m_'), false);
|
||||
$perm_ary = $auth->acl_get_list($user_ids, array('m_'), false);
|
||||
|
||||
foreach ($perm_ary as $forum_id => $forum_ary)
|
||||
{
|
||||
|
|
|
@ -40,4 +40,39 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
|
|||
$this->assert_response_success();
|
||||
$this->assertContains('admin', $crawler->filter('h2')->text());
|
||||
}
|
||||
|
||||
public function test_leaders()
|
||||
{
|
||||
$this->login();
|
||||
$this->create_user('memberlist-test-moderator');
|
||||
|
||||
// Admin should be listed, user not
|
||||
$crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('admin', $crawler->text());
|
||||
$this->assertNotContains('memberlist-test-user', $crawler->text());
|
||||
$this->assertNotContains('memberlist-test-moderator', $crawler->text());
|
||||
}
|
||||
|
||||
public function test_leaders_remove_users()
|
||||
{
|
||||
$this->login();
|
||||
|
||||
// Remove admin from admins
|
||||
$this->remove_user_group('ADMINISTRATORS', array('admin'));
|
||||
$crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('admin', $crawler->text());
|
||||
}
|
||||
|
||||
public function test_leaders_add_users()
|
||||
{
|
||||
$this->login();
|
||||
|
||||
// Add mod to moderators
|
||||
$this->add_user_group('GLOBAL_MODERATORS', array('memberlist-test-moderator'));
|
||||
$crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('memberlist-test-moderator', $crawler->text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,6 +316,90 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
return user_add($user_row);
|
||||
}
|
||||
|
||||
protected function remove_user_group($group_name, $usernames)
|
||||
{
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = new phpbb_config(array());
|
||||
$config['coppa_enable'] = 0;
|
||||
|
||||
$db = $this->get_db();
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$auth = $this->getMock('phpbb_auth');
|
||||
|
||||
$phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
|
||||
$cache = new phpbb_mock_null_cache;
|
||||
|
||||
$cache_driver = new phpbb_cache_driver_null();
|
||||
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$phpbb_container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->with('cache.driver')
|
||||
->will($this->returnValue($cache_driver));
|
||||
|
||||
if (!function_exists('utf_clean_string'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
|
||||
}
|
||||
if (!function_exists('group_user_del'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
|
||||
}
|
||||
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $db->sql_escape($group_name) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$group_id = (int) $db->sql_fetchfield('group_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return group_user_del($group_id, false, $usernames, $group_name);
|
||||
}
|
||||
|
||||
protected function add_user_group($group_name, $usernames)
|
||||
{
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = new phpbb_config(array());
|
||||
$config['coppa_enable'] = 0;
|
||||
|
||||
$db = $this->get_db();
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$auth = $this->getMock('phpbb_auth');
|
||||
|
||||
$phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
|
||||
$cache = new phpbb_mock_null_cache;
|
||||
|
||||
$cache_driver = new phpbb_cache_driver_null();
|
||||
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$phpbb_container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->with('cache.driver')
|
||||
->will($this->returnValue($cache_driver));
|
||||
|
||||
if (!function_exists('utf_clean_string'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
|
||||
}
|
||||
if (!function_exists('group_user_del'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
|
||||
}
|
||||
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $db->sql_escape($group_name) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$group_id = (int) $db->sql_fetchfield('group_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return group_user_add($group_id, false, $usernames, $group_name);
|
||||
}
|
||||
|
||||
protected function login($username = 'admin')
|
||||
{
|
||||
$this->add_lang('ucp');
|
||||
|
|
Loading…
Add table
Reference in a new issue