mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-09 19:26:53 +02:00
[ticket/13713] Create properly named base services for sources
PHPBB3-13713
This commit is contained in:
@ -16,33 +16,17 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: service_collection, tag: mention.source }
|
- { name: service_collection, tag: mention.source }
|
||||||
|
|
||||||
phpbb.mention.source.friend:
|
phpbb.mention.source.base_group:
|
||||||
class: phpbb\mention\source\friend
|
abstract: true
|
||||||
parent: phpbb.mention.source.user
|
arguments:
|
||||||
calls:
|
- '@dbal.conn'
|
||||||
- [set_user, ['@user']]
|
- '@group_helper'
|
||||||
tags:
|
- '@user'
|
||||||
- { name: mention.source }
|
- '@auth'
|
||||||
|
- '%core.root_path%'
|
||||||
|
- '%core.php_ext%'
|
||||||
|
|
||||||
phpbb.mention.source.member:
|
phpbb.mention.source.base_user:
|
||||||
class: phpbb\mention\source\member
|
|
||||||
parent: phpbb.mention.source.user
|
|
||||||
tags:
|
|
||||||
- { name: mention.source }
|
|
||||||
|
|
||||||
phpbb.mention.source.team:
|
|
||||||
class: phpbb\mention\source\team
|
|
||||||
parent: phpbb.mention.source.user
|
|
||||||
tags:
|
|
||||||
- { name: mention.source }
|
|
||||||
|
|
||||||
phpbb.mention.source.topic:
|
|
||||||
class: phpbb\mention\source\topic
|
|
||||||
parent: phpbb.mention.source.user
|
|
||||||
tags:
|
|
||||||
- { name: mention.source }
|
|
||||||
|
|
||||||
phpbb.mention.source.user:
|
|
||||||
abstract: true
|
abstract: true
|
||||||
arguments:
|
arguments:
|
||||||
- '@dbal.conn'
|
- '@dbal.conn'
|
||||||
@ -50,13 +34,40 @@ services:
|
|||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '%core.php_ext%'
|
- '%core.php_ext%'
|
||||||
|
|
||||||
phpbb.mention.source.usergroup:
|
phpbb.mention.source.friend:
|
||||||
class: phpbb\mention\source\usergroup
|
class: phpbb\mention\source\friend
|
||||||
arguments:
|
parent: phpbb.mention.source.base_user
|
||||||
- '@dbal.conn'
|
calls:
|
||||||
- '@group_helper'
|
- [set_user, ['@user']]
|
||||||
- '@user'
|
tags:
|
||||||
- '%core.root_path%'
|
- { name: mention.source }
|
||||||
- '%core.php_ext%'
|
|
||||||
|
phpbb.mention.source.group:
|
||||||
|
class: phpbb\mention\source\group
|
||||||
|
parent: phpbb.mention.source.base_group
|
||||||
|
tags:
|
||||||
|
- { name: mention.source }
|
||||||
|
|
||||||
|
phpbb.mention.source.team:
|
||||||
|
class: phpbb\mention\source\team
|
||||||
|
parent: phpbb.mention.source.base_user
|
||||||
|
tags:
|
||||||
|
- { name: mention.source }
|
||||||
|
|
||||||
|
phpbb.mention.source.topic:
|
||||||
|
class: phpbb\mention\source\topic
|
||||||
|
parent: phpbb.mention.source.base_user
|
||||||
|
tags:
|
||||||
|
- { name: mention.source }
|
||||||
|
|
||||||
|
phpbb.mention.source.user:
|
||||||
|
class: phpbb\mention\source\user
|
||||||
|
parent: phpbb.mention.source.base_user
|
||||||
|
tags:
|
||||||
|
- { name: mention.source }
|
||||||
|
|
||||||
|
phpbb.mention.source.usergroup:
|
||||||
|
class: phpbb\mention\source\usergroup
|
||||||
|
parent: phpbb.mention.source.base_group
|
||||||
tags:
|
tags:
|
||||||
- { name: mention.source }
|
- { name: mention.source }
|
||||||
|
148
phpBB/phpbb/mention/source/base_group.php
Normal file
148
phpBB/phpbb/mention/source/base_group.php
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
|
abstract class base_group implements source_interface
|
||||||
|
{
|
||||||
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
/** @var \phpbb\group\helper */
|
||||||
|
protected $helper;
|
||||||
|
|
||||||
|
/** @var \phpbb\user */
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
/** @var \phpbb\auth\auth */
|
||||||
|
protected $auth;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $php_ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\group\helper $helper, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $phpEx)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
$this->helper = $helper;
|
||||||
|
$this->user = $user;
|
||||||
|
$this->auth = $auth;
|
||||||
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
$this->php_ext = $phpEx;
|
||||||
|
|
||||||
|
if (!function_exists('phpbb_get_user_rank'))
|
||||||
|
{
|
||||||
|
include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data for all board groups
|
||||||
|
*
|
||||||
|
* @return array Array of groups' data
|
||||||
|
*/
|
||||||
|
protected function get_groups()
|
||||||
|
{
|
||||||
|
static $groups = null;
|
||||||
|
|
||||||
|
if (is_null($groups))
|
||||||
|
{
|
||||||
|
$query = $this->db->sql_build_query('SELECT', [
|
||||||
|
'SELECT' => 'g.*, ug.user_id as ug_user_id',
|
||||||
|
'FROM' => [
|
||||||
|
GROUPS_TABLE => 'g',
|
||||||
|
],
|
||||||
|
'LEFT_JOIN' => array(
|
||||||
|
array(
|
||||||
|
'FROM' => array(USER_GROUP_TABLE => 'ug'),
|
||||||
|
'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $this->user->data['user_id'],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
$result = $this->db->sql_query($query);
|
||||||
|
|
||||||
|
$groups = [];
|
||||||
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if ($row['group_type'] == GROUP_SPECIAL && !in_array($row['group_name'], ['ADMINISTRATORS', 'GLOBAL_MODERATORS']) || $row['group_type'] == GROUP_HIDDEN && !$this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $this->user->data['user_id'])
|
||||||
|
{
|
||||||
|
// Skip the group that we should not be able to mention.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$group_name = $this->helper->get_name($row['group_name']);
|
||||||
|
$groups['names'][$row['group_id']] = $group_name;
|
||||||
|
$groups[$row['group_id']] = $row;
|
||||||
|
$groups[$row['group_id']]['group_name'] = $group_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a query for getting group IDs based on user input
|
||||||
|
*
|
||||||
|
* @param string $keyword Search string
|
||||||
|
* @param int $topic_id Current topic ID
|
||||||
|
* @return string Query ready for execution
|
||||||
|
*/
|
||||||
|
abstract protected function query($keyword, $topic_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get($keyword, $topic_id)
|
||||||
|
{
|
||||||
|
// Grab all group IDs
|
||||||
|
$result = $this->db->sql_query($this->query($keyword, $topic_id));
|
||||||
|
|
||||||
|
$group_ids = [];
|
||||||
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$group_ids[] = $row['group_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Grab group data
|
||||||
|
$groups = $this->get_groups();
|
||||||
|
|
||||||
|
$matches = preg_grep('/^' . $keyword . '.*/i', $groups['names']);
|
||||||
|
$group_ids = array_intersect($group_ids, array_flip($matches));
|
||||||
|
|
||||||
|
$names = [];
|
||||||
|
foreach ($group_ids as $group_id)
|
||||||
|
{
|
||||||
|
$group_rank = phpbb_get_user_rank($groups[$group_id], false);
|
||||||
|
$names['g' . $group_id] = [
|
||||||
|
'name' => $groups[$group_id]['group_name'],
|
||||||
|
'param' => 'group_id',
|
||||||
|
'id' => $group_id,
|
||||||
|
'avatar' => [
|
||||||
|
'type' => 'group',
|
||||||
|
'src' => phpbb_get_group_avatar($groups[$group_id]),
|
||||||
|
],
|
||||||
|
'rank' => $group_rank['title'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
}
|
83
phpBB/phpbb/mention/source/base_user.php
Normal file
83
phpBB/phpbb/mention/source/base_user.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
|
abstract class base_user implements source_interface
|
||||||
|
{
|
||||||
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
/** @var \phpbb\user_loader */
|
||||||
|
protected $user_loader;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $php_ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user_loader $user_loader, $phpbb_root_path, $phpEx)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
$this->user_loader = $user_loader;
|
||||||
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
$this->php_ext = $phpEx;
|
||||||
|
|
||||||
|
if (!function_exists('phpbb_get_user_rank'))
|
||||||
|
{
|
||||||
|
include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a query based on user input
|
||||||
|
*
|
||||||
|
* @param string $keyword Search string
|
||||||
|
* @param int $topic_id Current topic ID
|
||||||
|
* @return string Query ready for execution
|
||||||
|
*/
|
||||||
|
abstract protected function query($keyword, $topic_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get($keyword, $topic_id)
|
||||||
|
{
|
||||||
|
$keyword = utf8_clean_string($keyword);
|
||||||
|
$result = $this->db->sql_query_limit($this->query($keyword, $topic_id), 5);
|
||||||
|
|
||||||
|
$names = [];
|
||||||
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$user_rank = $this->user_loader->get_rank($row['user_id'], true);
|
||||||
|
$names['u' . $row['user_id']] = [
|
||||||
|
'name' => $row['username'],
|
||||||
|
'param' => 'user_id',
|
||||||
|
'id' => $row['user_id'],
|
||||||
|
'avatar' => [
|
||||||
|
'type' => 'user',
|
||||||
|
'src' => $this->user_loader->get_avatar($row['user_id'], true),
|
||||||
|
],
|
||||||
|
'rank' => (isset($user_rank['rank_title'])) ? $user_rank['rank_title'] : '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
class friend extends user
|
class friend extends base_user
|
||||||
{
|
{
|
||||||
/** @var \phpbb\user */
|
/** @var \phpbb\user */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
@ -13,116 +13,19 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
abstract class group implements source_interface
|
class group extends base_group
|
||||||
{
|
{
|
||||||
/** @var \phpbb\db\driver\driver_interface */
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/** @var \phpbb\group\helper */
|
|
||||||
protected $helper;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $phpbb_root_path;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $php_ext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\group\helper $helper, $phpbb_root_path, $phpEx)
|
|
||||||
{
|
|
||||||
$this->db = $db;
|
|
||||||
$this->helper = $helper;
|
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
|
||||||
$this->php_ext = $phpEx;
|
|
||||||
|
|
||||||
if (!function_exists('phpbb_get_user_rank'))
|
|
||||||
{
|
|
||||||
include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns data for all board groups
|
|
||||||
*
|
|
||||||
* @return array Array of groups' data
|
|
||||||
*/
|
|
||||||
protected function get_groups()
|
|
||||||
{
|
|
||||||
static $groups = null;
|
|
||||||
|
|
||||||
if (is_null($groups))
|
|
||||||
{
|
|
||||||
$query = $this->db->sql_build_query('SELECT', [
|
|
||||||
'SELECT' => 'g.*',
|
|
||||||
'FROM' => [
|
|
||||||
GROUPS_TABLE => 'g',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
$result = $this->db->sql_query($query);
|
|
||||||
|
|
||||||
$groups = [];
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$group_name = $this->helper->get_name($row['group_name']);
|
|
||||||
$groups['names'][$row['group_id']] = $group_name;
|
|
||||||
$groups[$row['group_id']] = $row;
|
|
||||||
$groups[$row['group_id']]['group_name'] = $group_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
return $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a query for getting group IDs based on user input
|
|
||||||
*
|
|
||||||
* @param string $keyword Search string
|
|
||||||
* @param int $topic_id Current topic ID
|
|
||||||
* @return string Query ready for execution
|
|
||||||
*/
|
|
||||||
abstract protected function query($keyword, $topic_id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get($keyword, $topic_id)
|
protected function query($keyword, $topic_id)
|
||||||
{
|
{
|
||||||
// Grab all group IDs
|
$query = $this->db->sql_build_query('SELECT', [
|
||||||
$result = $this->db->sql_query($this->query($keyword, $topic_id));
|
'SELECT' => 'g.group_id',
|
||||||
|
'FROM' => [
|
||||||
$group_ids = [];
|
GROUPS_TABLE => 'g',
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
],
|
||||||
{
|
]);
|
||||||
$group_ids[] = $row['group_id'];
|
return $query;
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->sql_freeresult($result);
|
|
||||||
|
|
||||||
// Grab group data
|
|
||||||
$groups = $this->get_groups();
|
|
||||||
|
|
||||||
$matches = preg_grep('/^' . $keyword . '.*/i', $groups['names']);
|
|
||||||
$group_ids = array_intersect($group_ids, array_flip($matches));
|
|
||||||
|
|
||||||
$names = [];
|
|
||||||
foreach ($group_ids as $group_id)
|
|
||||||
{
|
|
||||||
$group_rank = phpbb_get_user_rank($groups[$group_id], false);
|
|
||||||
$names['g' . $group_id] = [
|
|
||||||
'name' => $groups[$group_id]['group_name'],
|
|
||||||
'param' => 'group_id',
|
|
||||||
'id' => $group_id,
|
|
||||||
'avatar' => [
|
|
||||||
'type' => 'group',
|
|
||||||
'src' => phpbb_get_group_avatar($groups[$group_id]),
|
|
||||||
],
|
|
||||||
'rank' => $group_rank['title'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $names;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This file is part of the phpBB Forum Software package.
|
|
||||||
*
|
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
||||||
*
|
|
||||||
* For full copyright and license information, please see
|
|
||||||
* the docs/CREDITS.txt file.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace phpbb\mention\source;
|
|
||||||
|
|
||||||
class member extends user
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function query($keyword, $topic_id)
|
|
||||||
{
|
|
||||||
$query = $this->db->sql_build_query('SELECT', [
|
|
||||||
'SELECT' => 'u.username, u.user_id',
|
|
||||||
'FROM' => [
|
|
||||||
USERS_TABLE => 'u',
|
|
||||||
],
|
|
||||||
'WHERE' => 'u.user_id <> ' . ANONYMOUS . '
|
|
||||||
AND ' . $this->db->sql_in_set('u.user_type', [USER_NORMAL, USER_FOUNDER]) . '
|
|
||||||
AND u.username_clean ' . $this->db->sql_like_expression($keyword . $this->db->get_any_char()),
|
|
||||||
'ORDER_BY' => 'u.user_lastvisit DESC'
|
|
||||||
]);
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
class team extends user
|
class team extends base_user
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
class topic extends user
|
class topic extends base_user
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -13,71 +13,23 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
abstract class user implements source_interface
|
class user extends base_user
|
||||||
{
|
{
|
||||||
/** @var \phpbb\db\driver\driver_interface */
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/** @var \phpbb\user_loader */
|
|
||||||
protected $user_loader;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $phpbb_root_path;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $php_ext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user_loader $user_loader, $phpbb_root_path, $phpEx)
|
|
||||||
{
|
|
||||||
$this->db = $db;
|
|
||||||
$this->user_loader = $user_loader;
|
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
|
||||||
$this->php_ext = $phpEx;
|
|
||||||
|
|
||||||
if (!function_exists('phpbb_get_user_rank'))
|
|
||||||
{
|
|
||||||
include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a query based on user input
|
|
||||||
*
|
|
||||||
* @param string $keyword Search string
|
|
||||||
* @param int $topic_id Current topic ID
|
|
||||||
* @return string Query ready for execution
|
|
||||||
*/
|
|
||||||
abstract protected function query($keyword, $topic_id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get($keyword, $topic_id)
|
protected function query($keyword, $topic_id)
|
||||||
{
|
{
|
||||||
$keyword = utf8_clean_string($keyword);
|
$query = $this->db->sql_build_query('SELECT', [
|
||||||
$result = $this->db->sql_query_limit($this->query($keyword, $topic_id), 5);
|
'SELECT' => 'u.username, u.user_id',
|
||||||
|
'FROM' => [
|
||||||
$names = [];
|
USERS_TABLE => 'u',
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
],
|
||||||
{
|
'WHERE' => 'u.user_id <> ' . ANONYMOUS . '
|
||||||
$user_rank = $this->user_loader->get_rank($row['user_id'], true);
|
AND ' . $this->db->sql_in_set('u.user_type', [USER_NORMAL, USER_FOUNDER]) . '
|
||||||
$names['u' . $row['user_id']] = [
|
AND u.username_clean ' . $this->db->sql_like_expression($keyword . $this->db->get_any_char()),
|
||||||
'name' => $row['username'],
|
'ORDER_BY' => 'u.user_lastvisit DESC'
|
||||||
'param' => 'user_id',
|
]);
|
||||||
'id' => $row['user_id'],
|
return $query;
|
||||||
'avatar' => [
|
|
||||||
'type' => 'user',
|
|
||||||
'src' => $this->user_loader->get_avatar($row['user_id'], true),
|
|
||||||
],
|
|
||||||
'rank' => (isset($user_rank['rank_title'])) ? $user_rank['rank_title'] : '',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->sql_freeresult($result);
|
|
||||||
|
|
||||||
return $names;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,21 +13,8 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
class usergroup extends group
|
class usergroup extends base_group
|
||||||
{
|
{
|
||||||
/** @var \phpbb\user */
|
|
||||||
protected $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\group\helper $helper, \phpbb\user $user, $phpbb_root_path, $phpEx)
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
|
|
||||||
parent::__construct($db, $helper, $phpbb_root_path, $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user