<? formerr($err["summary"]) ?>
</td>
</tr>
+<tr valign=top>
+ <td><P>Front page format:</td>
+ <td><?
+ $options = array("0" => "Show list of courses",
+ "1" => "1 news item",
+ "2" => "2 news items",
+ "3" => "3 news items",
+ "4" => "4 news items",
+ "5" => "5 news items",
+ "6" => "6 news items",
+ "7" => "7 news items",
+ "8" => "8 news items",
+ "9" => "9 news items",
+ "10" => "10 news items");
+ choose_from_menu ($options, "format", "$form->format");
+ formerr($err["format"]);
+ ?>
+ </td>
+</tr>
<tr>
<td></td>
<td><input type="submit" value="Update the site"></td>
$form = $course;
} else {
$form->category = 0;
+ $form->format = 1;
}
print_header("Admin: Setting up site", "Administration: Setting up site",
optional_variable($cat, 1);
- if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
-
- foreach ($courses as $course) {
- print_course($course);
- echo "<BR>\n";
- }
-
- } else {
- echo "<H3>No courses have been defined yet</H3>";
- }
+ print_simple_box_start("CENTER", "80%");
+
+ print_all_courses($cat);
+
+ print_simple_box_end();
print_footer();
}
+function print_all_courses($cat=1) {
+
+ if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
+ foreach ($courses as $course) {
+ print_course($course);
+ echo "<BR>\n";
+ }
+
+ } else {
+ echo "<H3>No courses have been defined yet</H3>";
+ }
+}
+
+
function print_course($course) {
+ global $CFG;
+
if (! $site = get_record("course", "category", "0") ) {
error("Could not find a site!");
}
- print_simple_box_start("CENTER", "80%");
+ print_simple_box_start("CENTER", "100%");
echo "<TABLE WIDTH=100%>";
echo "<TR VALIGN=top>";
echo "<TD VALIGN=top WIDTH=50%>";
- echo "<P><FONT SIZE=3><B><A HREF=\"view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
+ echo "<P><FONT SIZE=3><B><A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t
WHERE u.id = t.user AND t.course = '$course->id'
ORDER BY t.authority ASC")) {
echo "<P><FONT SIZE=1>\n";
foreach ($teachers as $teacher) {
- echo "$course->teacher: <A HREF=\"../user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>";
+ echo "$course->teacher: <A HREF=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>";
}
echo "</FONT></P>";
}
if ($course->guest or ($course->password == "")) {
- echo "<A TITLE=\"Guest user allowed\" HREF=\"view.php?id=$course->id\">";
- echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"../user/user.gif\"></A> ";
+ echo "<A TITLE=\"Guest user allowed\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
+ echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/user/user.gif\"></A> ";
}
if ($course->password) {
- echo "<A TITLE=\"Requires a Course entry key\" HREF=\"view.php?id=$course->id\">";
- echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"../pix/i/key.gif\"></A>";
+ echo "<A TITLE=\"Requires a Course entry key\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
+ echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/pix/i/key.gif\"></A>";
}
<? print_simple_box("Main Menu", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
<LI>Home</LI>
+ <? if ($site->format > 0 ) { ?>
<LI><A TITLE="Available courses on this server" HREF="course/"><B>Courses</B></A><BR></LI>
<LI><A TITLE="Site-level Forums" HREF="mod/discuss/index.php?id=<?=$site->id?>">Forums</A></LI>
+ <? } ?>
<?
if ($readings = list_all_readings()) {
</TD>
<TD WIDTH="55%" VALIGN="TOP">
- <? print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
-
- <IMG HEIGHT=8 SRC="pix/spacer.gif" ALT=""><BR>
-
- <? include("mod/discuss/lib.php");
- forum_latest_topics();
+ <? if ($site->format == 0 ) {
+ print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading");
+ echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
+ include("course/lib.php");
+ print_all_courses();
+
+ } else {
+ print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
+ echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
+ include("mod/discuss/lib.php");
+ forum_latest_topics(0, $site->format);
+ }
?>
-
+
</TD>
<TD WIDTH="30%" VALIGN="TOP">
<?