From 64fb4bec06a3f0c7248c8c8543faa5845113672a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 4 Feb 2012 12:25:09 +0100 Subject: [PATCH] Use classmember instead of constant for smiley activation --- file/lib/form/ChatForm.class.php | 3 ++- file/lib/system/chat/commands/CommandHandler.class.php | 2 +- file/lib/system/chat/commands/commands/Color.class.php | 2 +- file/lib/system/chat/commands/commands/Free.class.php | 2 +- file/lib/system/chat/commands/commands/Me.class.php | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index 1d12d46..32e9d54 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -51,6 +51,7 @@ public function readFormParameters() { */ public function validate() { parent::validate(); + if ($this->message === '') { throw new UserInputException('text'); } @@ -67,7 +68,7 @@ public function save() { try { $command = $commandHandler->loadCommand(); - if ($command::ENABLE_SMILIES != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command::ENABLE_SMILIES; + if ($command->enableSmilies != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command->enableSmilies; $type = $command->getType(); $this->message = $command->getMessage(); $receiver = $command->getReceiver(); diff --git a/file/lib/system/chat/commands/CommandHandler.class.php b/file/lib/system/chat/commands/CommandHandler.class.php index 558f6b5..2121fc2 100644 --- a/file/lib/system/chat/commands/CommandHandler.class.php +++ b/file/lib/system/chat/commands/CommandHandler.class.php @@ -50,7 +50,7 @@ public function loadCommand() { $parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2); if ($this->isCommand($parts[0])) { - return new \wcf\system\chat\commands\PlainCommand(); + return new commands\commands\PlainCommand($this); } $class = '\wcf\system\chat\commands\commands\\'.ucfirst($parts[0]); diff --git a/file/lib/system/chat/commands/commands/Color.class.php b/file/lib/system/chat/commands/commands/Color.class.php index db67a55..b79ce01 100644 --- a/file/lib/system/chat/commands/commands/Color.class.php +++ b/file/lib/system/chat/commands/commands/Color.class.php @@ -12,7 +12,7 @@ * @subpackage system.chat.commands.commands */ class Color extends \wcf\system\chat\commands\AbstractCommand { - const ENABLE_SMILIES = \wcf\system\chat\commands\ICommand::SMILEY_OFF; + public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF; public static $colors = array( 'red' => 0xFF0000, 'blue' => 0x0000FF, diff --git a/file/lib/system/chat/commands/commands/Free.class.php b/file/lib/system/chat/commands/commands/Free.class.php index b5a77e7..2ffdfd8 100644 --- a/file/lib/system/chat/commands/commands/Free.class.php +++ b/file/lib/system/chat/commands/commands/Free.class.php @@ -11,7 +11,7 @@ * @subpackage system.chat.commands.commands */ class Free extends Me { - const ENABLE_SMILIES = \wcf\system\chat\commands\ICommand::SMILEY_OFF; + public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF; /** * @see \wcf\system\chat\commands\ICommand::getMessage() diff --git a/file/lib/system/chat/commands/commands/Me.class.php b/file/lib/system/chat/commands/commands/Me.class.php index d08f36d..dbe734e 100644 --- a/file/lib/system/chat/commands/commands/Me.class.php +++ b/file/lib/system/chat/commands/commands/Me.class.php @@ -12,7 +12,7 @@ * @subpackage system.chat.commands.commands */ class Me extends \wcf\system\chat\commands\AbstractCommand { - const ENABLE_SMILIES = \wcf\system\chat\commands\ICommand::SMILEY_USER; + public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_USER; /** * @see \wcf\system\chat\commands\ICommand::getType()