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