]> git.mjollnir.org Git - moodle.git/commitdiff
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 9bb796fbf5a9f5399ddcabc8b7ee13334d823dac..3b2ad69efd55d47b70e1dfea3f9f30d8f96b9fcf 100644 (file)
     <? 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>
index d9e76d33d034e094673d421e33abb4aadff67242..f9301ac84faf628c6b0605f19ab4eeb506ac0690 100644 (file)
@@ -49,6 +49,7 @@
         $form = $course;
     } else {
         $form->category = 0;
+        $form->format = 1;
     }
 
     print_header("Admin: Setting up site", "Administration: Setting up site",
index e45944ae02b704ffcadef0b32233fda8dce2684f..73a875423118763cf0a354b9e4eedd26f01589da 100644 (file)
@@ -7,16 +7,11 @@
 
     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();
 
index 049479581b40beb2e7516dc1c1ec2ecf5c194a31..7b59d9f6993a0cc9cd0f21a78d9a9c777d908c81 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) {
 
+    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>&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) {
-        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 c5cd38a035a8bfe5bbebb584c9028c8602fb57b3..3d08fe2a0d6cc40d091d52f99f22d1b0b51b44a8 100644 (file)
--- a/index.php
+++ b/index.php
       <? 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"> 
       <?