]> git.mjollnir.org Git - moodle.git/commitdiff
Added new teacher forum. TABLE CHANGED: forum
authormartin <martin>
Thu, 4 Jul 2002 08:30:36 +0000 (08:30 +0000)
committermartin <martin>
Thu, 4 Jul 2002 08:30:36 +0000 (08:30 +0000)
course/topics.php
course/weeks.php
mod/forum/db/mysql.sql
mod/forum/index.php
mod/forum/lib.php
mod/forum/subscribe.php
mod/forum/view.php

index 912bcdabbd728f05c5358025a053355ef19029e0..42ea9fc1a2613ee0def41320ca2ab0136c796f57 100644 (file)
         } else {
             $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
         }
+        if ($teacherforum = get_course_teacher_forum($course->id)) {
+            $admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
+            $adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
+        }
 
         $admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
-        $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
+        $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course settings\">";
         $admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
         $adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
         $admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
index 506e4a0ee3ff1e3f78a69fef506ad85dc8db4593..870248b897a499e72c03192c6c82496f2c9dda08 100644 (file)
             $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
         }
 
+        if ($teacherforum = get_course_teacher_forum($course->id)) {
+            $admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
+            $adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
+        }
         $admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
         $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
         $admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
index aecc2d1c2b7c288e393dd5bd866e94f4516dcd07..9553e3b5f6151fce0319033ced32aebc304b2331 100644 (file)
@@ -5,7 +5,7 @@
 CREATE TABLE forum (
   id int(10) unsigned NOT NULL auto_increment,
   course int(10) unsigned NOT NULL default '0',
-  type enum('discussion','news','general','social','eachuser') NOT NULL default 'general',
+  type enum('discussion','news','general','social','eachuser','teacher') NOT NULL default 'general',
   name varchar(255) NOT NULL default '',
   intro tinytext NOT NULL,
   open tinyint(1) unsigned NOT NULL default '0',
index 99c887d38ed9abfe4670132e78b2d8461974df8f..c19ece594037550e159f5145898daf55005d02eb 100644 (file)
 
     if ($forums = get_records("forum", "course", $id, "name ASC")) {
         foreach ($forums as $forum) {
+            if ($forum->type == "teacher") {
+                if (!isteacher($course->id)) {
+                    continue;
+                }
+            }
             $count = count_records("discuss", "forum", "$forum->id");
 
             if ($can_subscribe) {
index 53631d6b71ce05191ea241781389dad34019af69..76b33ec408514cb9ace449d9686a29c7c8f0870f 100644 (file)
@@ -40,6 +40,8 @@ function user_can_post_discussion($forum) {
 
     if ($forum->type == "eachuser") {
         return (! user_has_posted_discussion($forum->id, $USER->id));
+    } else if ($forum->type == "teacher") {
+        return isteacher($forum->course);
     } else if (isteacher($forum->course)) {
         return true;
     } else {
@@ -113,6 +115,23 @@ function get_course_discussion_forum($courseid) {
     }
 }
 
+function get_course_teacher_forum($courseid) {
+    if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = 'teacher'")) {
+        return $forum;
+    } else {
+        // Doesn't exist, so create one now.
+        $forum->course = $courseid;
+        $forum->type = "teacher";
+        $forum->name = "Teacher Forum";
+        $forum->intro= "For teacher-only notes and discussion";
+        $forum->open = 0;
+        $forum->assessed = 0;
+        $forum->timemodified = time();
+        $forum->id = insert_record("forum", $forum);
+        return get_record_sql("SELECT * from forum WHERE id = '$forum->id'");
+    }
+}
+
 
 function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
     global $CFG, $USER;
index 987b20bf0c448062c7ef7cf778f2d4296391fb81..926213b816415bfdd63d9d53cda90b73b7f37c47 100644 (file)
         require_login();
     }
 
+    if ($forum->type == "teacher") {
+        if (!isteacher($course->id)) {
+            error("You must be a $course->teacher to subscribe to this forum");
+        }
+    }
+
+
     $returnto = go_back_to("index.php?id=$course->id");
 
     if ( is_subscribed($USER->id, $forum->id) ) {
index e4329e49d64b3f49d7dbbd690f7282af154abae0..2106c88cd7b874fb6b3d198099a5c335ba011cd9 100644 (file)
                        <A HREF=\"index.php?id=$course->id\">Forums</A> ->";
     }
 
+    if ($forum->type == "teacher") {
+        if (!isteacher($course->id)) {
+            error("You must be a $course->teacher to view this forum");
+        }
+    }
+
+
     add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
 
     print_header("$course->shortname: $forum->name", "$course->fullname",