It's now possible to choose a documentation language on the fly!
[moodle.git] / index.php
CommitLineData
657423c8 1<?PHP // $Id$
2 // index.php - the front page.
f9903ed0 3
4 require("config.php");
8ea30094 5 require("course/lib.php");
6 require("mod/resource/lib.php");
7 require("mod/forum/lib.php");
f9903ed0 8
8553b700 9 if (! $site = get_site()) {
88491cac 10 redirect("$CFG->wwwroot/admin/index.php");
f9903ed0 11 }
12
53bfe78c 13 if (isadmin()) {
14 if (moodle_needs_upgrading()) {
88491cac 15 redirect("$CFG->wwwroot/admin/index.php");
53bfe78c 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 {
76dbe04f 22 $headerbutton = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A></FONT>";
4efeb8c3 23 }
a325bd2b 24 }
8cea3a39 25 print_header("$site->fullname", "$site->fullname", "home", "",
de973a18 26 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
f0207959 27 true, "", $headerbutton);
f9903ed0 28
469e5eb1 29 $side = 175;
19a55d67 30
f9903ed0 31?>
32
3054741a 33
f9903ed0 34<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
35 <TR>
657423c8 36 <?PHP
670fddf1 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);
5e367a2d 45 print_section_block(get_string("mainmenu"), $site, $sections[0],
46 $mods, $modnames, $modnamesused, true, $side, isediting($site->id));
670fddf1 47 }
d66615eb 48
670fddf1 49 if ($site->newsitems > 0 ) {
9fa49e22 50 $categories = get_categories();
ba2e5d73 51 if (count($categories) > 1) {
ba2e5d73 52 print_course_categories($categories, "none", $side);
53 } else {
ba2e5d73 54 $category = array_shift($categories);
d9fd5e8b 55 print_all_courses($category->id, "minimal", 10, $side);
ba2e5d73 56 }
670fddf1 57 }
58 print_spacer(1,$side);
59 }
60
61 if (isadmin()) {
62 if (!$firstcolumn) {
63 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
693c02d0 64 }
670fddf1 65 print_admin_links($site->id, $side);
66 }
67
68 if ($firstcolumn) {
69 echo "</TD>";
670fddf1 70 }
915d17bb 71 echo "<TD WIDTH=70% VALIGN=TOP>";
670fddf1 72
73 if ($site->newsitems == 0 ) {
5e367a2d 74 print_heading_block(get_string("availablecourses"));
670fddf1 75 print_spacer(8,1);
9fa49e22 76 $categories = get_categories();
0c656181 77 if (count($categories) > 1) {
78 print_course_categories($categories, "index");
79 } else {
80 print_all_courses("all");
81 }
670fddf1 82
83 } else {
84 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
85 error("Could not find or create a main news forum for the site");
a166f060 86 }
d887b5a7 87
670fddf1 88 if (isset($USER->id)) {
89 $SESSION->fromdiscussion = "$CFG->wwwroot";
90 save_session("SESSION");
91 if (forum_is_subscribed($USER->id, $newsforum->id)) {
92 $subtext = get_string("unsubscribe", "forum");
30e1a2ee 93 } else {
670fddf1 94 $subtext = get_string("subscribe", "forum");
30e1a2ee 95 }
670fddf1 96 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
97 <TD>".get_string("sitenews")."</TD>
98 <TD ALIGN=RIGHT><FONT SIZE=1>
99 <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
100 </TD></TR></TABLE>";
101 } else {
102 $headertext = get_string("sitenews");
d887b5a7 103 }
5e367a2d 104 print_heading_block($headertext);
670fddf1 105 print_spacer(8,1);
106 forum_print_latest_discussions($newsforum->id, $site->newsitems);
107 }
108
109 echo "</TD>";
110 echo "<TD WIDTH=30% VALIGN=TOP>";
111
112 if (isediting($site->id)) {
113 $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
114 }
115
6daa3c23 116 print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
670fddf1 117 print_spacer(1,$side);
118 echo "</TD>";
119 ?>
d887b5a7 120
f9903ed0 121 </TR>
122</TABLE>
123
657423c8 124<?PHP print_footer("home"); // Please do not modify this line ?>
f9903ed0 125