2 namespace wcf\system\user\notification\event;
3 use wcf\data\moderation\queue\ModerationQueue;
4 use wcf\data\object\type\ObjectTypeCache;
5 use wcf\data\user\UserProfile;
6 use wcf\system\moderation\queue\ModerationQueueManager;
7 use wcf\system\moderation\queue\ModerationQueueReportManager;
11 * Provides a method to create a moderation queue entry for testing user notification
14 * @author Matthias Schmidt
15 * @copyright 2001-2018 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\User\Notification\Event
20 trait TTestableModerationQueueUserNotificationEvent {
22 * Creates a moderation queue entry for a reported user.
24 * @param UserProfile $reportedUser
25 * @param UserProfile $reportingUser
26 * @return ModerationQueue
28 public static function getTestUserModerationQueueEntry(UserProfile $reportedUser, UserProfile $reportingUser) {
29 $objectTypeID = ModerationQueueReportManager::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
31 $originalUser = WCF::getUser();
32 WCF::getSession()->changeUser($reportingUser->getDecoratedObject(), true);
34 ModerationQueueReportManager::getInstance()->addReport(
35 ObjectTypeCache::getInstance()->getObjectType($objectTypeID)->objectType,
36 $reportedUser->userID,
40 WCF::getSession()->changeUser($originalUser, true);
43 FROM wcf" . WCF_N . "_moderation_queue
44 WHERE objectTypeID = ?
46 $statement = WCF::getDB()->prepareStatement($sql);
47 $statement->execute([$objectTypeID, $reportedUser->userID]);
49 $moderationQueue = $statement->fetchObject(ModerationQueue::class);
51 ModerationQueueManager::getInstance()->setAssignment([$moderationQueue->queueID => true]);
53 return $moderationQueue;