1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-13 11:06:03 +02:00

[ticket/13713] Start working on User Mentions

PHPBB3-13713
This commit is contained in:
lavigor 2018-05-17 04:50:37 +03:00 committed by Marc Alexander
parent 726c90668e
commit f757e65559
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
5 changed files with 136 additions and 0 deletions

View File

@ -15,6 +15,7 @@ imports:
- { resource: services_help.yml }
- { resource: services_http.yml }
- { resource: services_language.yml }
- { resource: services_mention.yml }
- { resource: services_migrator.yml }
- { resource: services_mimetype_guesser.yml }
- { resource: services_module.yml }

View File

@ -24,6 +24,11 @@ phpbb_help_routing:
resource: help.yml
prefix: /help
phpbb_mention_controller:
path: /mention
methods: [GET, POST]
defaults: { _controller: phpbb.mention.controller:handle }
phpbb_report_routing:
resource: report.yml

View 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 }

View 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();
}
}

View 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);
}
}