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/$CFG->admin/index.php");
13 if ($CFG->forcelogin
) {
18 if (moodle_needs_upgrading()) {
19 redirect("$CFG->wwwroot/$CFG->admin/index.php");
23 if (empty($USER->id
)) {
24 $loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
26 $loginstring = "<font size=1>".user_login_string($site)."</font>";
29 if (empty($CFG->langmenu
)) {
32 $currlang = current_language();
33 $langs = get_list_of_languages();
34 $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
37 print_header(strip_tags($site->fullname
), "$site->fullname", "home", "",
38 "<meta name=\"description\" content=\"".s(strip_tags($site->summary
))."\">",
39 true, "", "$loginstring$langmenu");
41 $firstcolumn = false; // for now
42 $lastcolumn = false; // for now
45 $site_summary_editbuttons = '';
46 if (isediting($site->id
)) {
47 $site_summary_editbuttons = "<br><center><a href=\"$CFG->admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
58 <table width
="100%" border
="0" cellspacing
="5" cellpadding
="5">
61 $sections = get_all_sections($site->id
);
63 if ($site->newsitems
> 0 or $sections[0]->sequence
or isediting($site->id
) or isadmin()) {
65 echo "<td width=\"$side\" valign=top nowrap>";
68 if ($sections[0]->sequence
or isediting($site->id
)) {
69 get_all_mods($site->id
, $mods, $modnames, $modnamesplural, $modnamesused);
70 print_section_block(get_string("mainmenu"), $site, $sections[0],
71 $mods, $modnames, $modnamesused, true, $side);
75 echo "<div align=\"center\">".update_course_icon($site->id
)."</div>";
79 switch ($CFG->frontpage
) {
80 case FRONTPAGENEWS
: // print news links on the side
81 print_courses_sideblock(0, "$side");
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);
92 print_side_block_end();
97 print_spacer(1,$side);
102 echo "<td width=\"$side\" valign=top nowrap>";
105 print_admin_links($site->id
, $side);
112 echo "<td width=\"70%\" valign=\"top\">";
114 echo "<td width=\"100%\" valign=\"top\">";
117 switch ($CFG->frontpage
) { /// Display the main part of the front page.
119 if (! $newsforum = forum_get_course_forum($site->id
, "news")) {
120 error("Could not find or create a main news forum for the site");
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");
128 $subtext = get_string("subscribe", "forum");
130 $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0 class=headingblockcontent><tr>
131 <td>$newsforum->name</td>
132 <td align=right><font size=1>
133 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
136 $headertext = $newsforum->name
;
138 print_heading_block($headertext);
140 forum_print_latest_discussions($newsforum->id
, $site->newsitems
);
143 case FRONTPAGECOURSELIST
:
144 case FRONTPAGECATEGORYNAMES
:
145 if (isset($USER->id
) and !isset($USER->admin
)) {
146 print_heading_block(get_string("mycourses"));
150 print_heading_block(get_string("availablecourses"));
152 if (count_records("course_categories") > 1) {
153 print_simple_box_start("center", "100%");
154 print_whole_category_list();
155 print_simple_box_end();
156 print_course_search("", false, "short");
158 print_courses(0, "100%");
168 echo "<td width=\"30%\" valign=\"top\">";
169 print_simple_box(format_text($site->summary
, FORMAT_HTML
).$site_summary_editbuttons,
170 "", "100%", $THEME->cellcontent2
, 5, "siteinfo");
171 print_spacer(1,$side);
179 <?PHP
print_footer("home"); // Please do not modify this line ?>