From d64f11b3157c504b5a814c064e32869ce3b5c54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 24 May 2013 00:08:33 +0200 Subject: [PATCH] Rename position to showOrder --- file/lib/acp/page/RoomListPage.class.php | 2 +- file/lib/data/room/RoomAction.class.php | 6 +++--- file/lib/data/room/RoomEditor.class.php | 6 +++--- .../system/cache/builder/RoomCacheBuilder.class.php | 2 +- install.sql | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/file/lib/acp/page/RoomListPage.class.php b/file/lib/acp/page/RoomListPage.class.php index 7bb93b2..105123b 100644 --- a/file/lib/acp/page/RoomListPage.class.php +++ b/file/lib/acp/page/RoomListPage.class.php @@ -38,7 +38,7 @@ public function readData() { parent::readData(); $this->objects = new \chat\data\room\RoomList(); - $this->objects->sqlOrderBy = 'position ASC'; + $this->objects->sqlOrderBy = 'showOrder ASC'; $this->objects->readObjects(); } diff --git a/file/lib/data/room/RoomAction.class.php b/file/lib/data/room/RoomAction.class.php index fc9ee46..28f5143 100644 --- a/file/lib/data/room/RoomAction.class.php +++ b/file/lib/data/room/RoomAction.class.php @@ -41,14 +41,14 @@ public function create() { $room = parent::create(); WCF::getDB()->beginTransaction(); - $sql = "SELECT MAX(position) + $sql = "SELECT MAX(showOrder) FROM ".call_user_func(array($this->className, 'getDatabaseTableName'))." FOR UPDATE"; $stmt = WCF::getDB()->prepareStatement($sql); $stmt->execute(); $editor = new RoomEditor($room); - $editor->update(array('position' => ($stmt->fetchColumn() + 1))); + $editor->update(array('showOrder' => ($stmt->fetchColumn() + 1))); WCF::getDB()->commitTransaction(); return $room; @@ -115,7 +115,7 @@ public function updatePosition() { if ($room === null) continue; $editor = new RoomEditor($room); - $editor->update(array('position' => $i++)); + $editor->update(array('showOrder' => $i++)); } WCF::getDB()->commitTransaction(); } diff --git a/file/lib/data/room/RoomEditor.class.php b/file/lib/data/room/RoomEditor.class.php index 12fcc9e..3510894 100644 --- a/file/lib/data/room/RoomEditor.class.php +++ b/file/lib/data/room/RoomEditor.class.php @@ -29,7 +29,7 @@ public static function deleteAll(array $objectIDs = array()) { } $sql = "SELECT - position + showOrder FROM chat".WCF_N."_room WHERE @@ -40,9 +40,9 @@ public static function deleteAll(array $objectIDs = array()) { $sql = "UPDATE chat".WCF_N."_room SET - position = position - 1 + showOrder = showOrder - 1 WHERE - position > ?"; + showOrder > ?"; $update = WCF::getDB()->prepareStatement($sql); foreach ($objectIDs as $objectID) { diff --git a/file/lib/system/cache/builder/RoomCacheBuilder.class.php b/file/lib/system/cache/builder/RoomCacheBuilder.class.php index 3533677..3d5d1c0 100644 --- a/file/lib/system/cache/builder/RoomCacheBuilder.class.php +++ b/file/lib/system/cache/builder/RoomCacheBuilder.class.php @@ -17,7 +17,7 @@ class RoomCacheBuilder extends \wcf\system\cache\builder\AbstractCacheBuilder { public function rebuild(array $parameters) { // get all chat rooms $roomList = new \chat\data\room\RoomList(); - $roomList->sqlOrderBy = "room.position"; + $roomList->sqlOrderBy = "room.showOrder"; $roomList->readObjects(); return $roomList->getObjects(); diff --git a/install.sql b/install.sql index 72d1c24..e9b166f 100644 --- a/install.sql +++ b/install.sql @@ -32,11 +32,11 @@ CREATE TABLE chat1_room ( roomID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, topic VARCHAR(255) NOT NULL, - position INT(10) NOT NULL DEFAULT 0, + showOrder INT(10) NOT NULL DEFAULT 0, permanent TINYINT(1) NOT NULL DEFAULT 1, owner INT(10) DEFAULT NULL, - KEY positionKey (position), + KEY showOrder (showOrder), KEY owner (owner) ); @@ -63,7 +63,7 @@ ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON ALTER TABLE chat1_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE; ALTER TABLE chat1_suspension ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE; -INSERT INTO chat1_room (title, topic, position) VALUES ('chat.room.title1', 'chat.room.topic1', 1); -INSERT INTO chat1_room (title, topic, position) VALUES ('Testroom 2', 'Topic of Testroom 2', 2); -INSERT INTO chat1_room (title, topic, position) VALUES ('Testroom with a very long', 'The topic of this room is rather loing as well!', 3); -INSERT INTO chat1_room (title, topic, position) VALUES ('Room w/o topic', '', 4); +INSERT INTO chat1_room (title, topic, showOrder) VALUES ('chat.room.title1', 'chat.room.topic1', 1); +INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom 2', 'Topic of Testroom 2', 2); +INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom with a very long', 'The topic of this room is rather loing as well!', 3); +INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Room w/o topic', '', 4);