Merge branch '5.5' into 6.0
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 07:12:54 +0000 (09:12 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 07:12:54 +0000 (09:12 +0200)
1  2 
files/lib/data/conversation/Conversation.class.php
files/lib/data/conversation/ConversationEditor.class.php

index d0c8afc9193aede0bec34ed4f9a54c97045787bd,62a4fb7c84a2729a38793f6459a6cf8eec6a6a76..1f59d14487c41a6cd8816a9752d4c023c723963d
@@@ -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;
      }
  
      /**