* Comment support for WCF
*
* @author Alexander Ebert
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
WCF.Comment.Handler = Class.extend({
* @param jQuery input
*/
_save: function(event, isResponse, input) {
- var $input = (event === null) ? input : $(event.currentTarget).prev('textarea');
+ var $input = (event === null) ? input : $(event.currentTarget).parent().children('textarea');
+ $input.next('small.innerError').remove();
var $value = $.trim($input.val());
// ignore empty comments
this._proxy.sendRequest();
}
else {
- this._proxy.setOption('data', {
- actionName: $actionName,
- className: 'wcf\\data\\comment\\CommentAction',
- parameters: {
- data: $data
- }
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: $actionName,
+ className: 'wcf\\data\\comment\\CommentAction',
+ parameters: {
+ data: $data
+ }
+ },
+ success: $.proxy(this._success, this),
+ failure: (function(data, jqXHR, textStatus, errorThrown) {
+ if (data.returnValues && data.returnValues.fieldName) {
+ if (data.returnValues.fieldName === 'text' && data.returnValues.errorType) {
+ $('<small class="innerError">' + data.returnValues.errorType + '</small>').insertAfter($input);
+
+ return false;
+ }
+ }
+
+ this._failure(data, jqXHR, textStatus, errorThrown);
+ }).bind(this)
});
- this._proxy.sendRequest();
}
},
_saveEdit: function(event) {
var $input = $(event.currentTarget);
if ($input.is('button')) {
+ $input.prev('small.innerError').remove();
$input = $input.prev('textarea');
}
var $message = $.trim($input.val());
$data.responseID = $input.data('responseID');
}
- this._proxy.setOption('data', {
- actionName: 'edit',
- className: 'wcf\\data\\comment\\CommentAction',
- parameters: {
- data: $data
- }
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: 'edit',
+ className: 'wcf\\data\\comment\\CommentAction',
+ parameters: {
+ data: $data
+ }
+ },
+ success: $.proxy(this._success, this),
+ failure: (function(data, jqXHR, textStatus, errorThrown) {
+ if (data.returnValues && data.returnValues.fieldName) {
+ if (data.returnValues.fieldName === 'text' && data.returnValues.errorType) {
+ $('<small class="innerError">' + data.returnValues.errorType + '</small>').insertAfter($input);
+
+ return false;
+ }
+ }
+
+ this._failure(data, jqXHR, textStatus, errorThrown);
+ }).bind(this)
});
- this._proxy.sendRequest();
},
/**
use wcf\system\comment\manager\ICommentManager;
use wcf\system\exception\NamedUserException;
use wcf\system\exception\SystemException;
+use wcf\system\exception\UserInputException;
use wcf\system\like\LikeHandler;
+use wcf\system\message\censorship\Censorship;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\SingletonFactory;
* Provides methods for comment object handling.
*
* @author Alexander Ebert
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.comment
}
}
}
+
+ /**
+ * Enforces the censorship.
+ *
+ * @param string $text
+ */
+ public static function enforceCensorship($text) {
+ // search for censored words
+ if (ENABLE_CENSORSHIP) {
+ $result = Censorship::getInstance()->test($text);
+ if ($result) {
+ throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('wcf.message.error.censoredWordsFound', array('censoredWords' => $result)));
+ }
+ }
+ }
}