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 WoltLabSuite\Core\System\Moderation\Queue
21 class UserModerationQueueReportHandler extends AbstractModerationQueueHandler implements IModerationQueueReportHandler {
25 protected $className = User::class;
30 protected $definitionName = 'com.woltlab.wcf.moderation.report';
35 protected $objectType = 'com.woltlab.wcf.user';
40 public function assignQueues(array $queues) {
42 foreach ($queues as $queue) {
44 if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
48 $assignments[$queue->queueID] = $assignUser;
51 ModerationQueueManager::getInstance()->setAssignment($assignments);
57 public function canReport($objectID) {
58 if (!$this->isValid($objectID)) {
68 public function getContainerID($objectID) {
75 public function getReportedContent(ViewableModerationQueue $queue) {
76 /** @noinspection PhpParamsInspection */
77 WCF::getTPL()->assign([
78 'user' => new UserProfile($queue->getAffectedObject())
81 return WCF::getTPL()->fetch('moderationUser');
87 public function getReportedObject($objectID) {
88 if ($this->isValid($objectID)) {
89 return $this->getUser($objectID);
98 public function isValid($objectID) {
99 if ($this->getUser($objectID) === null) {
107 * Returns a user object by user id or null if user id is invalid.
109 * @param integer $objectID
112 protected function getUser($objectID) {
113 return UserRuntimeCache::getInstance()->getObject($objectID);
119 public function populate(array $queues) {
121 foreach ($queues as $object) {
122 $objectIDs[] = $object->objectID;
125 $users = UserRuntimeCache::getInstance()->getObjects($objectIDs);
126 foreach ($queues as $object) {
127 if ($users[$object->objectID] !== null) {
128 $object->setAffectedObject($users[$object->objectID]);
131 $object->setIsOrphaned();
139 public function canRemoveContent(ModerationQueue $queue) {
146 public function removeContent(ModerationQueue $queue, $message) {
147 throw new SystemException("it's not allowed to delete users using the moderation");