2 // index.php - the front page.
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");
9 if (! $site = get_site()) {
10 redirect("$CFG->wwwroot/admin/index.php");
14 if (moodle_needs_upgrading()) {
15 redirect("$CFG->wwwroot/admin/index.php");
19 if (empty($USER->id
)) {
20 $loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
22 $loginstring = "<font size=1>".user_login_string($site)."</font>";
25 if (empty($CFG->langmenu
)) {
28 $currlang = current_language();
29 $langs = get_list_of_languages();
30 $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
33 print_header(strip_tags($site->fullname
), "$site->fullname", "home", "",
34 "<meta name=\"description\" content=\"".s(strip_tags($site->summary
))."\">",
35 true, "", "<div align=right>$loginstring$langmenu</div>");
37 $firstcolumn = false; // for now
38 $lastcolumn = false; // for now
41 if (isediting($site->id
)) {
42 $site->summary
.= "<br><center><a href=\"admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
53 <table width
="100%" border
="0" cellspacing
="5" cellpadding
="5">
56 $sections = get_all_sections($site->id
);
58 if ($site->newsitems
> 0 or $sections[0]->sequence
or isediting($site->id
) or isadmin()) {
60 echo "<td width=\"$side\" valign=top nowrap>";
63 if ($sections[0]->sequence
or isediting($site->id
)) {
64 get_all_mods($site->id
, $mods, $modnames, $modnamesplural, $modnamesused);
65 print_section_block(get_string("mainmenu"), $site, $sections[0],
66 $mods, $modnames, $modnamesused, true, $side);
70 echo "<div align=\"center\">".update_course_icon($site->id
)."</div>";
74 switch ($CFG->frontpage
) {
75 case FRONTPAGENEWS
: // print news links on the side
76 print_courses_sideblock(0, "$side");
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);
87 print_side_block_end();
92 print_spacer(1,$side);
97 echo "<td width=\"$side\" valign=top nowrap>";
100 print_admin_links($site->id
, $side);
107 echo "<td width=\"70%\" valign=\"top\">";
109 echo "<td width=\"100%\" valign=\"top\">";
112 switch ($CFG->frontpage
) { /// Display the main part of the front page.
114 if (! $newsforum = forum_get_course_forum($site->id
, "news")) {
115 error("Could not find or create a main news forum for the site");
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");
123 $subtext = get_string("subscribe", "forum");
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>
131 $headertext = $newsforum->name
;
133 print_heading_block($headertext);
135 forum_print_latest_discussions($newsforum->id
, $site->newsitems
);
138 case FRONTPAGECOURSELIST
:
139 case FRONTPAGECATEGORYNAMES
:
140 if (isset($USER->id
) and !isset($USER->admin
)) {
141 print_heading_block(get_string("mycourses"));
145 print_heading_block(get_string("availablecourses"));
147 if (count_records("course_categories") > 1) {
148 print_simple_box_start("center", "100%");
149 print_whole_category_list();
150 print_simple_box_end();
151 print_course_search();
153 print_courses(0, "100%");
163 echo "<td width=\"30%\" valign=\"top\">";
164 print_simple_box($site->summary
, "", "100%", $THEME->cellcontent2
, 5, "siteinfo");
165 print_spacer(1,$side);
173 <?PHP
print_footer("home"); // Please do not modify this line ?>