Changes
[moodle.git] / index.php
CommitLineData
f9903ed0 1<? // $Id$
2 // index.php - the front page.
3
4 require("config.php");
30e1a2ee 5 include("course/lib.php");
693c02d0 6 include("mod/reading/lib.php");
f93f848a 7 include("mod/forum/lib.php");
f9903ed0 8
8553b700 9 if (! $site = get_site()) {
f9903ed0 10 redirect("$CFG->wwwroot/admin/");
11 }
12
79a69a3a 13 if (isset($USER->id)) {
a325bd2b 14 $headerbutton = update_course_icon($site->id);
15 } else {
ed5ab9f7 16 $headerbutton = "<FONT SIZE=2><A HREF=\"login/\">".get_string("login")."</A></FONT>";
a325bd2b 17 }
c8138d90 18 print_header("$site->fullname", "$site->fullname", "", "",
de973a18 19 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
a325bd2b 20 true, $headerbutton);
f9903ed0 21
3054741a 22
f9903ed0 23?>
24
3054741a 25
f9903ed0 26<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
27 <TR>
7493ca91 28 <TD VALIGN="TOP" NOWRAP>
94361e02 29 <?
30
31 $sections = get_all_sections($site->id);
e4b5c8c0 32
94361e02 33 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {
e4b5c8c0 34
94361e02 35 if ($sections[0]->sequence or isediting($site->id)) {
36 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
37 print_simple_box(get_string("mainmenu"), "CENTER", "100%", "$THEME->cellheading");
38 }
39
40 if ($sections[0]->sequence) {
41 print_section($site->id, $sections[0], $mods, $modnamesused, true);
693c02d0 42 }
94361e02 43
2c309dc2 44 if (isediting($site->id)) {
94361e02 45 echo "<DIV ALIGN=right>";
46 popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=",
47 $modnames, "section0", "", "Add...");
48 echo "</DIV>";
b7b6fef9 49 }
d66615eb 50
51 if ($site->newsitems > 0 ) {
52 print_simple_box(get_string("courses"), "CENTER", "100%", "$THEME->cellheading");
53 print_all_courses($cat=1, "minimal", 10);
54 }
9368336b 55 echo "<IMG SRC=\"pix/spacer.gif\" WIDTH=200 HEIGHT=0><BR>";
693c02d0 56 }
57
a166f060 58 if (isadmin()) {
74c6a7f9 59 print_admin_links($site->id);
a166f060 60 }
f9903ed0 61 ?>
62
63 </TD>
64
5eec8324 65 <TD WIDTH="70%" VALIGN="TOP">
b5fe4c93 66 <? if ($site->newsitems == 0 ) {
ed5ab9f7 67 print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
d887b5a7 68 echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
d887b5a7 69 print_all_courses();
70
71 } else {
11b0c469 72 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
73 error("Could not find or create a main news forum for the site");
30e1a2ee 74 }
75
79a69a3a 76 if (isset($USER->id)) {
501cdbd8 77 $SESSION->fromdiscussion = "$CFG->wwwroot";
1fee73fe 78 save_session("SESSION");
07e1f189 79 if (forum_is_subscribed($USER->id, $newsforum->id)) {
ed5ab9f7 80 $subtext = get_string("unsubscribe", "forum");
30e1a2ee 81 } else {
ed5ab9f7 82 $subtext = get_string("subscribe", "forum");
30e1a2ee 83 }
84 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
ed5ab9f7 85 <TD>".get_string("sitenews")."</TD>
30e1a2ee 86 <TD ALIGN=RIGHT><FONT SIZE=1>
c2fbfe6d 87 <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
30e1a2ee 88 </TD></TR></TABLE>";
89 } else {
ed5ab9f7 90 $headertext = get_string("sitenews");
30e1a2ee 91 }
ed5ab9f7 92 print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
d887b5a7 93 echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
11b0c469 94 forum_print_latest_discussions($newsforum->id, $site->newsitems);
d887b5a7 95 }
f9903ed0 96 ?>
d887b5a7 97
f9903ed0 98 </TD>
5eec8324 99 <TD WIDTH="30%" VALIGN="TOP">
45d1cc4a 100 <?
2c309dc2 101 if (isediting($site->id)) {
45d1cc4a 102 $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
103 }
ed5ab9f7 104 print_simple_box($site->summary, "", "100%", $THEME->cellheading);
45d1cc4a 105 ?>
f9903ed0 106 </TD>
107 </TR>
108</TABLE>
109
3054741a 110<? include("$CFG->dirroot/theme/$CFG->theme/footer.html"); ?>
f9903ed0 111
112<P ALIGN=center>
113<A WIDTH=85 HEIGHT=25 HREF="http://moodle.com/"><IMG SRC="pix/madewithmoodle.gif" BORDER=0></A>
114</P>
115