]> git.mjollnir.org Git - moodle.git/commitdiff
Changes to activate the "force subscribe" option on the Site News forum.
authormoodler <moodler>
Sat, 29 Mar 2003 03:39:56 +0000 (03:39 +0000)
committermoodler <moodler>
Sat, 29 Mar 2003 03:39:56 +0000 (03:39 +0000)
By default it is OFF, but if it is turned on, then site news is emailed
to ALL enrolled students and ALL current teachers.

lib/datalib.php
mod/forum/lib.php

index 8e983aa12df9f45b13a4e042dd8efa0b275f8d38..e5755fc82fb33a1579a6dbc350fe797e420f0e30 100644 (file)
@@ -818,23 +818,35 @@ function get_teacher($courseid) {
     }
 }
 
-function get_course_students($courseid, $sort="u.lastaccess DESC") {
+function get_course_students($courseid=0, $sort="u.lastaccess DESC") {
 /// Returns list of all students in this course
+/// if courseid = 0 then return ALL students in all courses
 
     global $CFG;
 
+    $selectcourse = "";
+    if (!empty($courseid)) {
+        $selectcourse = "s.course = '$courseid' AND ";
+    }
+
     return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s
-                            WHERE s.course = '$courseid' AND s.userid = u.id AND u.deleted = '0'
+                            WHERE $selectcourse s.userid = u.id AND u.deleted = '0'
                             ORDER BY $sort");
 }
 
-function get_course_teachers($courseid, $sort="t.authority ASC") {
+function get_course_teachers($courseid=0, $sort="t.authority ASC") {
 /// Returns list of all teachers in this course
+/// if courseid = 0 then return ALL teachers in all courses
 
     global $CFG;
 
+    $selectcourse = "";
+    if (!empty($courseid)) {
+        $selectcourse = "t.course = '$courseid' AND ";
+    }
+
     return get_records_sql("SELECT u.*,t.authority,t.role FROM {$CFG->prefix}user u, {$CFG->prefix}user_teachers t
-                            WHERE t.course = '$courseid' AND t.userid = u.id AND u.deleted = '0'
+                            WHERE $selectcourse t.userid = u.id AND u.deleted = '0'
                             ORDER BY $sort");
 }
 
@@ -858,7 +870,6 @@ function get_course_users($courseid, $sort="u.lastaccess DESC") {
 ///                            ORDER BY $sort");
 }
 
-
 function get_users_search($search, $sort="u.firstname ASC") {
     global $CFG;
 
index 96e3a1dc02ba602882af7cc9575e07469b2e6641..76fbcc1445140254926572f2b3019def17a34972 100644 (file)
@@ -619,9 +619,11 @@ function forum_subscribed_users($course, $forum) {
 /// Returns list of user objects that are subscribed to this forum
     global $CFG;
 
-    if ($course->category) {   // normal course
-        if ($forum->forcesubscribe) {
+    if ($forum->forcesubscribe) {
+        if ($course->category) {
             return get_course_users($course->id);
+        } else {
+            return get_course_users(0);   // ALL SITE USERS
         }
     }
     return get_records_sql("SELECT u.* 
@@ -650,15 +652,16 @@ function forum_get_course_forum($courseid, $type) {
         switch ($forum->type) {
             case "news":
                 $forum->name  = get_string("namenews", "forum");
+                $forum->forcesubscribe = 1;
+                $forum->intro = get_string("intronews", "forum");
+                $forum->open = 1;   // 0 - no, 1 - posts only, 2 - discuss and post
+                $forum->assessed = 0;
                 if ($site = get_site()) {
                     if ($courseid == $site->id) {
                         $forum->name  = get_string("sitenews");
+                        $forum->forcesubscribe = 0;
                     }
                 }
-                $forum->intro = get_string("intronews", "forum");
-                $forum->open = 1;   // 0 - no, 1 - posts only, 2 - discuss and post
-                $forum->assessed = 0;
-                $forum->forcesubscribe = 1;
                 break;
             case "social":
                 $forum->name  = get_string("namesocial", "forum");