2 namespace wcf\system\moderation\queue\report;
3 use wcf\data\moderation\queue\ModerationQueue;
4 use wcf\data\moderation\queue\ViewableModerationQueue;
5 use wcf\data\user\User;
6 use wcf\data\user\UserProfile;
7 use wcf\system\cache\runtime\UserRuntimeCache;
8 use wcf\system\exception\SystemException;
9 use wcf\system\moderation\queue\AbstractModerationQueueHandler;
10 use wcf\system\moderation\queue\ModerationQueueManager;
14 * An implementation of IModerationQueueReportHandler for user profiles.
17 * @copyright 2001-2016 WoltLab GmbH
18 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @package com.woltlab.wcf
20 * @subpackage system.moderation.queue
21 * @category Community Framework
23 class UserModerationQueueReportHandler extends AbstractModerationQueueHandler implements IModerationQueueReportHandler {
27 protected $className = User::class;
32 protected $definitionName = 'com.woltlab.wcf.moderation.report';
37 protected $objectType = 'com.woltlab.wcf.user';
42 public function assignQueues(array $queues) {
44 foreach ($queues as $queue) {
46 if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
50 $assignments[$queue->queueID] = $assignUser;
53 ModerationQueueManager::getInstance()->setAssignment($assignments);
59 public function canReport($objectID) {
60 if (!$this->isValid($objectID)) {
70 public function getContainerID($objectID) {
77 public function getReportedContent(ViewableModerationQueue $queue) {
78 /** @noinspection PhpParamsInspection */
79 WCF::getTPL()->assign([
80 'user' => new UserProfile($queue->getAffectedObject())
83 return WCF::getTPL()->fetch('moderationUser');
89 public function getReportedObject($objectID) {
90 if ($this->isValid($objectID)) {
91 return $this->getUser($objectID);
100 public function isValid($objectID) {
101 if ($this->getUser($objectID) === null) {
109 * Returns a user object by user id or null if user id is invalid.
111 * @param integer $objectID
114 protected function getUser($objectID) {
115 return UserRuntimeCache::getInstance()->getObject($objectID);
121 public function populate(array $queues) {
123 foreach ($queues as $object) {
124 $objectIDs[] = $object->objectID;
127 $users = UserRuntimeCache::getInstance()->getObjects($objectIDs);
128 foreach ($queues as $object) {
129 if ($users[$object->objectID] !== null) {
130 $object->setAffectedObject($users[$object->objectID]);
133 $object->setIsOrphaned();
141 public function canRemoveContent(ModerationQueue $queue) {
148 public function removeContent(ModerationQueue $queue, $message) {
149 throw new SystemException("it's not allowed to delete users using the moderation");