{foreach from=$responseList item=response}
- {if $response->isDisabled && $commentCanModerate|isset && !$commentCanModerate}
+ {if $response->isDisabled && !$commentCanModerate}
<li>
<p class="info commentModerationDisabledComment">{lang}wcf.comment.moderation.disabledComment{/lang}</p>
</li>
<nav class="jsMobileNavigation buttonGroupNavigation">
<ul class="buttonList iconList">
+ {if $response->isDisabled && $commentCanModerate}
+ <li class="jsOnly"><a href="#" class="jsEnableResponse"><span class="icon icon16 fa-check"></span> <span class="invisible">{lang}wcf.comment.approve{/lang}</span></a></li>
+ {/if}
{if $commentManager->supportsReport() && $__wcf->session->getPermission('user.profile.canReportContent')}
<li class="jsReportCommentResponse jsOnly" data-object-id="{@$response->responseID}"><a href="#" title="{lang}wcf.moderation.report.reportContent{/lang}" class="jsTooltip"><span class="icon icon16 fa-exclamation-triangle"></span> <span class="invisible">{lang}wcf.moderation.report.reportContent{/lang}</span></a></li>
{/if}
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')
- }
- }
+ objectIDs: [elData(comment, 'object-id')]
});
this._proxy.sendRequest();
},
//noinspection JSReferencingMutableVariableFromClosure
this._initPermalinkResponse(commentId, response, $responseID, link);
+
+ var enableResponse = elBySel('.jsEnableResponse', response);
+ if (enableResponse) {
+ enableResponse.addEventListener(WCF_CLICK_EVENT, this._enableCommentResponse.bind(this));
+ }
}).bind(this));
}
}
},
+ _enableCommentResponse: function (event) {
+ event.preventDefault();
+
+ var response = event.currentTarget.closest('.commentResponse');
+
+ this._proxy.setOption('data', {
+ actionName: 'enableResponse',
+ className: 'wcf\\data\\comment\\CommentAction',
+ parameters: {
+ data: {
+ responseID: elData(response, 'object-id')
+ }
+ }
+ });
+ this._proxy.sendRequest();
+ },
+
_initPermalinkResponse: function (commentId, response, responseId, link) {
var anchor = elCreate('a');
anchor.href = link + (link.indexOf('#') === -1 ? '#' : '/') + 'comment' + commentId + '/response' + responseId;
case 'enable':
this._enable(data);
break;
+
+ case 'enableResponse':
+ this._enableResponse(data);
+ break;
case 'loadComment':
this._insertComment(data);
}
},
+ _enableResponse: function(data) {
+ if (data.returnValues.responseID) {
+ var response = elBySel('.commentResponse[data-object-id="' + data.returnValues.responseID + '"]', this._container[0]);
+ if (response) {
+ elData(response, 'is-disabled', 0);
+ var badge = elBySel('.jsIconDisabled', response);
+ if (badge) elRemove(badge);
+
+ var enableLink = elBySel('.jsEnableResponse', response);
+ if (enableLink) elRemove(enableLink.parentNode);
+ }
+ }
+ },
+
_insertComment: function (data) {
if (data.returnValues.template === '') {
// comment id is invalid or there is a mismatch, silently ignore it
$this->commentProcessor = $objectType->getProcessor();
}
- /** @var CommentResponseEditor $response */
+ /** @var CommentResponse $response */
foreach ($this->parameters['responses'] as $response) {
+ (new CommentResponseEditor($response))->update(['isDisabled' => 0]);
+
$comment = $response->getComment();
// update response count
$this->commentProcessor->updateCounter($comment->objectID, 1);
// fire activity event
- if ($this->createdResponse->userID && UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.recentActivityEvent')) {
+ if ($response->userID && UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.recentActivityEvent')) {
UserActivityEventHandler::getInstance()->fireEvent($objectType->objectType.'.response.recentActivityEvent', $response->responseID, null, null, $response->time);
}
// fire notification event
if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.notification') && UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
$notificationObjectType = UserNotificationHandler::getInstance()->getObjectTypeProcessor($objectType->objectType.'.notification');
- $notificationObject = new CommentResponseUserNotificationObject($this->createdResponse);
+ $notificationObject = new CommentResponseUserNotificationObject($response);
if ($notificationObjectType instanceof IMultiRecipientCommentUserNotificationObjectType) {
$recipientIDs = $notificationObjectType->getRecipientIDs($comment);
'commentResponse',
$objectType->objectType . '.response.notification',
$notificationObject,
- [$this->comment->userID],
+ [$comment->userID],
[
'commentID' => $comment->commentID,
'objectID' => $comment->objectID,
}
public function validateEnable() {
- $this->readInteger('objectID', false, 'data');
$this->comment = $this->getSingleObject()->getDecoratedObject();
$objectType = $this->validateObjectType($this->comment->objectTypeID);
return ['commentID' => $this->comment->commentID];
}
+ public function validateEnableResponse() {
+ $this->readInteger('responseID', false, 'data');
+ $this->response = new CommentResponse($this->parameters['data']['responseID']);
+ if (!$this->response->responseID) {
+ throw new UserInputException('responseID');
+ }
+
+ $this->comment = $this->response->getComment();
+
+ $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 enableResponse() {
+ if ($this->response->isDisabled) {
+ $action = new CommentAction([], 'triggerPublicationResponse', [
+ 'commentProcessor' => $this->commentProcessor,
+ 'objectTypeID' => $this->comment->objectTypeID,
+ 'responses' => [$this->response]
+ ]);
+ $action->executeAction();
+ }
+
+ return ['responseID' => $this->response->responseID];
+ }
+
/**
* Validates parameters to edit a comment or a response.
*/
* @return array
*/
public function loadResponses() {
+ $commentCanModerate = $this->commentManager->canModerate($this->comment->objectTypeID, $this->comment->objectID);
+
// get response list
$responseList = new StructuredCommentResponseList($this->commentManager, $this->comment);
$responseList->getConditionBuilder()->add("comment_response.time > ?", [$this->parameters['data']['lastResponseTime']]);
+ if (!$commentCanModerate) $responseList->getConditionBuilder()->add("comment_response.isDisabled = ?", [0]);
if (!$this->parameters['data']['loadAllResponses']) $responseList->sqlLimit = 50;
$responseList->readObjects();
}
WCF::getTPL()->assign([
+ 'commentCanModerate' => $commentCanModerate,
'likeData' => MODULE_LIKE ? $responseList->getLikeData() : [],
'responseList' => $responseList,
'commentManager' => $this->commentManager
position: absolute;
}
-.jsEnableComment > .invisible {
+.jsEnableComment > .invisible,
+.jsEnableResponse > .invisible {
display: inline;
}