1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Properly delete position when a room is deleted.

This commit is contained in:
Tim Düsterhus 2012-04-16 22:12:44 +02:00
parent c1b2fe0dfd
commit 2cc70345ce

View File

@ -30,6 +30,28 @@ public static function deleteAll(array $objectIDs = array()) {
\wcf\system\language\I18nHandler::getInstance()->remove('wcf.chat.room.topic'.$objectID, $packageID);
}
$sql = "SELECT
position
FROM
wcf".WCF_N."_chat_room
WHERE
roomID = ?
FOR UPDATE";
$select = WCF::getDB()->prepareStatement($sql);
$sql = "UPDATE
wcf".WCF_N."_chat_room
SET
position = position - 1
WHERE
position > ?";
$update = WCF::getDB()->prepareStatement($sql);
foreach ($objectIDs as $objectID) {
$select->execute(array($objectID));
$update->execute(array($select->fetchColumn()));
}
// The transaction is being committed in parent::deleteAll()
// The beginTransaction() call in there is simply ignored.
return parent::deleteAll($objectIDs);