/**
* Gets a list of all participants.
*
+ * @param boolean $excludeLeftParticipants
* @return array<integer>
*/
- public function getParticipantIDs() {
- $participantIDs = array();
+ public function getParticipantIDs($excludeLeftParticipants = false) {
+ $conditions = new PreparedStatementConditionBuilder();
+ $conditions->add("conversationID = ?", array($this->conversationID));
+ if ($excludeLeftParticipants) $conditions->add("hideConversation <> ?", array(2));
+
$sql = "SELECT participantID
FROM wcf".WCF_N."_conversation_to_user
- WHERE conversationID = ?";
+ ".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->conversationID));
+ $statement->execute($conditions->getParameters());
+ $participantIDs = array();
while ($row = $statement->fetchArray()) {
$participantIDs[] = $row['participantID'];
}
// fire notification event
if (!$conversation->isDraft) {
- $notificationRecipients = array_diff($conversation->getParticipantIDs(), array($message->userID)); // don't notify message author
+ $notificationRecipients = array_diff($conversation->getParticipantIDs(true), array($message->userID)); // don't notify message author
if (!empty($notificationRecipients)) {
UserNotificationHandler::getInstance()->fireEvent('conversationMessage', 'com.woltlab.wcf.conversation.message.notification', new ConversationMessageUserNotificationObject($message), $notificationRecipients);
}
AND conversationID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($message->userID, $conversation->conversationID));
+
+ // reset visibility if it was hidden but not left
+ $sql = "UPDATE wcf".WCF_N."_conversation_to_user
+ SET hideConversation = ?
+ WHERE conversationID = ?
+ AND hideConversation = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(
+ 0,
+ $conversation->conversationID,
+ 1
+ ));
}
// reset storage