From 4a913724d0daec26bdee9174300f2d29decc868a Mon Sep 17 00:00:00 2001 From: Gilles-Philippe Leblanc Date: Wed, 6 Feb 2013 08:28:55 -0500 Subject: [PATCH] MDL-32125 mod_forum: Updating subscription mode not reflecting subscribers --- mod/forum/lib.php | 8 ++++++++ mod/forum/subscribe.php | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 149aa8770e9..dc06db964a3 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -212,6 +212,14 @@ function forum_update_instance($forum, $mform) { $DB->update_record('forum', $forum); + $modcontext = context_module::instance($forum->coursemodule); + if (($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) && ($oldforum->forcesubscribe <> $forum->forcesubscribe)) { + $users = forum_get_potential_subscribers($modcontext, 0, 'u.id, u.email', ''); + foreach ($users as $user) { + forum_subscribe($user->id, $forum->id); + } + } + forum_grade_item_update($forum); return true; diff --git a/mod/forum/subscribe.php b/mod/forum/subscribe.php index 7ea5cd7a3a2..1bd52774f61 100644 --- a/mod/forum/subscribe.php +++ b/mod/forum/subscribe.php @@ -111,6 +111,12 @@ if (!is_null($mode) and has_capability('mod/forum:managesubscriptions', $context redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1); break; case FORUM_INITIALSUBSCRIBE : // 2 + if ($forum->forcesubscribe <> FORUM_INITIALSUBSCRIBE) { + $users = forum_get_potential_subscribers($context, 0, 'u.id, u.email', ''); + foreach ($users as $user) { + forum_subscribe($user->id, $forum->id); + } + } forum_forcesubscribe($forum->id, FORUM_INITIALSUBSCRIBE); redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1); break;