From: martin Date: Mon, 10 Jun 2002 05:19:03 +0000 (+0000) Subject: Changes to allow choice of format on home page of site X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d887b5a7bd00dcdf96d497aa69d7df93b3fa133f;p=moodle.git Changes to allow choice of format on home page of site --- diff --git a/admin/site.html b/admin/site.html index 9bb796fbf5..3b2ad69efd 100644 --- a/admin/site.html +++ b/admin/site.html @@ -18,6 +18,25 @@ + +

Front page format: + "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"]); + ?> + + diff --git a/admin/site.php b/admin/site.php index d9e76d33d0..f9301ac84f 100644 --- a/admin/site.php +++ b/admin/site.php @@ -49,6 +49,7 @@ $form = $course; } else { $form->category = 0; + $form->format = 1; } print_header("Admin: Setting up site", "Administration: Setting up site", diff --git a/course/index.php b/course/index.php index e45944ae02..73a8754231 100644 --- a/course/index.php +++ b/course/index.php @@ -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 "
\n"; - } - - } else { - echo "

No courses have been defined yet

"; - } + print_simple_box_start("CENTER", "80%"); + + print_all_courses($cat); + + print_simple_box_end(); print_footer(); diff --git a/course/lib.php b/course/lib.php index 049479581b..7b59d9f699 100644 --- a/course/lib.php +++ b/course/lib.php @@ -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 "
\n"; + } + + } else { + echo "

No courses have been defined yet

"; + } +} + + 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 ""; echo ""; echo "
"; - echo "

id\">$course->fullname

"; + echo "

wwwroot/course/view.php?id=$course->id\">$course->fullname

"; 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 "

\n"; foreach ($teachers as $teacher) { - echo "$course->teacher: id&course=$site->id\">$teacher->firstname $teacher->lastname
"; + echo "$course->teacher: wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname
"; } echo "

"; } if ($course->guest or ($course->password == "")) { - echo "id\">"; - echo "\"\"  "; + echo "wwwroot/course/view.php?id=$course->id\">"; + echo "\"\"wwwroot/user/user.gif\">  "; } if ($course->password) { - echo "id\">"; - echo "\"\""; + echo "wwwroot/course/view.php?id=$course->id\">"; + echo "\"\"wwwroot/pix/i/key.gif\">"; } diff --git a/index.php b/index.php index c5cd38a035..3d08fe2a0d 100644 --- a/index.php +++ b/index.php @@ -21,8 +21,10 @@ cellheading"); ?>
  • Home
  • + format > 0 ) { ?>
  • Courses
  • Forums
  • +
    - cellheading"); ?> - -
    - - format == 0 ) { + print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading"); + echo "\"\"
    "; + include("course/lib.php"); + print_all_courses(); + + } else { + print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading"); + echo "\"\"
    "; + include("mod/discuss/lib.php"); + forum_latest_topics(0, $site->format); + } ?> - +