var $deleteButton = $('<li><a href="#" class="jsTooltip" title="' + WCF.Language.get('wcf.global.button.delete') + '"><span class="icon icon16 fa-times" /> <span class="invisible">' + WCF.Language.get('wcf.global.button.delete') + '</span></a></li>');
$deleteButton.data('commentID', commentID).appendTo(comment.find('ul.buttonList:eq(0)')).click($.proxy(this._delete, this));
}
+
+ var enableComment = elBySel('.jsEnableComment', comment[0]);
+ if (enableComment) {
+ enableComment.addEventListener(WCF_CLICK_EVENT, this._enableComment.bind(this));
+ }
+ },
+
+ _enableComment: function (event) {
+ event.preventDefault();
+
+ var comment = event.currentTarget.closest('.comment');
+
+ this._proxy.setOption('data', {
+ actionName: 'enable',
+ className: 'wcf\\data\\comment\\CommentAction',
+ objectIDs: [elData(comment, 'object-id')],
+ parameters: {
+ data: {
+ objectID: elData(this._container[0], 'object-id'),
+ objectTypeID: elData(this._container[0], 'object-type-id')
+ }
+ }
+ });
+ this._proxy.sendRequest();
},
_initPermalink: function(comment, link) {
this._update(data);
break;
+ case 'enable':
+ this._enable(data);
+ break;
+
case 'loadComment':
this._insertComment(data);
break;
WCF.DOMNodeInsertedHandler.execute();
},
+ _enable: function(data) {
+ if (data.returnValues.commentID) {
+ var comment = elBySel('.comment[data-object-id="' + data.returnValues.commentID + '"]', this._container[0]);
+ if (comment) {
+ elData(comment, 'is-disabled', 0);
+ var badge = elBySel('.jsIconDisabled', comment);
+ if (badge) elRemove(badge);
+
+ var enableLink = elBySel('.jsEnableComment', comment);
+ if (enableLink) elRemove(enableLink.parentNode);
+ }
+ }
+ },
+
_insertComment: function (data) {
if (data.returnValues.template === '') {
// comment id is invalid or there is a mismatch, silently ignore it
/** @var CommentEditor $comment */
foreach ($this->objects as $comment) {
// update counter
+ $comment->update(['isDisabled' => 0]);
$this->commentProcessor->updateCounter($comment->objectID, 1);
// fire activity event
}
}
+ public function validateEnable() {
+ $this->readInteger('objectID', false, 'data');
+ $this->comment = $this->getSingleObject()->getDecoratedObject();
+
+ $objectType = $this->validateObjectType($this->comment->objectTypeID);
+ $this->commentProcessor = $objectType->getProcessor();
+ if (!$this->commentProcessor->canModerate($this->comment->objectTypeID, $this->comment->objectID)) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ public function enable() {
+ if ($this->comment->isDisabled) {
+ $action = new CommentAction([$this->comment], 'triggerPublication', [
+ 'commentProcessor' => $this->commentProcessor
+ ]);
+ $action->executeAction();
+ }
+
+ return ['commentID' => $this->comment->commentID];
+ }
+
/**
* Validates parameters to edit a comment or a response.
*/