1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-17 22:11:26 +02:00

[ticket/13713] Fix case for phpBB directory

PHPBB3-13713
This commit is contained in:
lavigor
2018-05-30 22:06:26 +03:00
committed by Marc Alexander
parent 6c42563b4d
commit eec7703d3b
12 changed files with 0 additions and 0 deletions

1
phpBB/assets/css/jquery.atwho.min.css vendored Normal file
View File

@@ -0,0 +1 @@
.atwho-view{position:absolute;top:0;left:0;display:none;margin-top:18px;background:#fff;color:#000;border:1px solid #DDD;border-radius:3px;box-shadow:0 0 5px rgba(0,0,0,.1);min-width:120px;z-index:11110!important}.atwho-view .atwho-header{padding:5px;margin:5px;cursor:pointer;border-bottom:solid 1px #eaeff1;color:#6f8092;font-size:11px;font-weight:700}.atwho-view .atwho-header .small{color:#6f8092;float:right;padding-top:2px;margin-right:-5px;font-size:12px;font-weight:400}.atwho-view .atwho-header:hover{cursor:default}.atwho-view .cur{background:#36F;color:#fff}.atwho-view .cur small{color:#fff}.atwho-view strong{color:#36F}.atwho-view .cur strong{color:#fff;font:700}.atwho-view ul{list-style:none;padding:0;margin:auto;max-height:200px;overflow-y:auto}.atwho-view ul li{display:block;padding:5px 10px;border-bottom:1px solid #DDD;cursor:pointer}.atwho-view small{font-size:smaller;color:#777;font-weight:400}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
services:
# ----- Controller -----
phpbb.mention.controller:
class: phpbb\mention\controller\mention
arguments:
- '@phpbb.mention.source_collection'
- '@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.friend:
class: phpbb\mention\source\friend
arguments:
- '@dbal.conn'
- '@user'
tags:
- { name: mention.source }
phpbb.mention.source.topic:
class: phpbb\mention\source\topic
arguments:
- '@dbal.conn'
tags:
- { name: mention.source }
phpbb.mention.source.usergroup:
class: phpbb\mention\source\usergroup
arguments:
- '@dbal.conn'
- '@group_helper'
- '@user'
tags:
- { name: mention.source }

View File

@@ -0,0 +1,62 @@
<?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\di\service_collection */
protected $mention_sources;
/** @var \phpbb\request\request_interface */
protected $request;
/** @var string */
protected $phpbb_root_path;
/** @var string */
protected $php_ext;
/**
* Constructor
*
*/
public function __construct($mention_sources, \phpbb\request\request_interface $request, $phpbb_root_path, $phpEx)
{
$this->mention_sources = $mention_sources;
$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));
}
$keyword = $this->request->variable('keyword', '', true);
$topic_id = $this->request->variable('topic_id', 0);
$names = [];
foreach ($this->mention_sources as $source)
{
$names = array_merge($names, $source->get($keyword, $topic_id));
}
return new JsonResponse(array_values($names));
}
}

View File

@@ -0,0 +1,55 @@
<?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 friend extends user
{
/** @var \phpbb\user */
protected $user;
/**
* Constructor
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user)
{
$this->user = $user;
parent::__construct($db);
}
/**
* {@inheritdoc}
*/
protected function query($keyword, $topic_id)
{
$query = $this->db->sql_build_query('SELECT', [
'SELECT' => 'u.username, u.user_id',
'FROM' => [
USERS_TABLE => 'u',
],
'LEFT_JOIN' => [
[
'FROM' => [ZEBRA_TABLE => 'z'],
'ON' => 'u.user_id = z.zebra_id'
]
],
'WHERE' => 'z.friend = 1 AND z.user_id = ' . (int) $this->user->data['user_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' => 'u.user_lastvisit DESC'
]);
return $query;
}
}

View File

@@ -0,0 +1,105 @@
<?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 group implements source_interface
{
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\group\helper */
protected $helper;
/**
* Constructor
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\group\helper $helper)
{
$this->db = $db;
$this->helper = $helper;
}
/**
* 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',
],
]);
$res = $this->db->sql_query($query);
$groups = [];
while ($row = $this->db->sql_fetchrow($res))
{
$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;
}
}
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
$res = $this->db->sql_query($this->query($keyword, $topic_id));
$group_ids = [];
while ($row = $this->db->sql_fetchrow($res))
{
$group_ids[] = $row['group_id'];
}
// 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)
{
$names['g' . $group_id] = [
'name' => $groups[$group_id]['group_name'],
'param' => 'group_id',
'id' => $group_id,
];
}
return $names;
}
}

View File

@@ -0,0 +1,27 @@
<?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;
interface source_interface
{
/**
* Searches database for names to mention
* and returns and array of found items
*
* @param string $keyword Search string
* @param int $topic_id Current topic ID
* @return array Array of names
*/
public function get($keyword, $topic_id);
}

View File

@@ -0,0 +1,41 @@
<?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 topic 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',
],
'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'
]);
return $query;
}
}

View File

@@ -0,0 +1,58 @@
<?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 user implements source_interface
{
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/**
* Constructor
*/
public function __construct(\phpbb\db\driver\driver_interface $db)
{
$this->db = $db;
}
/**
* 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);
$res = $this->db->sql_query_limit($this->query($keyword, $topic_id), 5);
$names = [];
while ($row = $this->db->sql_fetchrow($res))
{
$names['u' . $row['user_id']] = [
'name' => $row['username'],
'param' => 'user_id',
'id' => $row['user_id'],
];
}
return $names;
}
}

View File

@@ -0,0 +1,51 @@
<?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 usergroup extends group
{
/** @var \phpbb\user */
protected $user;
/**
* Constructor
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\group\helper $helper, \phpbb\user $user)
{
$this->user = $user;
parent::__construct($db, $helper);
}
/**
* {@inheritdoc}
*/
protected function query($keyword, $topic_id)
{
$query = $this->db->sql_build_query('SELECT', [
'SELECT' => 'g.group_id',
'FROM' => [
GROUPS_TABLE => 'g',
],
'LEFT_JOIN' => [
[
'FROM' => [USER_GROUP_TABLE => 'ug'],
'ON' => 'g.group_id = ug.group_id'
]
],
'WHERE' => 'ug.user_id = ' . (int) $this->user->data['user_id'],
]);
return $query;
}
}

View File

@@ -0,0 +1,69 @@
<?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\textformatter\s9e;
class mention_helper
{
/**
* @var string Base URL for a user profile link, uses {USER_ID} as placeholder
*/
protected $user_profile_url;
/**
* @var string Base URL for a group profile link, uses {GROUP_ID} as placeholder
*/
protected $group_profile_url;
/**
* Constructor
*
* @param string $root_path
* @param string $php_ext
*/
public function __construct($root_path, $php_ext)
{
$this->user_profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=viewprofile&u={USER_ID}', false);
$this->group_profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=group&g={GROUP_ID}', false);
}
/**
* Inject dynamic metadata into MENTION tags in given XML
*
* @param string $xml Original XML
* @return string Modified XML
*/
public function inject_metadata($xml)
{
$user_profile_url = $this->user_profile_url;
$group_profile_url = $this->group_profile_url;
return \s9e\TextFormatter\Utils::replaceAttributes(
$xml,
'MENTION',
function ($attributes) use ($user_profile_url, $group_profile_url)
{
if (isset($attributes['user_id']))
{
$attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $user_profile_url);
}
else if (isset($attributes['group_id']))
{
$attributes['profile_url'] = str_replace('{GROUP_ID}', $attributes['group_id'], $group_profile_url);
}
return $attributes;
}
);
}
}