Skip to content

Commit 0541447

Browse files
committed
Necessary adjustments for new member list
1 parent 23b8531 commit 0541447

File tree

3 files changed

+42
-27
lines changed

3 files changed

+42
-27
lines changed

files/lib/bootstrap/com.woltlab.wcf.conversation.php

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

3-
use wcf\form\ConversationAddForm;
3+
use wcf\data\DatabaseObject;
4+
use wcf\data\user\UserProfile;
45
use wcf\system\event\EventHandler;
56
use wcf\system\request\LinkHandler;
6-
use wcf\system\view\user\profile\UserProfileHeaderViewInteractionOption;
77
use wcf\system\WCF;
8+
use wcf\util\StringUtil;
89

910
return static function (): void {
1011
$eventHandler = EventHandler::getInstance();
@@ -18,23 +19,41 @@ static function (\wcf\event\worker\RebuildWorkerCollecting $event) {
1819
}
1920
);
2021

21-
$eventHandler->register(
22-
\wcf\event\user\profile\UserProfileHeaderInteractionOptionCollecting::class,
23-
static function (\wcf\event\user\profile\UserProfileHeaderInteractionOptionCollecting $event) {
24-
if (
25-
MODULE_CONVERSATION
26-
&& WCF::getUser()->userID
27-
&& WCF::getSession()->getPermission('user.conversation.canUseConversation')
28-
&& WCF::getSession()->getPermission('user.conversation.canStartConversation')
29-
&& WCF::getUser()->userID != $event->user->userID
30-
) {
31-
$event->register(UserProfileHeaderViewInteractionOption::forLink(
32-
WCF::getLanguage()->get('wcf.conversation.button.add'),
33-
LinkHandler::getInstance()->getControllerLink(ConversationAddForm::class, ['userID' => $event->user->userID])
34-
));
22+
if (
23+
\MODULE_CONVERSATION
24+
&& WCF::getUser()->userID
25+
&& WCF::getSession()->getPermission('user.conversation.canUseConversation')
26+
&& WCF::getSession()->getPermission('user.conversation.canStartConversation')
27+
) {
28+
$eventHandler->register(
29+
\wcf\event\interaction\user\UserProfileInteractionCollecting::class,
30+
static function (\wcf\event\interaction\user\UserProfileInteractionCollecting $event) {
31+
$event->provider->addInteraction(
32+
new class(
33+
'start-conversation',
34+
isAvailableCallback: static fn(UserProfile $user) => WCF::getUser()->userID !== $user->userID
35+
) extends \wcf\system\interaction\AbstractInteraction {
36+
#[\Override]
37+
public function render(DatabaseObject $object): string
38+
{
39+
\assert($object instanceof UserProfile);
40+
41+
return \sprintf(
42+
'<a href="%s">%s</a>',
43+
StringUtil::encodeHTML(
44+
LinkHandler::getInstance()->getControllerLink(
45+
\wcf\form\ConversationAddForm::class,
46+
['userID' => $object->userID]
47+
)
48+
),
49+
WCF::getLanguage()->get('wcf.conversation.button.add')
50+
);
51+
}
52+
}
53+
);
3554
}
36-
}
37-
);
55+
);
56+
}
3857

3958
$eventHandler->register(
4059
\wcf\event\endpoint\ControllerCollecting::class,

templateListener.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
<eventname>buttons</eventname>
1414
<templatecode><![CDATA[{include file='__userInformationStartConversation'}]]></templatecode>
1515
</templatelistener>
16-
<templatelistener name="userCardConversationButton">
17-
<environment>user</environment>
18-
<templatename>userCard</templatename>
19-
<eventname>buttons</eventname>
20-
<templatecode><![CDATA[{include file='userCard_buttons_conversationButton'}]]></templatecode>
21-
</templatelistener>
2216

2317
<templatelistener name="searchAreaConversationSettings">
2418
<environment>user</environment>
@@ -52,5 +46,10 @@
5246
<eventname>menuInteraction</eventname>
5347
<templatecode><![CDATA[{include file='__userProfileStartConversation'}]]></templatecode>
5448
</templatelistener>
49+
<templatelistener name="userCardConversationButton">
50+
<environment>user</environment>
51+
<templatename>userCard</templatename>
52+
<eventname>buttons</eventname>
53+
</templatelistener>
5554
</delete>
5655
</data>

templates/userCard_buttons_conversationButton.tpl

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)