From 04ac9c2bde8d5412dab5e59329dfe1949f359ce7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 21 Mar 2014 01:51:29 +0100 Subject: [PATCH] Add createMessage and createdMessage event to QuickReplyManager Closes #1596 --- .../message/QuickReplyManager.class.php | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php b/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php index 295a7ca276..fee4a6f56d 100644 --- a/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php +++ b/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php @@ -48,6 +48,17 @@ class QuickReplyManager extends SingletonFactory { */ public $type = ''; + /** + * additional fields + * @var array + */ + public $additionalFields = array(); + + /** + * the message that just was created + */ + public $message = null; + /** * Returns a stored message from session. * @@ -139,6 +150,8 @@ class QuickReplyManager extends SingletonFactory { // check for message quote ids $parameters['removeQuoteIDs'] = (isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs'])) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : array(); + + EventHandler::getInstance()->fireAction($this, 'validateParameters'); } /** @@ -153,6 +166,8 @@ class QuickReplyManager extends SingletonFactory { * @return array */ public function createMessage(IMessageQuickReplyAction $object, array &$parameters, $containerActionClassName, $sortOrder, $templateName, $application = 'wcf') { + EventHandler::getInstance()->fireAction($this, 'createMessage'); + $tableIndexName = call_user_func(array($this->container, 'getDatabaseTableIndexName')); $parameters['data'][$tableIndexName] = $parameters['objectID']; $parameters['data']['enableSmilies'] = WCF::getSession()->getPermission('user.message.canUseSmilies'); @@ -160,14 +175,25 @@ class QuickReplyManager extends SingletonFactory { $parameters['data']['enableBBCodes'] = WCF::getSession()->getPermission('user.message.canUseBBCodes'); $parameters['data']['showSignature'] = (WCF::getUser()->userID ? WCF::getUser()->showSignature : 0); $parameters['data']['time'] = TIME_NOW; - $parameters['data']['userID'] = WCF::getUser()->userID; + $parameters['data']['userID'] = WCF::getUser()->userID ?: null; $parameters['data']['username'] = WCF::getUser()->username; // pre-parse message text $parameters['data']['message'] = MessageUtil::stripCrap($parameters['data']['message']); $parameters['data']['message'] = PreParser::getInstance()->parse($parameters['data']['message'], $this->allowedBBodes); - $message = $object->create(); + $parameters['data'] = array_merge($this->additionalFields, $parameters['data']); + + // clean up + $this->additionalFields = array(); + + $this->message = $object->create(); + EventHandler::getInstance()->fireAction($this, 'createdMessage'); + $message = $this->message; + + // clean up + $this->message = null; + if ($message instanceof IMessage && !$message->isVisible()) { return array( 'isVisible' => false -- 2.20.1