mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-48720 mod_forum: Only copy discussion preferences when moving posts
Rather than adding discussion preferences to a user based upon their subscription to the source forum, only respect any actively selected preference. That is to say that: * if a user has opted into a discussion and following a move would be unsubscribed, re-subscribe them; * if a user has opted out of a discussion and following a move would be subscribed once more, unsubscribe them; and * if a user has not made an active choice, follow the discussion preference for the target forum.
This commit is contained in:
parent
da0ef2e4cf
commit
9ddb376645
@ -118,14 +118,17 @@
|
||||
foreach ($potentialsubscribers as $subuser) {
|
||||
$userid = $subuser->id;
|
||||
$targetsubscription = \mod_forum\subscriptions::is_subscribed($userid, $forumto, null, $cmto);
|
||||
if (\mod_forum\subscriptions::is_subscribed($userid, $forum, $discussion->id)) {
|
||||
if (!$targetsubscription) {
|
||||
$subscriptionchanges[$userid] = $subscriptiontime;
|
||||
}
|
||||
} else {
|
||||
if ($targetsubscription) {
|
||||
$subscriptionchanges[$userid] = \mod_forum\subscriptions::FORUM_DISCUSSION_UNSUBSCRIBED;
|
||||
}
|
||||
$discussionsubscribed = \mod_forum\subscriptions::is_subscribed($userid, $forum, $discussion->id);
|
||||
$forumsubscribed = \mod_forum\subscriptions::is_subscribed($userid, $forum);
|
||||
|
||||
if ($forumsubscribed && !$discussionsubscribed && $targetsubscription) {
|
||||
// The user has opted out of this discussion and the move would cause them to receive notifications again.
|
||||
// Ensure they are unsubscribed from the discussion still.
|
||||
$subscriptionchanges[$userid] = \mod_forum\subscriptions::FORUM_DISCUSSION_UNSUBSCRIBED;
|
||||
} else if (!$forumsubscribed && $discussionsubscribed && !$targetsubscription) {
|
||||
// The user has opted into this discussion and would otherwise not receive the subscription after the move.
|
||||
// Ensure they are subscribed to the discussion still.
|
||||
$subscriptionchanges[$userid] = $subscriptiontime;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user