Removed some debugging stuff
[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 {
2560d133 22 $headerbutton = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login/\">".get_string("login")."</A></FONT>";
4efeb8c3 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
3f8247c2 29 $side = 180;
19a55d67 30
f9903ed0 31?>
32
3054741a 33
f9903ed0 34<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
35 <TR>
670fddf1 36 <?
37 $sections = get_all_sections($site->id);
38
39 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {
40
41 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
42
43 if ($sections[0]->sequence or isediting($site->id)) {
44 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
45 print_simple_box(get_string("mainmenu"), "CENTER", $side, "$THEME->cellheading");
46 }
47
48 if ($sections[0]->sequence) {
49 print_section($site->id, $sections[0], $mods, $modnamesused, true, $side);
50 }
94361e02 51
670fddf1 52 if (isediting($site->id)) {
53 echo "<DIV ALIGN=right>";
54 popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=",
cf38360f 55 $modnames, "section0", "", get_string("add")."...");
670fddf1 56 echo "</DIV>";
57 }
d66615eb 58
670fddf1 59 if ($site->newsitems > 0 ) {
ba2e5d73 60 $categories = get_all_categories();
61 if (count($categories) > 1) {
62 print_simple_box(get_string("categories"), "CENTER", $side, "$THEME->cellheading");
63 print_course_categories($categories, "none", $side);
64 } else {
65 print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
66 $category = array_shift($categories);
67 print_all_courses($category->id, "minimal", 10);
68 }
670fddf1 69 }
70 print_spacer(1,$side);
71 }
72
73 if (isadmin()) {
74 if (!$firstcolumn) {
75 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
693c02d0 76 }
670fddf1 77 print_admin_links($site->id, $side);
78 }
79
80 if ($firstcolumn) {
81 echo "</TD>";
670fddf1 82 }
915d17bb 83 echo "<TD WIDTH=70% VALIGN=TOP>";
670fddf1 84
85 if ($site->newsitems == 0 ) {
86 print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
87 print_spacer(8,1);
ba2e5d73 88 print_all_courses("all");
670fddf1 89
90 } else {
91 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
92 error("Could not find or create a main news forum for the site");
a166f060 93 }
d887b5a7 94
670fddf1 95 if (isset($USER->id)) {
96 $SESSION->fromdiscussion = "$CFG->wwwroot";
97 save_session("SESSION");
98 if (forum_is_subscribed($USER->id, $newsforum->id)) {
99 $subtext = get_string("unsubscribe", "forum");
30e1a2ee 100 } else {
670fddf1 101 $subtext = get_string("subscribe", "forum");
30e1a2ee 102 }
670fddf1 103 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
104 <TD>".get_string("sitenews")."</TD>
105 <TD ALIGN=RIGHT><FONT SIZE=1>
106 <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
107 </TD></TR></TABLE>";
108 } else {
109 $headertext = get_string("sitenews");
d887b5a7 110 }
670fddf1 111 print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
112 print_spacer(8,1);
113 forum_print_latest_discussions($newsforum->id, $site->newsitems);
114 }
115
116 echo "</TD>";
117 echo "<TD WIDTH=30% VALIGN=TOP>";
118
119 if (isediting($site->id)) {
120 $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
121 }
122
123 print_simple_box($site->summary, "", "100%", $THEME->cellheading);
124 print_spacer(1,$side);
125 echo "</TD>";
126 ?>
d887b5a7 127
f9903ed0 128 </TR>
129</TABLE>
130
4a62a659 131<? print_footer("home"); // Please do not modify this line ?>
f9903ed0 132