/**
* conversation id
- * @var integer
+ * @var int
*/
public $conversationID = 0;
/**
* message id
- * @var integer
+ * @var int
*/
public $messageID = 0;
$userIDs[] = $message->userID;
}
}
+ $userIDs = \array_unique($userIDs);
// fetch special trophies
if (MODULE_TROPHY) {
if (!empty($userIDs)) {
- UserProfile::prepareSpecialTrophies(\array_unique($userIDs));
+ UserProfile::prepareSpecialTrophies($userIDs);
}
}
if ($count > 1) {
$this->objectList->seek($count - 1);
if ($this->objectList->current()->time < $this->conversation->lastPostTime) {
- $sql = "SELECT time
- FROM wcf" . WCF_N . "_conversation_message
- WHERE conversationID = ?
- AND time > ?
- ORDER BY time";
+ $sql = "SELECT time
+ FROM wcf" . WCF_N . "_conversation_message
+ WHERE conversationID = ?
+ AND time > ?
+ ORDER BY time";
$statement = WCF::getDB()->prepareStatement($sql, 1);
$statement->execute([$this->conversationID, $this->objectList->current()->time]);
$endTime = $statement->fetchSingleColumn() - 1;
}
$this->objectList->rewind();
- // get invisible participants
- $invisibleParticipantIDs = [];
- if (WCF::getUser()->userID != $this->conversation->userID) {
- foreach ($this->participantList as $participant) {
- if ($participant->isInvisible) {
- $invisibleParticipantIDs[] = $participant->userID;
- }
+ // get visible participants
+ $visibleParticipantIDs = [];
+ foreach ($this->participantList as $participant) {
+ /** @noinspection PhpUndefinedFieldInspection */
+ if (!$participant->isInvisible || WCF::getUser()->userID == $this->conversation->userID) {
+ $visibleParticipantIDs[] = $participant->userID;
}
}
+ // Drafts do not store their participants in conversation_to_user.
+ if ($this->conversation->isDraft) {
+ $visibleParticipantIDs[] = $this->conversation->userID;
+ }
+
// load modification log entries
$this->modificationLogList = new ConversationLogModificationLogList($this->conversation->conversationID);
$this->modificationLogList->getConditionBuilder()
->add("modification_log.time BETWEEN ? AND ?", [$startTime, $endTime]);
-
- if (!empty($invisibleParticipantIDs)) {
- $this->modificationLogList->getConditionBuilder()->add(
- "(modification_log.action <> ? OR modification_log.userID NOT IN (?))",
- ['leave', $invisibleParticipantIDs]
- );
- }
+ $this->modificationLogList->getConditionBuilder()->add(
+ "modification_log.userID IN (?)",
+ [$visibleParticipantIDs]
+ );
$this->modificationLogList->readObjects();
}
$conditionBuilder = clone $this->objectList->getConditionBuilder();
$conditionBuilder->add('time ' . ($this->sortOrder == 'ASC' ? '<=' : '>=') . ' ?', [$this->message->time]);
- $sql = "SELECT COUNT(*) AS messages
- FROM wcf" . WCF_N . "_conversation_message conversation_message
- " . $conditionBuilder;
+ $sql = "SELECT COUNT(*) AS messages
+ FROM wcf" . WCF_N . "_conversation_message conversation_message
+ " . $conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
$row = $statement->fetchArray();
*/
protected function goToLastPost()
{
- $sql = "SELECT conversation_message.messageID
- FROM wcf" . WCF_N . "_conversation_message conversation_message
- " . $this->objectList->getConditionBuilder() . "
- ORDER BY time " . ($this->sortOrder == 'ASC' ? 'DESC' : 'ASC');
+ $sql = "SELECT conversation_message.messageID
+ FROM wcf" . WCF_N . "_conversation_message conversation_message
+ " . $this->objectList->getConditionBuilder() . "
+ ORDER BY time " . ($this->sortOrder == 'ASC' ? 'DESC' : 'ASC');
$statement = WCF::getDB()->prepareStatement($sql, 1);
$statement->execute($this->objectList->getConditionBuilder()->getParameters());
$row = $statement->fetchArray();
$conditionBuilder = clone $this->objectList->getConditionBuilder();
$conditionBuilder->add('time > ?', [$this->conversation->lastVisitTime]);
- $sql = "SELECT conversation_message.messageID
- FROM wcf" . WCF_N . "_conversation_message conversation_message
- " . $conditionBuilder . "
- ORDER BY time ASC";
+ $sql = "SELECT conversation_message.messageID
+ FROM wcf" . WCF_N . "_conversation_message conversation_message
+ " . $conditionBuilder . "
+ ORDER BY time ASC";
$statement = WCF::getDB()->prepareStatement($sql, 1);
$statement->execute($conditionBuilder->getParameters());
$row = $statement->fetchArray();