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\UserList;
7 use wcf\data\user\UserProfile;
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-2015 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 {
25 * @see \wcf\system\moderation\queue\AbstractModerationQueueHandler::$className
27 protected $className = 'wcf\data\user\User';
30 * @see \wcf\system\moderation\queue\AbstractModerationQueueHandler::$definitionName
32 protected $definitionName = 'com.woltlab.wcf.moderation.report';
35 * @see \wcf\system\moderation\queue\AbstractModerationQueueHandler::$objectType
37 protected $objectType = 'com.woltlab.wcf.user';
41 * @var array<\wcf\data\user\User>
43 protected static $users = array();
46 * @see \wcf\system\moderation\queue\IModerationQueueHandler::assignQueues()
48 public function assignQueues(array $queues) {
49 $assignments = array();
50 foreach ($queues as $queue) {
52 if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
56 $assignments[$queue->queueID] = $assignUser;
59 ModerationQueueManager::getInstance()->setAssignment($assignments);
63 * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::canReport()
65 public function canReport($objectID) {
66 if (!$this->isValid($objectID)) {
74 * @see \wcf\system\moderation\queue\IModerationQueueHandler::getContainerID()
76 public function getContainerID($objectID) {
81 * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::getReportedContent()
83 public function getReportedContent(ViewableModerationQueue $queue) {
84 WCF::getTPL()->assign(array(
85 'user' => new UserProfile($queue->getAffectedObject())
88 return WCF::getTPL()->fetch('moderationUser');
92 * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::getReportedObject()
94 public function getReportedObject($objectID) {
95 if ($this->isValid($objectID)) {
96 return $this->getUser($objectID);
103 * @see \wcf\system\moderation\queue\IModerationQueueHandler::isValid()
105 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 integer $objectID
117 * @return \wcf\data\user\User
119 protected function getUser($objectID) {
120 if (!array_key_exists($objectID, self::$users)) {
121 self::$users[$objectID] = new User($objectID);
122 if (!self::$users[$objectID]->userID) {
123 self::$users[$objectID] = null;
127 return self::$users[$objectID];
131 * @see \wcf\system\moderation\queue\IModerationQueueHandler::populate()
133 public function populate(array $queues) {
134 $objectIDs = array();
135 foreach ($queues as $object) {
136 $objectIDs[] = $object->objectID;
140 $userList = new UserList();
141 $userList->setObjectIDs($objectIDs);
142 $userList->readObjects();
143 $users = $userList->getObjects();
145 foreach ($queues as $object) {
146 if (isset($users[$object->objectID])) {
147 $object->setAffectedObject($users[$object->objectID]);
150 $object->setIsOrphaned();
156 * @see \wcf\system\moderation\queue\IModerationQueueHandler::canRemoveContent()
158 public function canRemoveContent(ModerationQueue $queue) {
163 * @see \wcf\system\moderation\queue\IModerationQueueHandler::removeContent()
165 public function removeContent(ModerationQueue $queue, $message) {
166 throw new SystemException("it's not allowed to delete users using the moderation");