[ticket/13713] Implement ranks

PHPBB3-13713
This commit is contained in:
lavigor 2018-06-01 18:46:39 +03:00 committed by Marc Alexander
parent a176be4c1d
commit f775c1e79d
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
8 changed files with 55 additions and 12 deletions

View file

@ -390,8 +390,9 @@ function getCaretPosition(txtarea) {
at: "@",
displayTpl: function(data) {
var avatar = (data.avatar.src) ? "<img src='" + data.avatar.src + "'>" :
"<span class='mention-avatar'><i class='fa fa-" + data.avatar.type + "'></i></span>";
return "<li>" + avatar + "<span>" + data.name + "</span></li>";
"<span class='mention-avatar'><i class='fa fa-" + data.avatar.type + "'></i></span>",
rank = (data.rank) ? "<span class='mention-rank'>" + data.rank + "</span>" : '';
return "<li>" + avatar + "<span>" + data.name + "</span>" + rank + "</li>";
},
insertTpl: "[mention ${param}=${id}]${name}[/mention]",
callbacks: {

View file

@ -22,6 +22,8 @@ services:
- '@dbal.conn'
- '@user_loader'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: mention.source }
@ -30,6 +32,8 @@ services:
arguments:
- '@dbal.conn'
- '@user_loader'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: mention.source }
@ -39,5 +43,7 @@ services:
- '@dbal.conn'
- '@group_helper'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: mention.source }

View file

@ -21,11 +21,11 @@ class friend extends user
/**
* Constructor
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user_loader $user_loader, \phpbb\user $user)
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user_loader $user_loader, \phpbb\user $user, $phpbb_root_path, $phpEx)
{
$this->user = $user;
parent::__construct($db, $user_loader);
parent::__construct($db, $user_loader, $phpbb_root_path, $phpEx);
}
/**

View file

@ -21,13 +21,26 @@ abstract class group implements source_interface
/** @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)
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);
}
}
/**
@ -93,6 +106,7 @@ abstract class group implements source_interface
$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',
@ -101,6 +115,7 @@ abstract class group implements source_interface
'type' => 'group',
'src' => phpbb_get_group_avatar($groups[$group_id]),
],
'rank' => $group_rank['title'],
];
}

View file

@ -21,13 +21,26 @@ abstract class user implements source_interface
/** @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)
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);
}
}
/**
@ -50,6 +63,7 @@ abstract class user implements source_interface
$names = [];
while ($row = $this->db->sql_fetchrow($res))
{
$user_rank = $this->user_loader->get_rank($row['user_id'], true);
$names['u' . $row['user_id']] = [
'name' => $row['username'],
'param' => 'user_id',
@ -58,6 +72,7 @@ abstract class user implements source_interface
'type' => 'user',
'src' => $this->user_loader->get_avatar($row['user_id'], true),
],
'rank' => (isset($user_rank['rank_title'])) ? $user_rank['rank_title'] : '',
];
}

View file

@ -21,11 +21,11 @@ class usergroup extends group
/**
* Constructor
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\group\helper $helper, \phpbb\user $user)
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);
parent::__construct($db, $helper, $phpbb_root_path, $phpEx);
}
/**

View file

@ -937,7 +937,7 @@
}
.mention-avatar {
right: 8px;
right: 7px;
left: auto;
}

View file

@ -287,7 +287,7 @@ fieldset.submit-buttons input {
/* Mention dropdown */
.atwho-container .atwho-view {
font-size: 12px;
min-width: 300px;
min-width: 260px;
}
.atwho-container .atwho-view ul li {
@ -304,11 +304,17 @@ fieldset.submit-buttons input {
border-radius: 100%;
position: absolute;
top: 50%;
left: 8px;
left: 7px;
display: inline-block;
width: 30px;
height: 30px;
margin-top: -15px;
margin-top: -16px;
}
.mention-rank {
font-size: 10px;
display: block;
margin-top: 2px;
}
/* Input field styles