Doesn't matter if user isn't provided
[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
53bfe78c 13 if (isadmin()) {
14 if (moodle_needs_upgrading()) {
15 redirect("$CFG->wwwroot/admin/");
16 }
a325bd2b 17 $headerbutton = update_course_icon($site->id);
4efeb8c3 18 } else {
19 if (isset($USER->id)) {
20 $headerbutton = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A></FONT>";
21 } else {
22 $headerbutton = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login\">".get_string("login")."</A></FONT>";
23 }
a325bd2b 24 }
c8138d90 25 print_header("$site->fullname", "$site->fullname", "", "",
de973a18 26 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
a325bd2b 27 true, $headerbutton);
f9903ed0 28
3054741a 29
3f8247c2 30 $side = 180;
19a55d67 31
32
f9903ed0 33?>
34
3054741a 35
f9903ed0 36<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
37 <TR>
19a55d67 38 <TD WIDTH=<?=$side?> VALIGN="TOP" NOWRAP>
94361e02 39 <?
40
41 $sections = get_all_sections($site->id);
e4b5c8c0 42
94361e02 43 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {
e4b5c8c0 44
94361e02 45 if ($sections[0]->sequence or isediting($site->id)) {
46 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
19a55d67 47 print_simple_box(get_string("mainmenu"), "CENTER", $side, "$THEME->cellheading");
94361e02 48 }
49
50 if ($sections[0]->sequence) {
19a55d67 51 print_section($site->id, $sections[0], $mods, $modnamesused, true, $side);
693c02d0 52 }
94361e02 53
2c309dc2 54 if (isediting($site->id)) {
94361e02 55 echo "<DIV ALIGN=right>";
56 popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=",
57 $modnames, "section0", "", "Add...");
58 echo "</DIV>";
b7b6fef9 59 }
d66615eb 60
61 if ($site->newsitems > 0 ) {
62 print_simple_box(get_string("courses"), "CENTER", "100%", "$THEME->cellheading");
63 print_all_courses($cat=1, "minimal", 10);
64 }
19a55d67 65 print_spacer(1,$side);
693c02d0 66 }
67
a166f060 68 if (isadmin()) {
74c6a7f9 69 print_admin_links($site->id);
a166f060 70 }
f9903ed0 71 ?>
72
73 </TD>
74
5eec8324 75 <TD WIDTH="70%" VALIGN="TOP">
b5fe4c93 76 <? if ($site->newsitems == 0 ) {
ed5ab9f7 77 print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
19a55d67 78 print_spacer(8,1);
d887b5a7 79 print_all_courses();
80
81 } else {
11b0c469 82 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
83 error("Could not find or create a main news forum for the site");
30e1a2ee 84 }
85
79a69a3a 86 if (isset($USER->id)) {
501cdbd8 87 $SESSION->fromdiscussion = "$CFG->wwwroot";
1fee73fe 88 save_session("SESSION");
07e1f189 89 if (forum_is_subscribed($USER->id, $newsforum->id)) {
ed5ab9f7 90 $subtext = get_string("unsubscribe", "forum");
30e1a2ee 91 } else {
ed5ab9f7 92 $subtext = get_string("subscribe", "forum");
30e1a2ee 93 }
94 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
ed5ab9f7 95 <TD>".get_string("sitenews")."</TD>
30e1a2ee 96 <TD ALIGN=RIGHT><FONT SIZE=1>
c2fbfe6d 97 <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
30e1a2ee 98 </TD></TR></TABLE>";
99 } else {
ed5ab9f7 100 $headertext = get_string("sitenews");
30e1a2ee 101 }
ed5ab9f7 102 print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
19a55d67 103 print_spacer(8,1);
11b0c469 104 forum_print_latest_discussions($newsforum->id, $site->newsitems);
d887b5a7 105 }
f9903ed0 106 ?>
d887b5a7 107
f9903ed0 108 </TD>
5eec8324 109 <TD WIDTH="30%" VALIGN="TOP">
45d1cc4a 110 <?
2c309dc2 111 if (isediting($site->id)) {
45d1cc4a 112 $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
113 }
ed5ab9f7 114 print_simple_box($site->summary, "", "100%", $THEME->cellheading);
19a55d67 115 print_spacer(1,$side);
45d1cc4a 116 ?>
f9903ed0 117 </TD>
118 </TR>
119</TABLE>
120
4a62a659 121<? print_footer("home"); // Please do not modify this line ?>
f9903ed0 122