mirrored from git://git.moodle.org/moodle.git
/
index.php
140 lines (114 loc) · 4.52 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?PHP // $Id$
// index.php - the front page.
require_once("config.php");
require_once("course/lib.php");
require_once("mod/resource/lib.php");
require_once("mod/forum/lib.php");
if (! $site = get_site()) {
redirect("$CFG->wwwroot/admin/index.php");
}
if (isadmin()) {
if (moodle_needs_upgrading()) {
redirect("$CFG->wwwroot/admin/index.php");
}
}
if (empty($USER->id)) {
$loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
} else {
$loginstring = "<font size=1>".user_login_string($site)."</font>";
}
if (empty($CFG->langmenu)) {
$langmenu = "";
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
}
print_header(strip_tags($site->fullname), "$site->fullname", "home", "",
"<meta name=\"description\" content=\"".s(strip_tags($site->summary))."\">",
true, "", "<div align=right>$loginstring$langmenu</div>");
$firstcolumn = false; // for now
$side = 175;
?>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<?PHP
$sections = get_all_sections($site->id);
if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
echo "<td width=\"$side\" valign=top nowrap>";
$firstcolumn=true;
if ($sections[0]->sequence or isediting($site->id)) {
get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
print_section_block(get_string("mainmenu"), $site, $sections[0],
$mods, $modnames, $modnamesused, true, $side, isediting($site->id));
}
if (isadmin()) {
echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
echo "<br />";
}
if ($site->newsitems > 0 ) {
$categories = get_categories();
if (count($categories) > 1) {
print_course_categories($categories, "none", $side);
} else {
$category = array_shift($categories);
print_all_courses($category->id, "minimal", 10, $side);
}
}
print_spacer(1,$side);
}
if (iscreator()) {
if (!$firstcolumn) {
echo "<td width=\"$side\" valign=top nowrap>";
$firstcolumn=true;
}
print_admin_links($site->id, $side);
}
if ($firstcolumn) {
echo "</td>";
}
echo "<td width=\"70%\" valign=\"top\">";
if ($site->newsitems == 0 ) {
print_heading_block(get_string("availablecourses"));
print_spacer(8,1);
$categories = get_categories();
if (count($categories) > 1) {
print_course_categories($categories, "index");
} else {
print_all_courses("all");
}
} else {
if (! $newsforum = forum_get_course_forum($site->id, "news")) {
error("Could not find or create a main news forum for the site");
}
if (isset($USER->id)) {
$SESSION->fromdiscussion = "$CFG->wwwroot";
if (forum_is_subscribed($USER->id, $newsforum->id)) {
$subtext = get_string("unsubscribe", "forum");
} else {
$subtext = get_string("subscribe", "forum");
}
$headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr>
<td>$newsforum->name</td>
<td align=right><font size=1>
<a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
</td></tr></table>";
} else {
$headertext = $newsforum->name;
}
print_heading_block($headertext);
print_spacer(8,1);
forum_print_latest_discussions($newsforum->id, $site->newsitems);
}
echo "</td>";
echo "<td width=30% valign=top>";
if (isediting($site->id)) {
$site->summary .= "<br><center><a href=\"admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
}
print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
print_spacer(1,$side);
echo "</td>";
?>
</tr>
</table>
<?PHP print_footer("home"); // Please do not modify this line ?>