From e34de96b5d8c57b52f7de364ac200664bac80ed5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 13 Feb 2023 19:53:33 +0100 Subject: [PATCH] Add include to random member module --- config/modules.yml | 2 ++ modules/random_member.php | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/config/modules.yml b/config/modules.yml index a219da77..c9e14e6c 100644 --- a/config/modules.yml +++ b/config/modules.yml @@ -223,6 +223,8 @@ services: - '@dbal.conn' - '@template' - '@user' + - '%core.root_path%' + - '%core.php_ext%' tags: - { name: board3.portal.module } diff --git a/modules/random_member.php b/modules/random_member.php index 120540b1..6d421a40 100644 --- a/modules/random_member.php +++ b/modules/random_member.php @@ -56,18 +56,28 @@ class random_member extends module_base /** @var \phpbb\user */ protected $user; + /** @var string PHP file extension */ + protected $php_ext; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + /** * Construct a random member object * * @param \phpbb\db\driver $db phpBB database system * @param \phpbb\template $template phpBB template * @param \phpbb\user $user phpBB user object + * @param string $phpbb_root_path phpBB root path + * @param string $phpEx PHP file extension */ - public function __construct($db, $template, $user) + public function __construct($db, $template, $user, $phpbb_root_path, $phpEx) { $this->db = $db; $this->template = $template; $this->user = $user; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; } /** @@ -106,8 +116,12 @@ class random_member extends module_base $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); - $avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($row, 'user'), 'USER_AVATAR'); + if (!function_exists('phpbb_get_user_rank')) + { + include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); + } + $avatar_img = phpbb_get_user_avatar($row); $rank_data = phpbb_get_user_rank($row, $row['user_posts']); $username = $row['username'];