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 {
27 public function getRecipientIDs(Comment $comment) {
28 $objectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue');
29 if ($comment->objectTypeID != $objectTypeID) {
33 // 1. fetch assigned user
34 // 2. fetch users who commented on the moderation queue entry
35 // 3. fetch users who responded to a comment on the moderation queue entry
38 FROM wcf".WCF_N."_moderation_queue
40 AND assignedUserID IS NOT NULL
44 SELECT DISTINCT userID
45 FROM wcf".WCF_N."_comment
51 SELECT DISTINCT comment_response.userID
52 FROM wcf".WCF_N."_comment_response comment_response
53 INNER JOIN wcf".WCF_N."_comment comment
54 ON (comment.commentID = comment_response.commentID)
55 WHERE comment.objectID = ?
56 AND comment.objectTypeID = ?
58 $statement = WCF::getDB()->prepareStatement($sql);
66 $recipientIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
68 // make sure that all users can (still) access the moderation queue entry
69 if (!empty($recipientIDs)) {
70 $conditionBuilder = new PreparedStatementConditionBuilder();
71 $conditionBuilder->add('userID IN (?)', [$recipientIDs]);
72 $conditionBuilder->add('queueID = ?', [$comment->objectID]);
73 $conditionBuilder->add('isAffected = ?', [1]);
75 FROM wcf".WCF_N."_moderation_queue_to_user
77 $statement = WCF::getDB()->prepareStatement($sql);
78 $statement->execute($conditionBuilder->getParameters());
79 $recipientIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
81 // make sure that all users (still) have permission to access moderation
83 UserStorageHandler::getInstance()->loadStorage($recipientIDs);
84 $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($recipientIDs);
85 $recipientIDs = array_keys(array_filter($userProfiles, function(UserProfile $userProfile) {
86 return $userProfile->getPermission('mod.general.canUseModeration');