]> git.mjollnir.org Git - moodle.git/commitdiff
Can now force subscribe INITIALLY, implementing suggestion by Howard in bug 1084
authorgustav_delius <gustav_delius>
Sun, 29 Aug 2004 19:17:27 +0000 (19:17 +0000)
committergustav_delius <gustav_delius>
Sun, 29 Aug 2004 19:17:27 +0000 (19:17 +0000)
lang/en/forum.php
lib/moodlelib.php
mod/forum/lib.php
mod/forum/mod.html
mod/forum/post.html
mod/forum/subscribe.php

index 8ef3c0420066656a6658706426c0fae085072272..a5f51c5ab4c014c5ae68ea6a9318817cb7c4d3b4 100644 (file)
@@ -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';
index d77f565e5e4d990ccde5a961d952714ff41d23fa..72dfc073bb9d471b2c529dd70dbc5b77b6a12a39 100644 (file)
@@ -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);
 
index cc5754b1fde78d32230a0db828d560f48a512a9b..8b7e688c992a00d5cc48fbadfff67736527e3bf6 100644 (file)
@@ -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);
+        }
+    }
 }
 
 ?>
index 35217c46726485258e02c5b3ade3f0a4b1640908..12ef1e2bec7eb01a74ead8955a6c9cc5fd6c75a5 100644 (file)
         <?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>
index 9391f6e32bf85f7d5395e64a60d1ae7520f9262e..398b0bc7e974948f9b5dab41bb24a4a7efaf12fa 100644 (file)
@@ -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);
index 84704423d047e226b6c4df8df3981e58fc47280e..de9ece0a7e3bebee263d98f3f14ff00069cc9251 100644 (file)
@@ -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)) {