Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changes to allow choice of format on home page of site

  • Loading branch information...
commit d887b5a7bd00dcdf96d497aa69d7df93b3fa133f 1 parent b5460e6
martin authored
19 admin/site.html
@@ -18,6 +18,25 @@
18 18 <? formerr($err["summary"]) ?>
19 19 </td>
20 20 </tr>
  21 +<tr valign=top>
  22 + <td><P>Front page format:</td>
  23 + <td><?
  24 + $options = array("0" => "Show list of courses",
  25 + "1" => "1 news item",
  26 + "2" => "2 news items",
  27 + "3" => "3 news items",
  28 + "4" => "4 news items",
  29 + "5" => "5 news items",
  30 + "6" => "6 news items",
  31 + "7" => "7 news items",
  32 + "8" => "8 news items",
  33 + "9" => "9 news items",
  34 + "10" => "10 news items");
  35 + choose_from_menu ($options, "format", "$form->format");
  36 + formerr($err["format"]);
  37 + ?>
  38 + </td>
  39 +</tr>
21 40 <tr>
22 41 <td></td>
23 42 <td><input type="submit" value="Update the site"></td>
1  admin/site.php
@@ -49,6 +49,7 @@
49 49 $form = $course;
50 50 } else {
51 51 $form->category = 0;
  52 + $form->format = 1;
52 53 }
53 54
54 55 print_header("Admin: Setting up site", "Administration: Setting up site",
15 course/index.php
@@ -7,16 +7,11 @@
7 7
8 8 optional_variable($cat, 1);
9 9
10   - if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
11   -
12   - foreach ($courses as $course) {
13   - print_course($course);
14   - echo "<BR>\n";
15   - }
16   -
17   - } else {
18   - echo "<H3>No courses have been defined yet</H3>";
19   - }
  10 + print_simple_box_start("CENTER", "80%");
  11 +
  12 + print_all_courses($cat);
  13 +
  14 + print_simple_box_end();
20 15
21 16 print_footer();
22 17
30 course/lib.php
@@ -115,35 +115,51 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
115 115 }
116 116
117 117
  118 +function print_all_courses($cat=1) {
  119 +
  120 + if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
  121 + foreach ($courses as $course) {
  122 + print_course($course);
  123 + echo "<BR>\n";
  124 + }
  125 +
  126 + } else {
  127 + echo "<H3>No courses have been defined yet</H3>";
  128 + }
  129 +}
  130 +
  131 +
118 132 function print_course($course) {
119 133
  134 + global $CFG;
  135 +
120 136 if (! $site = get_record("course", "category", "0") ) {
121 137 error("Could not find a site!");
122 138 }
123 139
124   - print_simple_box_start("CENTER", "80%");
  140 + print_simple_box_start("CENTER", "100%");
125 141
126 142 echo "<TABLE WIDTH=100%>";
127 143 echo "<TR VALIGN=top>";
128 144 echo "<TD VALIGN=top WIDTH=50%>";
129   - echo "<P><FONT SIZE=3><B><A HREF=\"view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
  145 + echo "<P><FONT SIZE=3><B><A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
130 146 if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t
131 147 WHERE u.id = t.user AND t.course = '$course->id'
132 148 ORDER BY t.authority ASC")) {
133 149
134 150 echo "<P><FONT SIZE=1>\n";
135 151 foreach ($teachers as $teacher) {
136   - echo "$course->teacher: <A HREF=\"../user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>";
  152 + echo "$course->teacher: <A HREF=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>";
137 153 }
138 154 echo "</FONT></P>";
139 155 }
140 156 if ($course->guest or ($course->password == "")) {
141   - echo "<A TITLE=\"Guest user allowed\" HREF=\"view.php?id=$course->id\">";
142   - echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"../user/user.gif\"></A>&nbsp;&nbsp;";
  157 + echo "<A TITLE=\"Guest user allowed\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
  158 + echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/user/user.gif\"></A>&nbsp;&nbsp;";
143 159 }
144 160 if ($course->password) {
145   - echo "<A TITLE=\"Requires a Course entry key\" HREF=\"view.php?id=$course->id\">";
146   - echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"../pix/i/key.gif\"></A>";
  161 + echo "<A TITLE=\"Requires a Course entry key\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
  162 + echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/pix/i/key.gif\"></A>";
147 163 }
148 164
149 165
22 index.php
@@ -21,8 +21,10 @@
21 21 <? print_simple_box("Main Menu", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
22 22
23 23 <LI>Home</LI>
  24 + <? if ($site->format > 0 ) { ?>
24 25 <LI><A TITLE="Available courses on this server" HREF="course/"><B>Courses</B></A><BR></LI>
25 26 <LI><A TITLE="Site-level Forums" HREF="mod/discuss/index.php?id=<?=$site->id?>">Forums</A></LI>
  27 + <? } ?>
26 28
27 29 <?
28 30 if ($readings = list_all_readings()) {
@@ -50,14 +52,20 @@
50 52 </TD>
51 53
52 54 <TD WIDTH="55%" VALIGN="TOP">
53   - <? print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
54   -
55   - <IMG HEIGHT=8 SRC="pix/spacer.gif" ALT=""><BR>
56   -
57   - <? include("mod/discuss/lib.php");
58   - forum_latest_topics();
  55 + <? if ($site->format == 0 ) {
  56 + print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading");
  57 + echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
  58 + include("course/lib.php");
  59 + print_all_courses();
  60 +
  61 + } else {
  62 + print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
  63 + echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
  64 + include("mod/discuss/lib.php");
  65 + forum_latest_topics(0, $site->format);
  66 + }
59 67 ?>
60   -
  68 +
61 69 </TD>
62 70 <TD WIDTH="30%" VALIGN="TOP">
63 71 <?

0 comments on commit d887b5a

Please sign in to comment.
Something went wrong with that request. Please try again.