2 namespace wcf\system\user\notification\object\type;
3 use wcf\data\comment\Comment;
4 use wcf\data\user\UserProfile;
5 use wcf\system\cache\runtime\UserProfileRuntimeCache;
6 use wcf\system\comment\CommentHandler;
7 use wcf\system\database\util\PreparedStatementConditionBuilder;
8 use wcf\system\user\storage\UserStorageHandler;
12 * Implements IMultiRecipientCommentUserNotificationObjectType::getRecipientIDs()
13 * for moderation queue comment user notification object types.
15 * @author Mathias Schmidt
16 * @copyright 2001-2016 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @package com.woltlab.wcf
19 * @subpackage system.user.notification.object.type
20 * @category Community Framework
23 trait TMultiRecipientModerationQueueCommentUserNotificationObjectType {
25 * @see IMultiRecipientCommentUserNotificationObjectType::getRecipientIDs()
27 public function getRecipientIDs(Comment $comment) {
28 $objectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue');
29 if ($comment->objectTypeID != $objectTypeID) {
35 // 1. fetch assigned user
36 // 2. fetch users who commented on the moderation queue entry
37 // 3. fetch users who responded to a comment on the moderation queue entry
40 FROM wcf".WCF_N."_moderation_queue
42 AND assignedUserID IS NOT NULL
46 SELECT DISTINCT userID
47 FROM wcf".WCF_N."_comment
53 SELECT DISTINCT comment_response.userID
54 FROM wcf".WCF_N."_comment_response comment_response
55 INNER JOIN wcf".WCF_N."_comment comment
56 ON (comment.commentID = comment_response.commentID)
57 WHERE comment.objectID = ?
58 AND comment.objectTypeID = ?
60 $statement = WCF::getDB()->prepareStatement($sql);
68 while ($userID = $statement->fetchColumn()) {
69 $recipientIDs[] = $userID;
72 // make sure that all users can (still) access the moderation queue entry
73 if (!empty($recipientIDs)) {
74 $conditionBuilder = new PreparedStatementConditionBuilder();
75 $conditionBuilder->add('userID IN (?)', [$recipientIDs]);
76 $conditionBuilder->add('queueID = ?', [$comment->objectID]);
77 $conditionBuilder->add('isAffected = ?', [1]);
79 FROM wcf".WCF_N."_moderation_queue_to_user
81 $statement = WCF::getDB()->prepareStatement($sql);
82 $statement->execute($conditionBuilder->getParameters());
85 while ($userID = $statement->fetchColumn()) {
86 $recipientIDs[] = $userID;
89 // make sure that all users (still) have permission to access moderation
91 UserStorageHandler::getInstance()->loadStorage($recipientIDs);
92 $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($recipientIDs);
93 $recipientIDs = array_keys(array_filter($userProfiles, function(UserProfile $userProfile) {
94 return $userProfile->getPermission('mod.general.canUseModeration');