// $table->align is an array of column alignments
// $table->data[] is an array of arrays containing the data.
- if ( $table->align) {
+ if ($table->align) {
foreach ($table->align as $key => $aa) {
if ($aa) {
$align[$key] = "ALIGN=\"$aa\"";
}
}
- echo "<BR>";
-
- print_simple_box_start("CENTER","","#FFFFFF",0);
- echo "<TABLE BORDER=0 valign=top align=center cellpadding=10 cellspacing=1>\n";
+ print_simple_box_start("CENTER", "80%", "#FFFFFF", 0);
+ echo "<TABLE WIDTH=100% BORDER=0 valign=top align=center cellpadding=10 cellspacing=1>\n";
if ($table->head) {
echo "<TR>";
$can_subscribe = (isstudent($course->id) || isteacher($course->id) || isadmin());
if ($can_subscribe) {
- $newtable->head = array ("Forum", "Description", "Topics", "Subscribed");
+ $table->head = array ("Forum", "Description", "Topics", "Subscribed");
} else {
- $newtable->head = array ("Forum", "Description", "Topics");
+ $table->head = array ("Forum", "Description", "Topics");
}
- $newtable->align = array ("LEFT", "LEFT", "CENTER", "CENTER");
+ $table->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;
- }
+ switch ($forum->type) {
+ case "discussion":
+ case "general":
+ case "eachuser":
+ $contentforums[] = $forum;
+ break;
+ case "teacher":
+ if (isteacher($course->id)) {
+ $generalforums[] = $forum;
+ }
+ break;
+ default:
+ $generalforums[] = $forum;
+ break;
}
- if ($forum->type == "eachuser" or $forum->type == "discussion") {
- continue; // Display these later on.
- }
+ }
+ }
+ if ($generalforums) {
+ foreach ($generalforums as $forum) {
$count = count_records("discuss", "forum", "$forum->id");
if ($can_subscribe) {
"$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;
- }
+ print_heading("General Forums");
+ print_table($table);
+ unset($table->data);
+ }
+ if ($contentforums) {
+ foreach ($contentforums as $forum) {
$count = count_records("discuss", "forum", "$forum->id");
if ($can_subscribe) {
"$count");
}
}
- if ($table) {
- print_heading("Forums about course content");
- print_table($table);
- }
+ print_heading("Course content");
+ print_table($table);
}
echo "<DIV ALIGN=CENTER>";