From: Alexander Ebert Date: Mon, 8 Jul 2013 11:18:20 +0000 (+0200) Subject: Added username to wcf1_conversation_to_user X-Git-Tag: 2.0.0_Beta_3~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a9bfc5bd2061c3f7005c7c78175cce252d9fdf2b;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.conversation.git Added username to wcf1_conversation_to_user --- diff --git a/files/lib/data/conversation/ConversationEditor.class.php b/files/lib/data/conversation/ConversationEditor.class.php index 4f96ad1..a7e3da7 100644 --- a/files/lib/data/conversation/ConversationEditor.class.php +++ b/files/lib/data/conversation/ConversationEditor.class.php @@ -1,5 +1,7 @@ $invisibleParticipantIDs */ public function updateParticipants(array $participantIDs, array $invisibleParticipantIDs = array()) { + $usernames = array(); + if (!empty($participantIDs) || !empty($invisibleParticipantIDs)) { + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("userID IN (?)", array(array_merge($participantIDs, $invisibleParticipantIDs))); + + $sql = "SELECT userID, username + FROM wcf".WCF_N."_user + ".$conditions; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $usernames[$row['userID']] = $row['username']; + } + } + if (!empty($participantIDs)) { WCF::getDB()->beginTransaction(); $sql = "INSERT INTO wcf".WCF_N."_conversation_to_user - (conversationID, participantID, isInvisible) - VALUES (?, ?, ?) + (conversationID, participantID, username, isInvisible) + VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE hideConversation = 0"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($participantIDs as $userID) { - $statement->execute(array($this->conversationID, $userID, 0)); + $statement->execute(array( + $this->conversationID, + $userID, + $usernames[$userID], + 0 + )); } WCF::getDB()->commitTransaction(); } @@ -73,12 +95,17 @@ class ConversationEditor extends DatabaseObjectEditor { if (!empty($invisibleParticipantIDs)) { WCF::getDB()->beginTransaction(); $sql = "INSERT INTO wcf".WCF_N."_conversation_to_user - (conversationID, participantID, isInvisible) - VALUES (?, ?, ?)"; + (conversationID, participantID, username, isInvisible) + VALUES (?, ?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($invisibleParticipantIDs as $userID) { - $statement->execute(array($this->conversationID, $userID, 1)); + $statement->execute(array( + $this->conversationID, + $userID, + $usernames[$userID], + 1 + )); } WCF::getDB()->commitTransaction(); } @@ -114,14 +141,12 @@ class ConversationEditor extends DatabaseObjectEditor { */ public function updateParticipantSummary() { $users = array(); - $sql = "SELECT conversation_to_user.participantID AS userID, conversation_to_user.hideConversation, user_table.username - FROM wcf".WCF_N."_conversation_to_user conversation_to_user - LEFT JOIN wcf".WCF_N."_user user_table - ON (user_table.userID = conversation_to_user.participantID) - WHERE conversation_to_user.conversationID = ? - AND conversation_to_user.participantID <> ? - AND conversation_to_user.isInvisible = 0 - ORDER BY user_table.username"; + $sql = "SELECT participantID AS userID, hideConversation, username + FROM wcf".WCF_N."_conversation_to_user + WHERE conversationID = ? + participantID <> ? + isInvisible = 0 + ORDER BY username"; $statement = WCF::getDB()->prepareStatement($sql, 5); $statement->execute(array($this->conversationID, $this->userID)); while ($row = $statement->fetchArray()) { diff --git a/install.sql b/install.sql index 163265c..eadb1a2 100644 --- a/install.sql +++ b/install.sql @@ -25,6 +25,7 @@ DROP TABLE IF EXISTS wcf1_conversation_to_user; CREATE TABLE wcf1_conversation_to_user ( conversationID INT(10) NOT NULL, participantID INT(10), + username VARCHAR(255) NOT NULL DEFAULT '', hideConversation TINYINT(1) NOT NULL DEFAULT 0, isInvisible TINYINT(1) NOT NULL DEFAULT 0, lastVisitTime INT(10) NOT NULL DEFAULT 0,