From: Tim Düsterhus Date: Wed, 27 Sep 2023 07:12:54 +0000 (+0200) Subject: Merge branch '5.5' into 6.0 X-Git-Tag: 6.0.0_RC_2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a3c8ddeb6091c05e72a5bddb148360119074519f;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.conversation.git Merge branch '5.5' into 6.0 --- a3c8ddeb6091c05e72a5bddb148360119074519f diff --cc files/lib/data/conversation/Conversation.class.php index d0c8afc,62a4fb7..1f59d14 --- a/files/lib/data/conversation/Conversation.class.php +++ b/files/lib/data/conversation/Conversation.class.php @@@ -392,42 -406,21 +392,19 @@@ class Conversation extends DatabaseObje /** * Returns false if the active user is the last participant of this conversation. - * - * @return bool */ - public function hasOtherParticipants() + public function hasOtherParticipants(): bool { - if ($this->userID == WCF::getUser()->userID) { - // author - if ($this->participants == 0) { - return false; - } - - return true; - } else { - if ($this->participants > 1) { - return true; - } - if ($this->isInvisible && $this->participants > 0) { - return true; - } - - if ($this->userID) { - // check if author has left the conversation - $sql = "SELECT hideConversation - FROM wcf" . WCF_N . "_conversation_to_user - WHERE conversationID = ? - AND participantID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([$this->conversationID, $this->userID]); - $row = $statement->fetchArray(); - if ($row !== false) { - if ($row['hideConversation'] != self::STATE_LEFT) { - return true; - } - } - } - - return false; - } + $participantList = new ConversationParticipantList( + $this->conversationID, + WCF::getUser()->userID, + $this->userID == WCF::getUser()->userID + ); + $participantList->getConditionBuilder()->add('conversation_to_user.hideConversation <> ?', [self::STATE_LEFT]); + $participantList->getConditionBuilder()->add('conversation_to_user.leftAt = ?', [0]); + $participantList->readObjectIDs(); + + return \count($participantList->getObjectIDs()) > 1; } /**