added link to index of helpfiles
[moodle.git] / index.php
CommitLineData
657423c8 1<?PHP // $Id$
2 // index.php - the front page.
f9903ed0 3
b0e3a925 4 require_once("config.php");
5 require_once("course/lib.php");
6 require_once("mod/resource/lib.php");
7 require_once("mod/forum/lib.php");
f9903ed0 8
8553b700 9 if (! $site = get_site()) {
f33db1ce 10 redirect("$CFG->wwwroot/$CFG->admin/index.php");
f9903ed0 11 }
12
53bfe78c 13 if (isadmin()) {
14 if (moodle_needs_upgrading()) {
f33db1ce 15 redirect("$CFG->wwwroot/$CFG->admin/index.php");
53bfe78c 16 }
3565715c 17 }
18
19 if (empty($USER->id)) {
20 $loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
4efeb8c3 21 } else {
3565715c 22 $loginstring = "<font size=1>".user_login_string($site)."</font>";
a325bd2b 23 }
a5e3644b 24
984a8bf3 25 if (empty($CFG->langmenu)) {
26 $langmenu = "";
27 } else {
28 $currlang = current_language();
29 $langs = get_list_of_languages();
30 $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
31 }
a5e3644b 32
54c1a20c 33 print_header(strip_tags($site->fullname), "$site->fullname", "home", "",
958facf0 34 "<meta name=\"description\" content=\"".s(strip_tags($site->summary))."\">",
3565715c 35 true, "", "<div align=right>$loginstring$langmenu</div>");
f9903ed0 36
9c9f7d77 37 $firstcolumn = false; // for now
ee00b8b9 38 $lastcolumn = false; // for now
469e5eb1 39 $side = 175;
19a55d67 40
ee00b8b9 41 if (isediting($site->id)) {
f33db1ce 42 $site->summary .= "<br><center><a href=\"$CFG->admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
ee00b8b9 43 }
44
45 if ($site->summary) {
46 $lastcolumn = true;
47 }
48
49
f9903ed0 50?>
51
3054741a 52
3565715c 53<table width="100%" border="0" cellspacing="5" cellpadding="5">
54 <tr>
657423c8 55 <?PHP
670fddf1 56 $sections = get_all_sections($site->id);
57
3565715c 58 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
670fddf1 59
3565715c 60 echo "<td width=\"$side\" valign=top nowrap>";
9c9f7d77 61 $firstcolumn=true;
670fddf1 62
63 if ($sections[0]->sequence or isediting($site->id)) {
64 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
5e367a2d 65 print_section_block(get_string("mainmenu"), $site, $sections[0],
52dcc2f9 66 $mods, $modnames, $modnamesused, true, $side);
670fddf1 67 }
d66615eb 68
3565715c 69 if (isadmin()) {
70 echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
71 echo "<br />";
72 }
73
c2cb4545 74 switch ($CFG->frontpage) {
75 case FRONTPAGENEWS: // print news links on the side
76 print_courses_sideblock(0, "$side");
77 break;
78
79 case FRONTPAGECOURSELIST:
80 case FRONTPAGECATEGORYNAMES:
81 if ($site->newsitems) {
82 if ($news = forum_get_course_forum($site->id, "news")) {
83 print_side_block_start(get_string("latestnews"), $side, "sideblocklatestnews");
84 echo "<font size=\"-2\">";
85 forum_print_latest_discussions($news->id, $site->newsitems, "minimal", "", false);
86 echo "</font>";
87 print_side_block_end();
88 }
89 }
90 break;
670fddf1 91 }
92 print_spacer(1,$side);
93 }
94
1924074c 95 if (iscreator()) {
670fddf1 96 if (!$firstcolumn) {
3565715c 97 echo "<td width=\"$side\" valign=top nowrap>";
98 $firstcolumn=true;
693c02d0 99 }
670fddf1 100 print_admin_links($site->id, $side);
101 }
102
103 if ($firstcolumn) {
3565715c 104 echo "</td>";
670fddf1 105 }
ee00b8b9 106 if ($lastcolumn) {
107 echo "<td width=\"70%\" valign=\"top\">";
108 } else {
109 echo "<td width=\"100%\" valign=\"top\">";
110 }
670fddf1 111
c2cb4545 112 switch ($CFG->frontpage) { /// Display the main part of the front page.
113 case FRONTPAGENEWS:
114 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
115 error("Could not find or create a main news forum for the site");
116 }
117
118 if (isset($USER->id)) {
119 $SESSION->fromdiscussion = "$CFG->wwwroot";
120 if (forum_is_subscribed($USER->id, $newsforum->id)) {
121 $subtext = get_string("unsubscribe", "forum");
122 } else {
123 $subtext = get_string("subscribe", "forum");
124 }
125 $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr>
126 <td>$newsforum->name</td>
127 <td align=right><font size=1>
128 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
129 </td></tr></table>";
30e1a2ee 130 } else {
c2cb4545 131 $headertext = $newsforum->name;
30e1a2ee 132 }
c2cb4545 133 print_heading_block($headertext);
134 print_spacer(8,1);
135 forum_print_latest_discussions($newsforum->id, $site->newsitems);
136 break;
137
138 case FRONTPAGECOURSELIST:
139 case FRONTPAGECATEGORYNAMES:
140 if (isset($USER->id) and !isset($USER->admin)) {
141 print_heading_block(get_string("mycourses"));
142 print_spacer(8,1);
143 print_my_moodle();
144 } else {
145 print_heading_block(get_string("availablecourses"));
146 print_spacer(8,1);
147 if (count_records("course_categories") > 1) {
ee00b8b9 148 print_simple_box_start("center", "100%");
c2cb4545 149 print_whole_category_list();
ee00b8b9 150 print_simple_box_end();
4020587b 151 print_course_search("", false, "short");
c2cb4545 152 } else {
153 print_courses(0, "100%");
154 }
155 }
156 break;
157
670fddf1 158 }
159
3565715c 160 echo "</td>";
670fddf1 161
ee00b8b9 162 if ($lastcolumn) {
163 echo "<td width=\"30%\" valign=\"top\">";
164 print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
165 print_spacer(1,$side);
166 echo "</td>";
167 }
670fddf1 168 ?>
d887b5a7 169
3565715c 170 </tr>
171</table>
f9903ed0 172
657423c8 173<?PHP print_footer("home"); // Please do not modify this line ?>
f9903ed0 174