Changed some function names, making room for export functions later
[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()) {
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 }
a5e3644b 25
a5e3644b 26 $currlang = current_language();
27 $langs = get_list_of_languages();
28 $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
29
8cea3a39 30 print_header("$site->fullname", "$site->fullname", "home", "",
de973a18 31 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
789a2500 32 true, "", "<div align=right>$headerbutton$langmenu</div>");
f9903ed0 33
9c9f7d77 34 $firstcolumn = false; // for now
469e5eb1 35 $side = 175;
19a55d67 36
f9903ed0 37?>
38
3054741a 39
f9903ed0 40<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
41 <TR>
657423c8 42 <?PHP
670fddf1 43 $sections = get_all_sections($site->id);
44
45 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {
46
9c9f7d77 47 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>";
48 $firstcolumn=true;
670fddf1 49
50 if ($sections[0]->sequence or isediting($site->id)) {
51 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
5e367a2d 52 print_section_block(get_string("mainmenu"), $site, $sections[0],
53 $mods, $modnames, $modnamesused, true, $side, isediting($site->id));
670fddf1 54 }
d66615eb 55
670fddf1 56 if ($site->newsitems > 0 ) {
9fa49e22 57 $categories = get_categories();
ba2e5d73 58 if (count($categories) > 1) {
ba2e5d73 59 print_course_categories($categories, "none", $side);
60 } else {
ba2e5d73 61 $category = array_shift($categories);
d9fd5e8b 62 print_all_courses($category->id, "minimal", 10, $side);
ba2e5d73 63 }
670fddf1 64 }
65 print_spacer(1,$side);
66 }
67
1924074c 68 if (iscreator()) {
670fddf1 69 if (!$firstcolumn) {
70 echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
693c02d0 71 }
670fddf1 72 print_admin_links($site->id, $side);
73 }
74
75 if ($firstcolumn) {
76 echo "</TD>";
670fddf1 77 }
915d17bb 78 echo "<TD WIDTH=70% VALIGN=TOP>";
670fddf1 79
80 if ($site->newsitems == 0 ) {
5e367a2d 81 print_heading_block(get_string("availablecourses"));
670fddf1 82 print_spacer(8,1);
9fa49e22 83 $categories = get_categories();
0c656181 84 if (count($categories) > 1) {
85 print_course_categories($categories, "index");
86 } else {
87 print_all_courses("all");
88 }
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";
670fddf1 97 if (forum_is_subscribed($USER->id, $newsforum->id)) {
98 $subtext = get_string("unsubscribe", "forum");
30e1a2ee 99 } else {
670fddf1 100 $subtext = get_string("subscribe", "forum");
30e1a2ee 101 }
670fddf1 102 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
9c2c5c5b 103 <TD>$newsforum->name</TD>
670fddf1 104 <TD ALIGN=RIGHT><FONT SIZE=1>
105 <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
106 </TD></TR></TABLE>";
107 } else {
9c2c5c5b 108 $headertext = $newsforum->name;
d887b5a7 109 }
5e367a2d 110 print_heading_block($headertext);
670fddf1 111 print_spacer(8,1);
112 forum_print_latest_discussions($newsforum->id, $site->newsitems);
113 }
114
115 echo "</TD>";
116 echo "<TD WIDTH=30% VALIGN=TOP>";
117
118 if (isediting($site->id)) {
119 $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
120 }
121
6daa3c23 122 print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
670fddf1 123 print_spacer(1,$side);
124 echo "</TD>";
125 ?>
d887b5a7 126
f9903ed0 127 </TR>
128</TABLE>
129
657423c8 130<?PHP print_footer("home"); // Please do not modify this line ?>
f9903ed0 131