mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/13713] Create abstract parent service for user source
PHPBB3-13713
This commit is contained in:
parent
52c2e11fdd
commit
52fac451a3
3 changed files with 25 additions and 32 deletions
|
@ -18,44 +18,37 @@ services:
|
||||||
|
|
||||||
phpbb.mention.source.friend:
|
phpbb.mention.source.friend:
|
||||||
class: phpbb\mention\source\friend
|
class: phpbb\mention\source\friend
|
||||||
arguments:
|
parent: phpbb.mention.source.user
|
||||||
- '@dbal.conn'
|
calls:
|
||||||
- '@user_loader'
|
- [set_user, ['@user']]
|
||||||
- '@user'
|
|
||||||
- '%core.root_path%'
|
|
||||||
- '%core.php_ext%'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: mention.source }
|
- { name: mention.source }
|
||||||
|
|
||||||
phpbb.mention.source.member:
|
phpbb.mention.source.member:
|
||||||
class: phpbb\mention\source\member
|
class: phpbb\mention\source\member
|
||||||
arguments:
|
parent: phpbb.mention.source.user
|
||||||
- '@dbal.conn'
|
|
||||||
- '@user_loader'
|
|
||||||
- '%core.root_path%'
|
|
||||||
- '%core.php_ext%'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: mention.source }
|
- { name: mention.source }
|
||||||
|
|
||||||
phpbb.mention.source.team:
|
phpbb.mention.source.team:
|
||||||
class: phpbb\mention\source\team
|
class: phpbb\mention\source\team
|
||||||
arguments:
|
parent: phpbb.mention.source.user
|
||||||
- '@dbal.conn'
|
|
||||||
- '@user_loader'
|
|
||||||
- '%core.root_path%'
|
|
||||||
- '%core.php_ext%'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: mention.source }
|
- { name: mention.source }
|
||||||
|
|
||||||
phpbb.mention.source.topic:
|
phpbb.mention.source.topic:
|
||||||
class: phpbb\mention\source\topic
|
class: phpbb\mention\source\topic
|
||||||
|
parent: phpbb.mention.source.user
|
||||||
|
tags:
|
||||||
|
- { name: mention.source }
|
||||||
|
|
||||||
|
phpbb.mention.source.user:
|
||||||
|
abstract: true
|
||||||
arguments:
|
arguments:
|
||||||
- '@dbal.conn'
|
- '@dbal.conn'
|
||||||
- '@user_loader'
|
- '@user_loader'
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '%core.php_ext%'
|
- '%core.php_ext%'
|
||||||
tags:
|
|
||||||
- { name: mention.source }
|
|
||||||
|
|
||||||
phpbb.mention.source.usergroup:
|
phpbb.mention.source.usergroup:
|
||||||
class: phpbb\mention\source\usergroup
|
class: phpbb\mention\source\usergroup
|
||||||
|
|
|
@ -19,13 +19,13 @@ class friend extends user
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Set the user service used to retrieve current user ID
|
||||||
|
*
|
||||||
|
* @param \phpbb\user $user
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user_loader $user_loader, \phpbb\user $user, $phpbb_root_path, $phpEx)
|
public function set_user(\phpbb\user $user)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
parent::__construct($db, $user_loader, $phpbb_root_path, $phpEx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,7 @@ class mention_helper
|
||||||
/**
|
/**
|
||||||
* @var array Array of users' and groups' colors for each cached ID
|
* @var array Array of users' and groups' colors for each cached ID
|
||||||
*/
|
*/
|
||||||
protected $cached_colors = [];
|
protected $cached_colours = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -59,9 +59,9 @@ class mention_helper
|
||||||
*/
|
*/
|
||||||
protected function get_colors($user_ids, $group_ids)
|
protected function get_colors($user_ids, $group_ids)
|
||||||
{
|
{
|
||||||
$this->cached_colors = [];
|
$this->cached_colours = [];
|
||||||
$this->cached_colors['users'] = [];
|
$this->cached_colours['users'] = [];
|
||||||
$this->cached_colors['groups'] = [];
|
$this->cached_colours['groups'] = [];
|
||||||
|
|
||||||
if (!empty($user_ids))
|
if (!empty($user_ids))
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ class mention_helper
|
||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$this->cached_colors['users'][$row['user_id']] = $row['user_colour'];
|
$this->cached_colours['users'][$row['user_id']] = $row['user_colour'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
@ -97,7 +97,7 @@ class mention_helper
|
||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$this->cached_colors['groups'][$row['group_id']] = $row['group_colour'];
|
$this->cached_colours['groups'][$row['group_id']] = $row['group_colour'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
@ -130,18 +130,18 @@ class mention_helper
|
||||||
{
|
{
|
||||||
$attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $user_profile_url);
|
$attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $user_profile_url);
|
||||||
|
|
||||||
if (!empty($this->cached_colors['users'][$attributes['user_id']]))
|
if (!empty($this->cached_colours['users'][$attributes['user_id']]))
|
||||||
{
|
{
|
||||||
$attributes['color'] = $this->cached_colors['users'][$attributes['user_id']];
|
$attributes['color'] = $this->cached_colours['users'][$attributes['user_id']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isset($attributes['group_id']))
|
else if (isset($attributes['group_id']))
|
||||||
{
|
{
|
||||||
$attributes['profile_url'] = str_replace('{GROUP_ID}', $attributes['group_id'], $group_profile_url);
|
$attributes['profile_url'] = str_replace('{GROUP_ID}', $attributes['group_id'], $group_profile_url);
|
||||||
|
|
||||||
if (!empty($this->cached_colors['groups'][$attributes['group_id']]))
|
if (!empty($this->cached_colours['groups'][$attributes['group_id']]))
|
||||||
{
|
{
|
||||||
$attributes['color'] = $this->cached_colors['groups'][$attributes['group_id']];
|
$attributes['color'] = $this->cached_colours['groups'][$attributes['group_id']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue