$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';
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;
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);
}
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,
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);
+ }
+ }
}
?>
<?php
unset($options);
$options[0] = get_string("no");
- $options[1] = get_string("yes");
+ $options[1] = get_string('yesforever', 'forum');
+ $options[FORUM_INITIALSUBSCRIBE] = get_string('yesinitially', 'forum');
choose_from_menu($options, "forcesubscribe", $form->forcesubscribe, "");
- helpbutton("subscription", get_string("forcesubscribeq", "forum"), "forum");
+ helpbutton("subscription2", get_string("forcesubscribeq", "forum"), "forum");
?>
</td>
</tr>
<td align=right><p><b><?php print_string("subscription", "forum") ?>:</b></p></td>
<td>
<?php
- if ($forum->forcesubscribe) {
+ if (forum_is_forcesubscribed($forum->id)) {
print_string("everyoneissubscribed", "forum");
} else {
unset($options);
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)) {