Define forum type all the time
[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
9c9f7d77 29 $firstcolumn = false; // for now
469e5eb1 30 $side = 175;
19a55d67 31
f9903ed0 32?>
33
3054741a 34
f9903ed0 35<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
36 <TR>
657423c8 37 <?PHP
670fddf1 38 $sections = get_all_sections($site->id);
39
40 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {
41
9c9f7d77 42 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>";
43 $firstcolumn=true;
670fddf1 44
45 if ($sections[0]->sequence or isediting($site->id)) {
46 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
5e367a2d 47 print_section_block(get_string("mainmenu"), $site, $sections[0],
48 $mods, $modnames, $modnamesused, true, $side, isediting($site->id));
670fddf1 49 }
d66615eb 50
670fddf1 51 if ($site->newsitems > 0 ) {
9fa49e22 52 $categories = get_categories();
ba2e5d73 53 if (count($categories) > 1) {
ba2e5d73 54 print_course_categories($categories, "none", $side);
55 } else {
ba2e5d73 56 $category = array_shift($categories);
d9fd5e8b 57 print_all_courses($category->id, "minimal", 10, $side);
ba2e5d73 58 }
670fddf1 59 }
60 print_spacer(1,$side);
61 }
62
63 if (isadmin()) {
64 if (!$firstcolumn) {
65 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
693c02d0 66 }
670fddf1 67 print_admin_links($site->id, $side);
68 }
69
70 if ($firstcolumn) {
71 echo "</TD>";
670fddf1 72 }
915d17bb 73 echo "<TD WIDTH=70% VALIGN=TOP>";
670fddf1 74
75 if ($site->newsitems == 0 ) {
5e367a2d 76 print_heading_block(get_string("availablecourses"));
670fddf1 77 print_spacer(8,1);
9fa49e22 78 $categories = get_categories();
0c656181 79 if (count($categories) > 1) {
80 print_course_categories($categories, "index");
81 } else {
82 print_all_courses("all");
83 }
670fddf1 84
85 } else {
86 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
87 error("Could not find or create a main news forum for the site");
a166f060 88 }
d887b5a7 89
670fddf1 90 if (isset($USER->id)) {
91 $SESSION->fromdiscussion = "$CFG->wwwroot";
92 save_session("SESSION");
93 if (forum_is_subscribed($USER->id, $newsforum->id)) {
94 $subtext = get_string("unsubscribe", "forum");
30e1a2ee 95 } else {
670fddf1 96 $subtext = get_string("subscribe", "forum");
30e1a2ee 97 }
670fddf1 98 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
99 <TD>".get_string("sitenews")."</TD>
100 <TD ALIGN=RIGHT><FONT SIZE=1>
101 <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
102 </TD></TR></TABLE>";
103 } else {
104 $headertext = get_string("sitenews");
d887b5a7 105 }
5e367a2d 106 print_heading_block($headertext);
670fddf1 107 print_spacer(8,1);
108 forum_print_latest_discussions($newsforum->id, $site->newsitems);
109 }
110
111 echo "</TD>";
112 echo "<TD WIDTH=30% VALIGN=TOP>";
113
114 if (isediting($site->id)) {
115 $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
116 }
117
6daa3c23 118 print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
670fddf1 119 print_spacer(1,$side);
120 echo "</TD>";
121 ?>
d887b5a7 122
f9903ed0 123 </TR>
124</TABLE>
125
657423c8 126<?PHP print_footer("home"); // Please do not modify this line ?>
f9903ed0 127