From 05414474ff273234d6e1f86a84bdd559d313b4a6 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 24 Jul 2025 14:10:22 +0200 Subject: [PATCH] Necessary adjustments for new member list --- .../com.woltlab.wcf.conversation.php | 55 +++++++++++++------ templateListener.xml | 11 ++-- .../userCard_buttons_conversationButton.tpl | 3 - 3 files changed, 42 insertions(+), 27 deletions(-) delete mode 100644 templates/userCard_buttons_conversationButton.tpl diff --git a/files/lib/bootstrap/com.woltlab.wcf.conversation.php b/files/lib/bootstrap/com.woltlab.wcf.conversation.php index ec7cb573..0b6adc0c 100644 --- a/files/lib/bootstrap/com.woltlab.wcf.conversation.php +++ b/files/lib/bootstrap/com.woltlab.wcf.conversation.php @@ -1,10 +1,11 @@ register( - \wcf\event\user\profile\UserProfileHeaderInteractionOptionCollecting::class, - static function (\wcf\event\user\profile\UserProfileHeaderInteractionOptionCollecting $event) { - if ( - MODULE_CONVERSATION - && WCF::getUser()->userID - && WCF::getSession()->getPermission('user.conversation.canUseConversation') - && WCF::getSession()->getPermission('user.conversation.canStartConversation') - && WCF::getUser()->userID != $event->user->userID - ) { - $event->register(UserProfileHeaderViewInteractionOption::forLink( - WCF::getLanguage()->get('wcf.conversation.button.add'), - LinkHandler::getInstance()->getControllerLink(ConversationAddForm::class, ['userID' => $event->user->userID]) - )); + if ( + \MODULE_CONVERSATION + && WCF::getUser()->userID + && WCF::getSession()->getPermission('user.conversation.canUseConversation') + && WCF::getSession()->getPermission('user.conversation.canStartConversation') + ) { + $eventHandler->register( + \wcf\event\interaction\user\UserProfileInteractionCollecting::class, + static function (\wcf\event\interaction\user\UserProfileInteractionCollecting $event) { + $event->provider->addInteraction( + new class( + 'start-conversation', + isAvailableCallback: static fn(UserProfile $user) => WCF::getUser()->userID !== $user->userID + ) extends \wcf\system\interaction\AbstractInteraction { + #[\Override] + public function render(DatabaseObject $object): string + { + \assert($object instanceof UserProfile); + + return \sprintf( + '%s', + StringUtil::encodeHTML( + LinkHandler::getInstance()->getControllerLink( + \wcf\form\ConversationAddForm::class, + ['userID' => $object->userID] + ) + ), + WCF::getLanguage()->get('wcf.conversation.button.add') + ); + } + } + ); } - } - ); + ); + } $eventHandler->register( \wcf\event\endpoint\ControllerCollecting::class, diff --git a/templateListener.xml b/templateListener.xml index a32f701d..e81a0ca4 100644 --- a/templateListener.xml +++ b/templateListener.xml @@ -13,12 +13,6 @@ buttons - - user - userCard - buttons - - user @@ -52,5 +46,10 @@ menuInteraction + + user + userCard + buttons + diff --git a/templates/userCard_buttons_conversationButton.tpl b/templates/userCard_buttons_conversationButton.tpl deleted file mode 100644 index b23fcc60..00000000 --- a/templates/userCard_buttons_conversationButton.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{if MODULE_CONVERSATION && $__wcf->user->userID && $__wcf->session->getPermission('user.conversation.canUseConversation') && $__wcf->session->getPermission('user.conversation.canStartConversation') && $user->userID != $__wcf->user->userID} - {icon name='comments' type='solid' size=24} -{/if}