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-2018 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @package WoltLabSuite\Core\System\User\Notification\Object\Type
21 trait TMultiRecipientModerationQueueCommentUserNotificationObjectType {
25 public function getRecipientIDs(Comment $comment) {
26 $objectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue');
27 if ($comment->objectTypeID != $objectTypeID) {
31 // 1. fetch assigned user
32 // 2. fetch users who commented on the moderation queue entry
33 // 3. fetch users who responded to a comment on the moderation queue entry
36 FROM wcf".WCF_N."_moderation_queue
38 AND assignedUserID IS NOT NULL
42 SELECT DISTINCT userID
43 FROM wcf".WCF_N."_comment
49 SELECT DISTINCT comment_response.userID
50 FROM wcf".WCF_N."_comment_response comment_response
51 INNER JOIN wcf".WCF_N."_comment comment
52 ON (comment.commentID = comment_response.commentID)
53 WHERE comment.objectID = ?
54 AND comment.objectTypeID = ?
56 $statement = WCF::getDB()->prepareStatement($sql);
64 $recipientIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
66 // make sure that all users can (still) access the moderation queue entry
67 if (!empty($recipientIDs)) {
68 $conditionBuilder = new PreparedStatementConditionBuilder();
69 $conditionBuilder->add('userID IN (?)', [$recipientIDs]);
70 $conditionBuilder->add('queueID = ?', [$comment->objectID]);
71 $conditionBuilder->add('isAffected = ?', [1]);
73 FROM wcf".WCF_N."_moderation_queue_to_user
75 $statement = WCF::getDB()->prepareStatement($sql);
76 $statement->execute($conditionBuilder->getParameters());
77 $recipientIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
79 // make sure that all users (still) have permission to access moderation
81 UserStorageHandler::getInstance()->loadStorage($recipientIDs);
82 $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($recipientIDs);
83 $recipientIDs = array_keys(array_filter($userProfiles, function(UserProfile $userProfile) {
84 return $userProfile->getPermission('mod.general.canUseModeration');