Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
team
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 query
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 *
4 * This file is part of the phpBB Forum Software package.
5 *
6 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7 * @license       GNU General Public License, version 2 (GPL-2.0)
8 *
9 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14namespace phpbb\mention\source;
15
16class team extends base_user
17{
18    /** @var int */
19    protected $cache_ttl = 300;
20
21    /**
22     * {@inheritdoc}
23     */
24    protected function query(string $keyword, int $topic_id): string
25    {
26        /*
27         * Select unique names of team members: each name should be selected only once
28         * regardless of the number of groups the certain user is a member of
29         *
30         * For optimization purposes all team members are returned regardless of the keyword
31         * Names filtering is done on the frontend
32         * Results will be cached in a single file
33         */
34        return $this->db->sql_build_query('SELECT_DISTINCT', [
35            'SELECT'    => 'u.username_clean, u.user_id',
36            'FROM'      => [
37                USERS_TABLE => 'u',
38                USER_GROUP_TABLE => 'ug',
39                TEAMPAGE_TABLE => 't',
40            ],
41            'WHERE'     => 'ug.group_id = t.group_id AND ug.user_id = u.user_id AND ug.user_pending = 0
42                AND ' . $this->db->sql_in_set('u.user_type', [USER_NORMAL, USER_FOUNDER]),
43            'ORDER_BY'  => 'u.username_clean'
44        ]);
45    }
46}