this._previewButton.click($.proxy(this._click, this));
this._proxy = new WCF.Action.Proxy({
+ failure: $.proxy(this._failure, this),
success: $.proxy(this._success, this)
});
},
// restore preview button
this._previewButton.html(this._previewButtonLabel).enable();
+ // remove error message
+ this._messageField.parent().children('small.innerError').remove();
+
// evaluate message
this._handleResponse(data);
},
*
* @param object data
*/
- _handleResponse: function(data) { }
+ _handleResponse: function(data) { },
+
+ /**
+ * Handles errors during preview requests.
+ *
+ * The return values indicates if the default error overlay is shown.
+ *
+ * @param object data
+ * @return boolean
+ */
+ _failure: function(data) {
+ if (data === null || data.returnValues === undefined || data.returnValues.errorType === undefined) {
+ return true;
+ }
+
+ // restore preview button
+ this._previewButton.html(this._previewButtonLabel).enable();
+
+ var $innerError = this._messageField.next('small.innerError').empty();
+ if (!$innerError.length) {
+ $innerError = $('<small class="innerError" />').appendTo(this._messageField.parent());
+ }
+
+ $innerError.html(data.returnValues.errorType);
+
+ return false;
+ }
});
/**
use wcf\system\bbcode\PreParser;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
+use wcf\util\ArrayUtil;
use wcf\util\StringUtil;
/**
* Provides a default message preview action.
*
* @author Marcel Werk
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf.message
* @subpackage data.message
$enableSmilies = (isset($this->parameters['options']['enableSmilies'])) ? 1 : 0;
$preParse = (isset($this->parameters['options']['preParse'])) ? 1 : 0;
+ $allowedBBCodesPermission = (isset($this->parameters['allowedBBCodesPermission'])) ? $this->parameters['allowedBBCodesPermission'] : 'user.message.allowedBBCodes';
+
// validate permissions for options
if ($enableBBCodes && !WCF::getSession()->getPermission('user.message.canUseBBCodes')) $enableBBCodes = 0;
if ($enableHtml && !WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 0;
if ($enableSmilies && !WCF::getSession()->getPermission('user.message.canUseSmilies')) $enableSmilies = 0;
+ // check if disallowed bbcode are used
+ if ($enableBBCodes && $allowedBBCodesPermission) {
+ $disallowedBBCodes = MessageParser::getInstance()->validateBBCodes($this->parameters['data']['message'], ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
+ if (!empty($disallowedBBCodes)) {
+ throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array(
+ 'disallowedBBCodes' => $disallowedBBCodes
+ )));
+ }
+ }
+
// get attachments
if (!empty($this->parameters['attachmentObjectType'])) {
$attachmentList = new GroupedAttachmentList($this->parameters['attachmentObjectType']);
// parse URLs
if ($preParse && $enableBBCodes) {
- $message = PreParser::getInstance()->parse($message);
+ if ($allowedBBCodesPermission) {
+ $message = PreParser::getInstance()->parse($message, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
+ }
+ else {
+ $message = PreParser::getInstance()->parse($message);
+ }
}
// parse message
if (isset($this->parameters['options']['enableBBCodes']) && WCF::getSession()->getPermission('user.signature.canUseBBCodes')) {
$disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($this->parameters['data']['message'], explode(',', WCF::getSession()->getPermission('user.signature.allowedBBCodes')));
if (!empty($disallowedBBCodes)) {
- throw new UserInputException('message', 'disallowedBBCodes', $disallowedBBCodes);
+ throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array(
+ 'disallowedBBCodes' => $disallowedBBCodes
+ )));
}
}
}
use wcf\system\language\LanguageFactory;
use wcf\system\message\censorship\Censorship;
use wcf\system\WCF;
+use wcf\util\ArrayUtil;
use wcf\util\MessageUtil;
use wcf\util\StringUtil;
}
if ($this->enableBBCodes && $this->allowedBBCodesPermission) {
- $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($this->text, explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission)));
+ $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($this->text, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission))));
if (!empty($disallowedBBCodes)) {
WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
throw new UserInputException('text', 'disallowedBBCodes');
// BBCodes are enabled
if ($this->enableBBCodes) {
if ($this->allowedBBCodesPermission) {
- $this->text = PreParser::getInstance()->parse($this->text, explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission)));
+ $this->text = PreParser::getInstance()->parse($this->text, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission))));
}
else {
$this->text = PreParser::getInstance()->parse($this->text);
));
if ($this->allowedBBCodesPermission) {
- WCF::getTPL()->assign('allowedBBCodes', explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission)));
+ WCF::getTPL()->assign('allowedBBCodes', explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($this->allowedBBCodesPermission))));
}
}
}
use wcf\system\bbcode\BBCodeParser;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
+use wcf\util\ArrayUtil;
/**
* Option type implementation for message.
*
* @author Marcel Werk
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf.user
* @subpackage system.option
parent::validate($option, $newValue);
if ($option->allowedbbcodepermission) {
- $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($newValue, explode(',', WCF::getSession()->getPermission($option->allowedbbcodepermission)));
+ $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($newValue, explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($option->allowedbbcodepermission))));
if (!empty($disallowedBBCodes)) {
WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
throw new UserInputException($option->optionName, 'disallowedBBCodes');