3 namespace wcf\system\user\notification\
object\type
;
5 use wcf\data\comment\Comment
;
6 use wcf\data\user\UserProfile
;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache
;
8 use wcf\system\comment\CommentHandler
;
9 use wcf\system\database\util\PreparedStatementConditionBuilder
;
10 use wcf\system\user\storage\UserStorageHandler
;
14 * Implements IMultiRecipientCommentUserNotificationObjectType::getRecipientIDs()
15 * for moderation queue comment user notification object types.
17 * @author Mathias Schmidt
18 * @copyright 2001-2019 WoltLab GmbH
19 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
20 * @package WoltLabSuite\Core\System\User\Notification\Object\Type
23 trait TMultiRecipientModerationQueueCommentUserNotificationObjectType
28 public function getRecipientIDs(Comment
$comment)
30 $objectTypeID = CommentHandler
::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue');
31 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
44 SELECT DISTINCT userID
45 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
74 " . $conditionBuilder;
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, static function (UserProfile
$userProfile) {
84 return $userProfile->getPermission('mod.general.canUseModeration');