[ticket/13713] Add two new sources: member and team

PHPBB3-13713
This commit is contained in:
lavigor 2018-06-09 18:56:26 +03:00 committed by Marc Alexander
parent c70ac7eb62
commit 52c2e11fdd
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
3 changed files with 93 additions and 0 deletions

View file

@ -27,6 +27,26 @@ services:
tags:
- { name: mention.source }
phpbb.mention.source.member:
class: phpbb\mention\source\member
arguments:
- '@dbal.conn'
- '@user_loader'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: mention.source }
phpbb.mention.source.team:
class: phpbb\mention\source\team
arguments:
- '@dbal.conn'
- '@user_loader'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: mention.source }
phpbb.mention.source.topic:
class: phpbb\mention\source\topic
arguments:

View file

@ -0,0 +1,35 @@
<?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;
}
}

View file

@ -0,0 +1,38 @@
<?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 team 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',
USER_GROUP_TABLE => 'ug',
TEAMPAGE_TABLE => 't',
],
'WHERE' => 'ug.group_id = t.group_id AND ug.user_id = u.user_id AND ug.user_pending = 0
AND 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;
}
}