* Returns a list of the usernames of all participants.
*
* @param boolean $excludeSelf
+ * @param boolean $leftByOwnChoice
* @return string[]
*/
- public function getParticipantNames($excludeSelf = false) {
+ public function getParticipantNames($excludeSelf = false, $leftByOwnChoice = false) {
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("conversationID = ?", [$this->conversationID]);
if ($excludeSelf) $conditions->add("conversation_to_user.participantID <> ?", [WCF::getUser()->userID]);
+ if ($leftByOwnChoice) $conditions->add("conversation_to_user.leftByOwnChoice = ?", [1]);
$sql = "SELECT user_table.username
FROM wcf".WCF_N."_conversation_to_user conversation_to_user
*/
public function getAddParticipantsForm() {
return [
- 'excludedSearchValues' => $this->conversation->getParticipantNames(),
+ 'excludedSearchValues' => $this->conversation->getParticipantNames(false, true),
'maxItems' => WCF::getSession()->getPermission('user.conversation.maxParticipants') - $this->conversation->participants,
'canAddGroupParticipants' => WCF::getSession()->getPermission('user.conversation.canAddGroupParticipants'),
'template' => WCF::getTPL()->fetch('conversationAddParticipants', 'wcf', ['conversation' => $this->conversation])
(conversationID, participantID, username, isInvisible, joinedAt)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY
- UPDATE hideConversation = 0";
+ UPDATE hideConversation = 0, leftAt = 0, leftByOwnChoice = 1";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($participantIDs as $userID) {
$sql = "UPDATE wcf".WCF_N."_conversation_to_user
SET leftAt = ?,
- lastMessageID = ?
+ lastMessageID = ?,
+ leftByOwnChoice = ?
WHERE conversationID = ?
AND participantID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute([
TIME_NOW,
$lastMessageID ?: null,
+ 0,
$this->conversationID,
$userID
]);
joinedAt INT(10) NOT NULL DEFAULT 0,
leftAt INT(10) NOT NULL DEFAULT 0,
lastMessageID INT(10) NULL,
+ leftByOwnChoice TINYINT(1) NOT NULL DEFAULT 1,
UNIQUE KEY (participantID, conversationID),
KEY (participantID, hideConversation)