From: gustav_delius Date: Sun, 29 Aug 2004 19:17:27 +0000 (+0000) Subject: Can now force subscribe INITIALLY, implementing suggestion by Howard in bug 1084 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7b5944cdb30153d5bb31a394a42954a52fbc55e1;p=moodle.git Can now force subscribe INITIALLY, implementing suggestion by Howard in bug 1084 --- diff --git a/lang/en/forum.php b/lang/en/forum.php index 8ef3c04200..a5f51c5ab4 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -150,6 +150,8 @@ $string['subscriptions'] = 'Subscriptions'; $string['unsubscribe'] = 'Unsubscribe from this forum'; $string['unsubscribed'] = 'Unsubscribed'; $string['unsubscribeshort'] = 'Unsubscribe'; +$string['yesinitially'] = 'Yes, initially'; +$string['yesforever'] = 'Yes, forever'; $string['youratedthis'] = 'You rated this'; $string['yournewtopic'] = 'Your new discussion topic'; $string['yourreply'] = 'Your reply'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d77f565e5e..72dfc073bb 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -879,6 +879,7 @@ function unenrol_student($userid, $courseid=0) { function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $timeend=0) { /// Add a teacher to a given course + global $CFG; if ($teacher = get_record('user_teachers', 'userid', $userid, 'course', $courseid)) { $newteacher = NULL; @@ -918,11 +919,8 @@ function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $ti delete_records("user_students", "userid", $userid, "course", $courseid); // Unenrol as student /// Add forum subscriptions for new users - if ($forums = get_records('forum', 'course', $courseid, 'forcesubscribe', 2)) { - foreach ($forums as $forum) { - forum_subscribe($userid, $forum->id); - } - } + require_once('../mod/forum/lib.php'); + forum_add_user($userid, $courseid); return insert_record("user_teachers", $teacher); diff --git a/mod/forum/lib.php b/mod/forum/lib.php index cc5754b1fd..8b7e688c99 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1214,14 +1214,10 @@ function forum_subscribed_users($course, $forum, $groupid=0) { } if (forum_is_forcesubscribed($forum->id)) { - if ($course->category) { - if ($forum->type == "teacher") { - return get_course_teachers($course->id); // Only teachers can be subscribed to teacher forums - } else { - return get_course_users($course->id); // Otherwise get everyone in the course - } + if ($forum->type == "teacher") { + return get_course_teachers($course->id); // Only teachers can be subscribed to teacher forums } else { - return get_site_users(); + return get_course_users($course->id); // Otherwise get everyone in the course } } return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop, @@ -2849,6 +2845,11 @@ function forum_add_user($userid, $courseid) { forum_subscribe($userid, $forum->id); } } + if ($forums = get_records_select('forum', "course = '".SITEID."' AND forcesubscribe = '2'")) { + foreach ($forums as $forum) { + forum_subscribe($userid, $forum->id); + } + } } ?> diff --git a/mod/forum/mod.html b/mod/forum/mod.html index 35217c4672..12ef1e2bec 100644 --- a/mod/forum/mod.html +++ b/mod/forum/mod.html @@ -106,9 +106,10 @@ forcesubscribe, ""); - helpbutton("subscription", get_string("forcesubscribeq", "forum"), "forum"); + helpbutton("subscription2", get_string("forcesubscribeq", "forum"), "forum"); ?> diff --git a/mod/forum/post.html b/mod/forum/post.html index 9391f6e32b..398b0bc7e9 100644 --- a/mod/forum/post.html +++ b/mod/forum/post.html @@ -59,7 +59,7 @@

:

forcesubscribe) { + if (forum_is_forcesubscribed($forum->id)) { print_string("everyoneissubscribed", "forum"); } else { unset($options); diff --git a/mod/forum/subscribe.php b/mod/forum/subscribe.php index 84704423d0..de9ece0a7e 100644 --- a/mod/forum/subscribe.php +++ b/mod/forum/subscribe.php @@ -7,10 +7,10 @@ require_variable($id); // The forum to subscribe or unsubscribe to optional_variable($force); // Force everyone to be subscribed to this forum? - optional_variable($user); // Force everyone to be subscribed to this forum? + optional_variable($user); if (isguest()) { - error("Guests are not allowed to subscribe to posts.", $_SERVER["HTTP_REFERER"]); + error("Guests are not allowed to subscribe to forums.", $_SERVER["HTTP_REFERER"]); } if (! $forum = get_record("forum", "id", $id)) {