/**
* 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;
}
/**