From 2ad26f0d04d377bd331e744505b4591c6664398c Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Tue, 12 Aug 2014 20:43:35 +0200 Subject: [PATCH] Don't color usernames if the color has not been set explicitly --- file/lib/data/message/Message.class.php | 7 ++++++- file/lib/system/command/commands/RestoreCommand.class.php | 4 ++-- install.sql | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/file/lib/data/message/Message.class.php b/file/lib/data/message/Message.class.php index cd841b9..f97f794 100644 --- a/file/lib/data/message/Message.class.php +++ b/file/lib/data/message/Message.class.php @@ -124,7 +124,12 @@ public function getUsername($colored = false) { if ($this->type == self::TYPE_INFORMATION) return WCF::getLanguage()->get('chat.global.information'); if ($colored) { - $username = \chat\util\ChatUtil::gradient($username, $this->color1, $this->color2); + if ($this->color1 !== null || $this->color2 !== null) { + $username = \chat\util\ChatUtil::gradient($username, $this->color1, $this->color2); + } + else { + $username = ''.$username.''; + } } return $username; diff --git a/file/lib/system/command/commands/RestoreCommand.class.php b/file/lib/system/command/commands/RestoreCommand.class.php index 9369f4e..998c9ec 100644 --- a/file/lib/system/command/commands/RestoreCommand.class.php +++ b/file/lib/system/command/commands/RestoreCommand.class.php @@ -32,8 +32,8 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler) $editor = new \wcf\data\user\UserEditor($this->user); $editor->update(array( - 'chatColor1' => 0, - 'chatColor2' => 0 + 'chatColor1' => null, + 'chatColor2' => null )); $this->didInit(); } diff --git a/install.sql b/install.sql index 7bd211b..66d416b 100644 --- a/install.sql +++ b/install.sql @@ -19,8 +19,8 @@ CREATE TABLE chat1_message ( message MEDIUMTEXT NOT NULL, enableSmilies TINYINT(1) NOT NULL DEFAULT 1, enableHTML TINYINT(1) NOT NULL DEFAULT 0, - color1 INT(10) NOT NULL DEFAULT 0, - color2 INT(10) NOT NULL DEFAULT 0, + color1 INT(10) DEFAULT NULL, + color2 INT(10) DEFAULT NULL, additionalData TEXT DEFAULT NULL, attachmentID INT(10) DEFAULT NULL, @@ -62,8 +62,8 @@ CREATE TABLE chat1_suspension ( ); ALTER TABLE wcf1_user ADD COLUMN chatRoomID INT(10) DEFAULT NULL; -ALTER TABLE wcf1_user ADD COLUMN chatColor1 INT(10) NOT NULL DEFAULT 0; -ALTER TABLE wcf1_user ADD COLUMN chatColor2 INT(10) NOT NULL DEFAULT 0; +ALTER TABLE wcf1_user ADD COLUMN chatColor1 INT(10) DEFAULT NULL; +ALTER TABLE wcf1_user ADD COLUMN chatColor2 INT(10) DEFAULT NULL; ALTER TABLE wcf1_user ADD COLUMN chatLastActivity INT(10) NOT NULL DEFAULT 0; ALTER TABLE wcf1_user ADD COLUMN chatAway TEXT DEFAULT NULL; ALTER TABLE wcf1_user ADD COLUMN chatLastSeen INT(10) NOT NULL DEFAULT 0;