From: Marcel Werk Date: Tue, 15 Jul 2014 15:12:44 +0000 (+0200) Subject: Moderation queue entries now support comments / moderation queue overhaul (WIP) X-Git-Tag: 2.1.0_Alpha_1~569 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=166d2b91db5b4c32cefcf5dd64f9be72cb6dfa08;p=GitHub%2FWoltLab%2FWCF.git Moderation queue entries now support comments / moderation queue overhaul (WIP) --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 567794498b..0080bf9e0c 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -216,6 +216,12 @@ com.woltlab.wcf.user + + + com.woltlab.wcf.moderation.queue + com.woltlab.wcf.comment.commentableContent + + diff --git a/com.woltlab.wcf/templates/__commentJavaScript.tpl b/com.woltlab.wcf/templates/__commentJavaScript.tpl index 04337db0aa..2a070de5d8 100644 --- a/com.woltlab.wcf/templates/__commentJavaScript.tpl +++ b/com.woltlab.wcf/templates/__commentJavaScript.tpl @@ -18,12 +18,12 @@ }); new {if $commentHandlerClass|isset}{@$commentHandlerClass}{else}WCF.Comment.Handler{/if}('{$commentContainerID}', '{@$__wcf->getUserProfileHandler()->getAvatar()->getImageTag(32)}'); - {if MODULE_LIKE && $__wcf->getSession()->getPermission('user.like.canViewLike')} + {if MODULE_LIKE && $commentList->getCommentManager()->supportsLike() && $__wcf->getSession()->getPermission('user.like.canViewLike')} new WCF.Comment.Like({if $__wcf->getUser()->userID && $__wcf->getSession()->getPermission('user.like.canLike')}1{else}0{/if}, {@LIKE_ENABLE_DISLIKE}, false, {@LIKE_ALLOW_FOR_OWN_CONTENT}); new WCF.Comment.Response.Like({if $__wcf->getUser()->userID && $__wcf->getSession()->getPermission('user.like.canLike')}1{else}0{/if}, {@LIKE_ENABLE_DISLIKE}, false, {@LIKE_ALLOW_FOR_OWN_CONTENT}); {/if} - {if $__wcf->session->getPermission('user.profile.canReportContent')} + {if $commentList->getCommentManager()->supportsReport() && $__wcf->session->getPermission('user.profile.canReportContent')} new WCF.Moderation.Report.Content('com.woltlab.wcf.comment.comment', '.jsReportCommentComment'); new WCF.Moderation.Report.Content('com.woltlab.wcf.comment.response', '.jsReportCommentResponse'); {/if} diff --git a/com.woltlab.wcf/templates/commentList.tpl b/com.woltlab.wcf/templates/commentList.tpl index 9238db9371..4404921680 100644 --- a/com.woltlab.wcf/templates/commentList.tpl +++ b/com.woltlab.wcf/templates/commentList.tpl @@ -1,3 +1,4 @@ +{if !$commentManager|isset}{assign var='commentManager' value=$commentList->getCommentManager()}{/if} {foreach from=$commentList item=comment}
  • @@ -27,7 +28,7 @@
    +
    +

    {lang}wcf.moderation.comments{/lang} {#$queue->comments}

    +

    {lang}wcf.moderation.comments.description{/lang}

    +
    + +{include file='__commentJavaScript' commentContainerID='moderationQueueCommentList'} + +
    +
      + {include file='commentList'} +
    +
    + {include file='footer'} diff --git a/com.woltlab.wcf/templates/moderationReport.tpl b/com.woltlab.wcf/templates/moderationReport.tpl index f12eb39212..06685a596a 100644 --- a/com.woltlab.wcf/templates/moderationReport.tpl +++ b/com.woltlab.wcf/templates/moderationReport.tpl @@ -1,7 +1,7 @@ {include file='documentHeader'} - {lang}wcf.moderation.report{/lang} - {PAGE_TITLE|language} + {lang}wcf.moderation.report{/lang}: {$queue->getTitle()} - {PAGE_TITLE|language} {include file='headInclude'} @@ -22,82 +22,61 @@ -{include file='header' sidebarOrientation='left'} +{capture assign='sidebar'} +
    +
    + {lang}wcf.moderation.report.details{/lang} + +
    +
    {lang}wcf.moderation.assignedUser{/lang}
    +
    +
      + {if $assignedUserID && ($assignedUserID != $__wcf->getUser()->userID)} +
    • + {/if} +
    • +
    • +
    +
    +
    + {if $queue->assignedUser} +
    +
    +
    {$queue->assignedUsername}
    +
    + {/if} + + {event name='detailsFields'} + +
    + + {@SECURITY_TOKEN_INPUT_TAG} +
    +
    + + {event name='fieldsets'} +
    + + {event name='boxes'} +{/capture} + +{include file='header' sidebarOrientation='right'}
    -

    {lang}wcf.moderation.report{/lang}

    +

    {lang}wcf.moderation.report{/lang}: {$queue->getTitle()}

    + + {if $queue->lastChangeTime} +
    +
    {lang}wcf.moderation.lastChangeTime{/lang}
    +
    {@$queue->lastChangeTime|time}
    +
    + {/if}
    {include file='userNotice'} {include file='formError'} -
    - -
    - -
    -
    - {lang}wcf.moderation.report.details{/lang} - -
    -
    {lang}wcf.global.objectID{/lang}
    -
    {#$queue->queueID}
    -
    -
    -
    {lang}wcf.moderation.report.reportedBy{/lang}
    -
    {if $queue->userID}{$queue->username}{else}{lang}wcf.user.guest{/lang}{/if} ({@$queue->time|time})
    -
    - {if $queue->lastChangeTime} -
    -
    {lang}wcf.moderation.lastChangeTime{/lang}
    -
    {@$queue->lastChangeTime|time}
    -
    - {/if} -
    -
    {lang}wcf.moderation.assignedUser{/lang}
    -
    -
      - {if $assignedUserID && ($assignedUserID != $__wcf->getUser()->userID)} -
    • - {/if} -
    • -
    • -
    -
    -
    - {if $queue->assignedUser} -
    -
    -
    {$queue->assignedUsername}
    -
    - {/if} -
    -
    {lang}wcf.moderation.report.reason{/lang}
    -
    {@$queue->getFormattedMessage()}
    -
    -
    -
    -
    -
    - - {event name='detailsFields'} - -
    - - {@SECURITY_TOKEN_INPUT_TAG} -
    -
    - - {event name='fieldsets'} -
    -

    {lang}wcf.moderation.report.reportedContent{/lang}

    @@ -113,13 +92,58 @@ {if $queueManager->canRemoveContent($queue->getDecoratedObject())}
  • {lang}wcf.moderation.report.removeContent{/lang}
  • {/if}
  • {lang}wcf.moderation.report.removeReport{/lang}
  • {/if} -
  • {lang}wcf.moderation.moderation{/lang}
  • + {if $queue->getAffectedObject()}
  • {lang}wcf.moderation.jumpToContent{/lang}
  • {/if} - {event name='contentNavigationButtonsBottom'} + {event name='contentNavigationButtons'} +
    +

    {lang}wcf.moderation.report.reportedBy{/lang}

    +
    + +
    +
    + {if $reportUser->userID} + + {@$reportUser->getAvatar()->getImageTag(32)} + + {else} + {@$reportUser->getAvatar()->getImageTag(32)} + {/if} + +
    +
    +

    + {if $queue->userID} + {$queue->username} + {else} + {lang}wcf.user.guest{/lang} + {/if} + + - {@$queue->time|time} +

    +
    + +
    {@$queue->getFormattedMessage()}
    +
    +
    +
    + +
    +

    {lang}wcf.moderation.comments{/lang} {#$queue->comments}

    +

    {lang}wcf.moderation.comments.description{/lang}

    +
    + +{include file='__commentJavaScript' commentContainerID='moderationQueueCommentList'} + +
    + +
    + {include file='footer'} diff --git a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php index 1c3b2dd048..948fcfdbea 100644 --- a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php +++ b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php @@ -630,7 +630,8 @@ class CommentAction extends AbstractDatabaseObjectAction { } WCF::getTPL()->assign(array( - 'commentList' => array($comment) + 'commentList' => array($comment), + 'commentManager' => $this->commentProcessor )); return WCF::getTPL()->fetch('commentList'); } @@ -654,7 +655,8 @@ class CommentAction extends AbstractDatabaseObjectAction { // render response WCF::getTPL()->assign(array( - 'responseList' => array($response) + 'responseList' => array($response), + 'commentManager' => $this->commentProcessor )); return WCF::getTPL()->fetch('commentResponseList'); } diff --git a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php index 23e01bd4da..1e3c07a477 100644 --- a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php @@ -171,4 +171,13 @@ class StructuredCommentList extends CommentList { public function getMinCommentTime() { return $this->minCommentTime; } + + /** + * Returns the comment manager object. + * + * @return \wcf\system\comment\manager\ICommentManager + */ + public function getCommentManager() { + return $this->commentManager; + } } diff --git a/wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php b/wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php index 2b3dbe929f..6675ca0085 100644 --- a/wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php @@ -165,7 +165,8 @@ class CommentResponseAction extends AbstractDatabaseObjectAction { WCF::getTPL()->assign(array( 'likeData' => (MODULE_LIKE ? $responseList->getLikeData() : array()), - 'responseList' => $responseList + 'responseList' => $responseList, + 'commentManager' => $this->commentManager )); return array( diff --git a/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php b/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php index 45a1197e78..0fbc68f50f 100644 --- a/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php +++ b/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php @@ -4,12 +4,13 @@ use wcf\data\moderation\queue\ModerationQueue; use wcf\data\moderation\queue\ModerationQueueAction; use wcf\data\moderation\queue\ViewableModerationQueue; use wcf\system\breadcrumb\Breadcrumb; +use wcf\system\comment\CommentHandler; use wcf\system\event\EventHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\PermissionDeniedException; use wcf\system\request\LinkHandler; +use wcf\system\user\collapsible\content\UserCollapsibleContentHandler; use wcf\system\WCF; -use wcf\util\StringUtil; /** * Provides an abstract form for moderation queue processing. @@ -28,12 +29,6 @@ abstract class AbstractModerationForm extends AbstractForm { */ public $assignedUserID = 0; - /** - * comment - * @var string - */ - public $comment = ''; - /** * data used for moderation queue update * @var array @@ -62,6 +57,24 @@ abstract class AbstractModerationForm extends AbstractForm { */ public $queueID = 0; + /** + * comment object type id + * @var integer + */ + public $commentObjectTypeID = 0; + + /** + * comment manager object + * @var \wcf\system\comment\manager\ICommentManager + */ + public $commentManager = null; + + /** + * list of comments + * @var \wcf\data\comment\StructuredCommentList + */ + public $commentList = null; + /** * @see \wcf\page\IPage::readParameters() */ @@ -85,8 +98,6 @@ abstract class AbstractModerationForm extends AbstractForm { public function readFormParameters() { parent::readFormParameters(); - if (isset($_POST['comment'])) $this->comment = StringUtil::trim($_POST['comment']); - // verify assigned user id if (isset($_POST['assignedUserID'])) { $this->assignedUserID = intval($_POST['assignedUserID']); @@ -107,13 +118,16 @@ abstract class AbstractModerationForm extends AbstractForm { if (empty($_POST)) { $this->assignedUserID = $this->queue->assignedUserID; - $this->comment = $this->queue->comment; } WCF::getBreadcrumbs()->add(new Breadcrumb( WCF::getLanguage()->get('wcf.moderation.moderation'), LinkHandler::getInstance()->getLink('ModerationList') )); + + $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue'); + $this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor(); + $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->queueID); } /** @@ -124,8 +138,14 @@ abstract class AbstractModerationForm extends AbstractForm { WCF::getTPL()->assign(array( 'assignedUserID' => $this->assignedUserID, - 'comment' => $this->comment, - 'queue' => $this->queue + 'queue' => $this->queue, + 'queueID' => $this->queueID, + 'commentCanAdd' => true, + 'commentList' => $this->commentList, + 'commentObjectTypeID' => $this->commentObjectTypeID, + 'lastCommentTime' => ($this->commentList ? $this->commentList->getMinCommentTime() : 0), + 'sidebarCollapsed' => UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'com.woltlab.wcf.ModerationForm'), + 'sidebarName' => 'com.woltlab.wcf.ModerationForm' )); } @@ -137,7 +157,6 @@ abstract class AbstractModerationForm extends AbstractForm { $this->data = array( 'assignedUserID' => ($this->assignedUserID ?: null), - 'comment' => $this->comment ); if ($this->queue->status != ModerationQueue::STATUS_DONE) { if ($this->assignedUserID) { diff --git a/wcfsetup/install/files/lib/form/ModerationReportForm.class.php b/wcfsetup/install/files/lib/form/ModerationReportForm.class.php index d86a864a51..0cad79a814 100644 --- a/wcfsetup/install/files/lib/form/ModerationReportForm.class.php +++ b/wcfsetup/install/files/lib/form/ModerationReportForm.class.php @@ -1,5 +1,7 @@ queue->userID); + if ($reportUser === null) $reportUser = new UserProfile(new User(null, array())); WCF::getTPL()->assign(array( 'reportedContent' => ModerationQueueReportManager::getInstance()->getReportedContent($this->queue), - 'queueManager' => ModerationQueueReportManager::getInstance() + 'queueManager' => ModerationQueueReportManager::getInstance(), + 'reportUser' => $reportUser )); } } diff --git a/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php index 8ece8fa2a1..73c3cfd531 100644 --- a/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php +++ b/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php @@ -160,4 +160,18 @@ abstract class AbstractCommentManager extends SingletonFactory implements IComme public function getCommentsPerPage() { return $this->commentsPerPage; } + + /** + * @see \wcf\system\comment\manager\ICommentManager::supportsLike() + */ + public function supportsLike() { + return true; + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::supportsReport() + */ + public function supportsReport() { + return true; + } } diff --git a/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php index e4289a84cf..b4de3799be 100644 --- a/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php +++ b/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php @@ -106,4 +106,18 @@ interface ICommentManager { * @param integer $value */ public function updateCounter($objectID, $value); + + /** + * Returns true, if this comment type supports likes. + * + * @return boolean + */ + public function supportsLike(); + + /** + * Returns true, if this comment type supports reports. + * + * @return boolean + */ + public function supportsReport(); } diff --git a/wcfsetup/install/files/lib/system/comment/manager/ModerationQueueCommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/ModerationQueueCommentManager.class.php new file mode 100644 index 0000000000..faff440c87 --- /dev/null +++ b/wcfsetup/install/files/lib/system/comment/manager/ModerationQueueCommentManager.class.php @@ -0,0 +1,90 @@ + + * @package com.woltlab.wcf + * @subpackage system.comment.manager + * @category Community Framework + */ +class ModerationQueueCommentManager extends AbstractCommentManager { + /** + * @see \wcf\system\comment\manager\ICommentManager::isAccessible() + */ + public function isAccessible($objectID, $validateWritePermission = false) { + $entry = new ModerationQueue($objectID); + return $entry->canEdit(); + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::getLink() + */ + public function getLink($objectTypeID, $objectID) { + $entry = new ViewableModerationQueue(new ModerationQueue($objectID)); + return $entry->getLink(); + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::getTitle() + */ + public function getTitle($objectTypeID, $objectID, $isResponse = false) { + return ''; + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::updateCounter() + */ + public function updateCounter($objectID, $value) { + $entry = new ModerationQueue($objectID); + $editor = new ModerationQueueEditor($entry); + $editor->updateCounters(array( + 'comments' => $value + )); + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::canAdd() + */ + public function canAdd($objectID) { + if (!$this->isAccessible($objectID, true)) { + return false; + } + + return true; + } + + /** + * @see \wcf\system\comment\manager\AbstractCommentManager::canEdit() + */ + protected function canEdit($isOwner) { + return $isOwner; + } + + /** + * @see \wcf\system\comment\manager\AbstractCommentManager::canDelete() + */ + protected function canDelete($isOwner) { + return $isOwner; + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::supportsLike() + */ + public function supportsLike() { + return false; + } + + /** + * @see \wcf\system\comment\manager\ICommentManager::supportsReport() + */ + public function supportsReport() { + return false; + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 4887b1448f..7b3763e096 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2171,7 +2171,6 @@ Fehler sind beispielsweise: - @@ -2210,7 +2209,7 @@ Fehler sind beispielsweise: - + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 2af13aaa5b..4205787ccf 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2139,7 +2139,6 @@ Errors are: - @@ -2178,7 +2177,7 @@ Errors are: - + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index ac4dae266c..d425ce9717 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -507,7 +507,7 @@ CREATE TABLE wcf1_moderation_queue ( -- internal assignedUserID INT(10) NULL, status TINYINT(1) NOT NULL DEFAULT 0, - comment TEXT, + comments SMALLINT(5) NOT NULL DEFAULT 0, lastChangeTime INT(10) NOT NULL DEFAULT 0, -- additional data, e.g. message if reporting content