From 5715774e734f7fe0987e46155ea2e3b8964afc3c Mon Sep 17 00:00:00 2001 From: Partydragen Date: Mon, 29 Jul 2024 18:14:39 +0200 Subject: [PATCH] Check if members module is enabled (#3532) --- modules/Forum/module.php | 50 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/modules/Forum/module.php b/modules/Forum/module.php index 4ea279ffc6..c899a566ab 100644 --- a/modules/Forum/module.php +++ b/modules/Forum/module.php @@ -143,30 +143,32 @@ public function __construct(Language $language, Language $forum_language, Pages EventHandler::registerListener('renderPostEdit', 'ContentHook::purify'); EventHandler::registerListener('renderPostEdit', 'ContentHook::replaceAnchors', 15); - MemberListManager::getInstance()->registerListProvider(new MostPostsMemberListProvider($forum_language)); - MemberListManager::getInstance()->registerListProvider(new HighestForumReactionScoresMemberListProvider($forum_language)); - - MemberListManager::getInstance()->registerMemberMetadataProvider(function (User $member) use ($forum_language) { - return [ - $forum_language->get('forum', 'posts_title') => - DB::getInstance()->query( - 'SELECT COUNT(post_content) AS `count` FROM nl2_posts WHERE post_creator = ?', - [$member->data()->id] - )->first()->count, - ]; - }); - - MemberListManager::getInstance()->registerMemberMetadataProvider(function (User $member) use ($forum_language) { - return [ - $forum_language->get('forum', 'reaction_score') => - DB::getInstance()->query( - 'SELECT COUNT(fr.user_received) AS `count` FROM nl2_forums_reactions fr JOIN nl2_reactions r ON r.id = fr.reaction_id WHERE r.type = 2 AND fr.user_received = ?', - [$member->data()->id] - )->first()->count, - ]; - }); - - ReactionContextsManager::getInstance()->provideContext(new ForumPostReactionContext($forum_language)); + if (Util::isModuleEnabled('Members')) { + MemberListManager::getInstance()->registerListProvider(new MostPostsMemberListProvider($forum_language)); + MemberListManager::getInstance()->registerListProvider(new HighestForumReactionScoresMemberListProvider($forum_language)); + + MemberListManager::getInstance()->registerMemberMetadataProvider(function (User $member) use ($forum_language) { + return [ + $forum_language->get('forum', 'posts_title') => + DB::getInstance()->query( + 'SELECT COUNT(post_content) AS `count` FROM nl2_posts WHERE post_creator = ?', + [$member->data()->id] + )->first()->count, + ]; + }); + + MemberListManager::getInstance()->registerMemberMetadataProvider(function (User $member) use ($forum_language) { + return [ + $forum_language->get('forum', 'reaction_score') => + DB::getInstance()->query( + 'SELECT COUNT(fr.user_received) AS `count` FROM nl2_forums_reactions fr JOIN nl2_reactions r ON r.id = fr.reaction_id WHERE r.type = 2 AND fr.user_received = ?', + [$member->data()->id] + )->first()->count, + ]; + }); + + ReactionContextsManager::getInstance()->provideContext(new ForumPostReactionContext($forum_language)); + } } public function onInstall() {