]> git.mjollnir.org Git - moodle.git/commitdiff
Changed listing of forums
authormartin <martin>
Sat, 20 Jul 2002 17:56:21 +0000 (17:56 +0000)
committermartin <martin>
Sat, 20 Jul 2002 17:56:21 +0000 (17:56 +0000)
mod/forum/db/mysql.sql
mod/forum/index.php
mod/forum/lib.php

index 9553e3b5f6151fce0319033ced32aebc304b2331..cb4e2b2b9dae2870562d32ddfec4fbe439af15cf 100644 (file)
@@ -7,7 +7,7 @@ CREATE TABLE forum (
   course int(10) unsigned NOT NULL default '0',
   type enum('discussion','news','general','social','eachuser','teacher') NOT NULL default 'general',
   name varchar(255) NOT NULL default '',
-  intro tinytext NOT NULL,
+  intro mediumtext NOT NULL,
   open tinyint(1) unsigned NOT NULL default '0',
   assessed tinyint(1) unsigned NOT NULL default '0',
   timemodified int(10) unsigned NOT NULL default '0',
index 3bf541b9c903bc2e46432eec4392709f9caf3d6a..dcb04a6ca485702dac77a6ba52d8339ae334d77a 100644 (file)
 
     $can_subscribe = (isstudent($course->id) || isteacher($course->id) || isadmin());
     if ($can_subscribe) {
-        $table->head = array ("Forum", "Description", "Topics", "Subscribed");
+        $newtable->head = array ("Forum", "Description", "Topics", "Subscribed");
     } else {
-        $table->head = array ("Forum", "Description", "Topics");
+        $newtable->head = array ("Forum", "Description", "Topics");
     }
-    $table->align = array ("LEFT", "LEFT", "CENTER", "CENTER");
+    $newtable->align = array ("LEFT", "LEFT", "CENTER", "CENTER");
+
 
     if ($forums = get_records("forum", "course", $id, "name ASC")) {
+        $table = $newtable;
+        foreach ($forums as $forum) {
+            if ($forum->type == "teacher") {
+                if (!isteacher($course->id)) {
+                    continue;
+                }
+            }
+            if ($forum->type == "eachuser" or $forum->type == "discussion") {
+                continue;    // Display these later on.
+            }       
+
+            $count = count_records("discuss", "forum", "$forum->id");
+
+            if ($can_subscribe) {
+                if (is_subscribed($USER->id, $forum->id)) {
+                    $subscribed = "YES";
+                } else {
+                    $subscribed = "NO";
+                }
+                $table->data[] = array ("<A HREF=\"view.php?f=$forum->id\">$forum->name</A>", 
+                                  "$forum->intro", 
+                                  "$count",
+                                  "<A HREF=\"subscribe.php?id=$forum->id\">$subscribed</A>");
+            } else {
+                $table->data[] = array ("<A HREF=\"view.php?f=$forum->id\">$forum->name</A>", 
+                                  "$forum->intro", 
+                                  "$count");
+            }
+        }
+        if ($table) {
+            print_heading("General Forums");
+            print_table($table);
+            $table = $newtable;
+        }
+
         foreach ($forums as $forum) {
             if ($forum->type == "teacher") {
                 if (!isteacher($course->id)) {
                     continue;
                 }
             }
+            if ($forum->type != "eachuser" and $forum->type != "discussion") {
+                continue;
+            }       
+
             $count = count_records("discuss", "forum", "$forum->id");
 
             if ($can_subscribe) {
                                   "$count");
             }
         }
+        if ($table) {
+            print_heading("Forums about course content");
+            print_table($table);
+        }
     }
 
-    print_table($table);
     echo "<DIV ALIGN=CENTER>";
     print_discussion_search_form($course, $search);
     echo "</DIV>";
index 76b33ec408514cb9ace449d9686a29c7c8f0870f..503b7db90221db350dd03ad06452f9347b5052cc 100644 (file)
@@ -106,7 +106,7 @@ function get_course_discussion_forum($courseid) {
         $forum->course = $courseid;
         $forum->type = "discussion";
         $forum->name = "Course Discussion";
-        $forum->intro= "Discussions about course content";
+        $forum->intro= "General discussions about course topics";
         $forum->open = 0;
         $forum->assessed = 1;
         $forum->timemodified = time();