Changes to allow choice of format on home page of site
authormartin <martin>
Mon, 10 Jun 2002 05:19:03 +0000 (05:19 +0000)
committermartin <martin>
Mon, 10 Jun 2002 05:19:03 +0000 (05:19 +0000)
admin/site.html
admin/site.php
course/index.php
course/lib.php
index.php

index 9bb796f..3b2ad69 100644 (file)
     <? formerr($err["summary"]) ?>
     </td>
 </tr>
     <? 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>
 <tr>
     <td></td>
        <td><input type="submit" value="Update the site"></td>
index d9e76d3..f9301ac 100644 (file)
@@ -49,6 +49,7 @@
         $form = $course;
     } else {
         $form->category = 0;
         $form = $course;
     } else {
         $form->category = 0;
+        $form->format = 1;
     }
 
     print_header("Admin: Setting up site", "Administration: Setting up site",
     }
 
     print_header("Admin: Setting up site", "Administration: Setting up site",
index e45944a..73a8754 100644 (file)
@@ -7,16 +7,11 @@
 
     optional_variable($cat, 1);
 
 
     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();
 
 
     print_footer();
 
index 0494795..7b59d9f 100644 (file)
@@ -115,35 +115,51 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
 }
 
 
 }
 
 
+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) {
 
 function print_course($course) {
 
+    global $CFG;
+
     if (! $site = get_record("course", "category", "0") ) {
         error("Could not find a site!");
     }
 
     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 "<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) {
     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 "</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>&nbsp;&nbsp;";
+        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>&nbsp;&nbsp;";
     }
     if ($course->password) {
     }
     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>";
     }
 
 
     }
 
 
index c5cd38a..3d08fe2 100644 (file)
--- a/index.php
+++ b/index.php
       <? print_simple_box("Main Menu", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
 
          <LI>Home</LI>
       <? 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>
       <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()) {
 
       <? 
          if ($readings = list_all_readings()) {
     </TD>
 
     <TD WIDTH="55%" VALIGN="TOP">
     </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"> 
       <? 
     </TD>
     <TD WIDTH="30%" VALIGN="TOP"> 
       <?