Can now force subscribe INITIALLY, implementing suggestion by Howard in bug 1084
This commit is contained in:
@@ -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';
|
||||
|
||||
+3
-5
@@ -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);
|
||||
|
||||
|
||||
+8
-7
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+3
-2
@@ -106,9 +106,10 @@
|
||||
<?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>
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@
|
||||
<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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user