mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-13 19:15:20 +02:00
[ticket/13713] Start working on User Mentions
PHPBB3-13713
This commit is contained in:
parent
726c90668e
commit
f757e65559
@ -15,6 +15,7 @@ imports:
|
|||||||
- { resource: services_help.yml }
|
- { resource: services_help.yml }
|
||||||
- { resource: services_http.yml }
|
- { resource: services_http.yml }
|
||||||
- { resource: services_language.yml }
|
- { resource: services_language.yml }
|
||||||
|
- { resource: services_mention.yml }
|
||||||
- { resource: services_migrator.yml }
|
- { resource: services_migrator.yml }
|
||||||
- { resource: services_mimetype_guesser.yml }
|
- { resource: services_mimetype_guesser.yml }
|
||||||
- { resource: services_module.yml }
|
- { resource: services_module.yml }
|
||||||
|
@ -24,6 +24,11 @@ phpbb_help_routing:
|
|||||||
resource: help.yml
|
resource: help.yml
|
||||||
prefix: /help
|
prefix: /help
|
||||||
|
|
||||||
|
phpbb_mention_controller:
|
||||||
|
path: /mention
|
||||||
|
methods: [GET, POST]
|
||||||
|
defaults: { _controller: phpbb.mention.controller:handle }
|
||||||
|
|
||||||
phpbb_report_routing:
|
phpbb_report_routing:
|
||||||
resource: report.yml
|
resource: report.yml
|
||||||
|
|
||||||
|
25
phpbb/config/default/container/services_mention.yml
Normal file
25
phpbb/config/default/container/services_mention.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
services:
|
||||||
|
# ----- Controller -----
|
||||||
|
phpbb.mention.controller:
|
||||||
|
class: phpbb\mention\controller\mention
|
||||||
|
arguments:
|
||||||
|
- '@request'
|
||||||
|
- '%core.root_path%'
|
||||||
|
- '%core.php_ext%'
|
||||||
|
|
||||||
|
# ----- Sources for mention -----
|
||||||
|
phpbb.mention.source_collection:
|
||||||
|
class: phpbb\di\service_collection
|
||||||
|
arguments:
|
||||||
|
- '@service_container'
|
||||||
|
tags:
|
||||||
|
- { name: service_collection, tag: mention.source }
|
||||||
|
|
||||||
|
phpbb.mention.source.topic:
|
||||||
|
class: phpbb\mention\source\topic
|
||||||
|
arguments:
|
||||||
|
- '@dbal.conn'
|
||||||
|
- '@request'
|
||||||
|
tags:
|
||||||
|
- { name: mention.source }
|
||||||
|
|
52
phpbb/phpbb/mention/controller/mention.php
Normal file
52
phpbb/phpbb/mention/controller/mention.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?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\controller;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
|
class mention
|
||||||
|
{
|
||||||
|
/** @var \phpbb\request\request_interface */
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $php_ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct(\phpbb\request\request_interface $request, $phpbb_root_path, $phpEx)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
$this->php_ext = $phpEx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if (!$this->request->is_ajax())
|
||||||
|
{
|
||||||
|
redirect(append_sid($this->phpbb_root_path . 'index.' . $this->php_ext));
|
||||||
|
}
|
||||||
|
|
||||||
|
$topic_id = $this->request->variable('topic_id', 0);
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return new JsonResponse();
|
||||||
|
}
|
||||||
|
}
|
53
phpbb/phpbb/mention/source/topic.php
Normal file
53
phpbb/phpbb/mention/source/topic.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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\method;
|
||||||
|
|
||||||
|
class topic
|
||||||
|
{
|
||||||
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
/** @var \phpbb\request\request_interface */
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\request\request_interface $request)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($keyword, $topic_id)
|
||||||
|
{
|
||||||
|
$query = $this->db->sql_build_query('SELECT', [
|
||||||
|
'SELECT' => 'u.username, u.user_id',
|
||||||
|
'FROM' => [
|
||||||
|
USERS_TABLE => 'u',
|
||||||
|
],
|
||||||
|
'LEFT_JOIN' => [
|
||||||
|
'FROM' => [POSTS_TABLE => 'p'],
|
||||||
|
'ON' => 'u.user_id = p.poster_id'
|
||||||
|
],
|
||||||
|
'WHERE' => 'p.topic_id = ' . $topic_id . ' 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' => 'p.post_time DESC'
|
||||||
|
]);
|
||||||
|
$res = $this->db->sql_query_limit($query, 5);
|
||||||
|
|
||||||
|
return $this->db->sql_fetchrowset($res);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user