3 namespace wcf\system\moderation\queue\report;
5 use wcf\data\moderation\queue\ModerationQueue;
6 use wcf\data\moderation\queue\ViewableModerationQueue;
7 use wcf\data\user\User;
8 use wcf\data\user\UserProfile;
9 use wcf\system\cache\runtime\UserRuntimeCache;
10 use wcf\system\exception\SystemException;
11 use wcf\system\moderation\queue\AbstractModerationQueueHandler;
12 use wcf\system\moderation\queue\ModerationQueueManager;
16 * An implementation of IModerationQueueReportHandler for user profiles.
19 * @copyright 2001-2019 WoltLab GmbH
20 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
21 * @package WoltLabSuite\Core\System\Moderation\Queue
23 class UserModerationQueueReportHandler extends AbstractModerationQueueHandler implements IModerationQueueReportHandler
28 protected $className = User::class;
33 protected $definitionName = 'com.woltlab.wcf.moderation.report';
38 protected $objectType = 'com.woltlab.wcf.user';
43 public function assignQueues(array $queues)
46 foreach ($queues as $queue) {
48 if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
52 $assignments[$queue->queueID] = $assignUser;
55 ModerationQueueManager::getInstance()->setAssignment($assignments);
61 public function canReport($objectID)
63 if (!$this->isValid($objectID)) {
73 public function getContainerID($objectID)
81 public function getReportedContent(ViewableModerationQueue $queue)
83 /** @noinspection PhpParamsInspection */
84 WCF::getTPL()->assign([
85 'user' => new UserProfile($queue->getAffectedObject()),
88 return WCF::getTPL()->fetch('moderationUser');
94 public function getReportedObject($objectID)
96 if ($this->isValid($objectID)) {
97 return $this->getUser($objectID);
104 public function isValid($objectID)
106 if ($this->getUser($objectID) === null) {
114 * Returns a user object by user id or null if user id is invalid.
116 * @param int $objectID
119 protected function getUser($objectID)
121 return UserRuntimeCache::getInstance()->getObject($objectID);
127 public function populate(array $queues)
130 foreach ($queues as $object) {
131 $objectIDs[] = $object->objectID;
134 $users = UserRuntimeCache::getInstance()->getObjects($objectIDs);
135 foreach ($queues as $object) {
136 if ($users[$object->objectID] !== null) {
137 $object->setAffectedObject($users[$object->objectID]);
139 $object->setIsOrphaned();
147 public function canRemoveContent(ModerationQueue $queue)
155 public function removeContent(ModerationQueue $queue, $message)
157 throw new SystemException("it's not allowed to delete users using the moderation");