Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 195 lines (160 sloc) 7.255 kB
4bab527 some string quote and spacing cleanup
dhawes authored
1 <?php // $Id$
657423c get rid of short_open_tags
moodler authored
2 // index.php - the front page.
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
3
8b5b102 New automatic installation script! No need to make config.php anymore!
moodler authored
4 if (!file_exists('./config.php')) {
5 header('Location: install.php');
6 die;
7 }
8
9 /// Bounds for block widths on this page
df9e0f8 Fixes for bug 1485:
defacer authored
10 define('BLOCK_L_MIN_WIDTH', 160);
11 define('BLOCK_L_MAX_WIDTH', 210);
12 define('BLOCK_R_MIN_WIDTH', 160);
13 define('BLOCK_R_MAX_WIDTH', 210);
14
8deb0ff Merged file path improvements from stable
moodler authored
15 require_once('config.php');
4bab527 some string quote and spacing cleanup
dhawes authored
16 require_once($CFG->dirroot .'/course/lib.php');
17 require_once($CFG->dirroot .'/lib/blocklib.php');
18 require_once($CFG->dirroot .'/mod/resource/lib.php');
19 require_once($CFG->dirroot .'/mod/forum/lib.php');
f9903ed Initial revision
martin authored
20
78ba4d0 Save a db call by using SITE
moodler authored
21 if (empty($SITE)) {
4bab527 some string quote and spacing cleanup
dhawes authored
22 redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
f9903ed Initial revision
martin authored
23 }
24
0a45ffe A new configuration setting - "forcelogin".
moodler authored
25 if ($CFG->forcelogin) {
26 require_login();
27 }
28
53bfe78 New functions get_list_of_modules() and moodle_needs_upgrading().
martin authored
29 if (isadmin()) {
30 if (moodle_needs_upgrading()) {
4bab527 some string quote and spacing cleanup
dhawes authored
31 redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
53bfe78 New functions get_list_of_modules() and moodle_needs_upgrading().
martin authored
32 }
3565715 Moved the "turn editing on" button and tidied some other things up a bit
moodler authored
33 }
34
c44d5d4 Some cleaning up of user_login_string and SITE
moodler authored
35 if (!empty($USER->id)) {
34dd590 FIxed my last hasty checkin
moodler authored
36 add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID);
a325bd2 More accessible log in button up top
martin authored
37 }
a5e3644 Add setting of language to home page, and setting of new user accounts
moodler authored
38
984a8bf Two new language variables implemented.
moodler authored
39 if (empty($CFG->langmenu)) {
4bab527 some string quote and spacing cleanup
dhawes authored
40 $langmenu = '';
984a8bf Two new language variables implemented.
moodler authored
41 } else {
42 $currlang = current_language();
43 $langs = get_list_of_languages();
4bab527 some string quote and spacing cleanup
dhawes authored
44 $langmenu = popup_form ($CFG->wwwroot .'/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true);
984a8bf Two new language variables implemented.
moodler authored
45 }
a5e3644 Add setting of language to home page, and setting of new user accounts
moodler authored
46
60fe973 Updating index page with all the latest from blocklib and pagelib.
defacer authored
47 $PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
3615b2b Simplifying to death using the new blocks_setup()
defacer authored
48 $pageblocks = blocks_setup($PAGE);
60fe973 Updating index page with all the latest from blocklib and pagelib.
defacer authored
49 $editing = $PAGE->user_is_editing();
50 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH);
51 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH);
df9e0f8 Fixes for bug 1485:
defacer authored
52
78ba4d0 Save a db call by using SITE
moodler authored
53 print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home', '',
54 '<meta name="description" content="'. s(strip_tags($SITE->summary)) .'" />',
c44d5d4 Some cleaning up of user_login_string and SITE
moodler authored
55 true, '', user_login_string($SITE).$langmenu);
5921e0a Fixed incorrect use of optional_param.
defacer authored
56
f9903ed Initial revision
martin authored
57 ?>
58
3054741 Tidied up the front page. Added 'editing' switch and normal footer
martin authored
59
e96ba29 Vastly improved styles, lots of inline styles removed, markup improved.
defacer authored
60 <table id="layout-table">
3565715 Moved the "turn editing on" button and tidied some other things up a bit
moodler authored
61 <tr>
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
62 <?PHP
63
dffd4bb You know you are beyond hope of redemption when you make "API uniform…
defacer authored
64 if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
e96ba29 Vastly improved styles, lots of inline styles removed, markup improved.
defacer authored
65 echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
6649232 Since $PAGE knows where the adminblock should be printed, let it do t…
defacer authored
66 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
67 echo '</td>';
68 }
69
e96ba29 Vastly improved styles, lots of inline styles removed, markup improved.
defacer authored
70 echo '<td id="middle-column">';
8c336db _ added the div framework
urs_hunkler authored
71
72
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
73 /// Print Section
78ba4d0 Save a db call by using SITE
moodler authored
74 if ($SITE->numsections > 0) {
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
75
78ba4d0 Save a db call by using SITE
moodler authored
76 if (!$section = get_record('course_sections', 'course', $SITE->id, 'section', 1)) {
77 delete_records('course_sections', 'course', $SITE->id, 'section', 1); // Just in case
78 $section->course = $SITE->id;
45a6b40 FIxed up the Site Topic
moodler authored
79 $section->section = 1;
80 $section->summary = '';
a2b8226 Don't show the front page topic section when it's empty anyway. bug 2691
moodler authored
81 $section->sequence = '';
45a6b40 FIxed up the Site Topic
moodler authored
82 $section->visible = 1;
83 $section->id = insert_record('course_sections', $section);
84 }
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
85
a2b8226 Don't show the front page topic section when it's empty anyway. bug 2691
moodler authored
86 if (!empty($section->sequence) or !empty($section->summary) or $editing) {
87 print_simple_box_start('center', '100%', '', 5, 'sitetopic');
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
88
a2b8226 Don't show the front page topic section when it's empty anyway. bug 2691
moodler authored
89 /// If currently moving a file then show the current clipboard
90 if (ismoving($SITE->id)) {
91 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
92 echo '<p><font size="2">';
93 echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true\">". get_string('cancel') .'</a>)';
94 echo '</font></p>';
95 }
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
96
a2b8226 Don't show the front page topic section when it's empty anyway. bug 2691
moodler authored
97 echo format_text($section->summary, FORMAT_HTML);
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
98
a2b8226 Don't show the front page topic section when it's empty anyway. bug 2691
moodler authored
99 if ($editing) {
100 $streditsummary = get_string('editsummary');
101 echo "<a title=\"$streditsummary\" ".
102 " href=\"course/editsection.php?id=$section->id\"><img src=\"$CFG->pixpath/t/edit.gif\" ".
103 " height=\"11\" width=\"11\" border=\"0\" alt=\"$streditsummary\" /></a><br /><br />";
104 }
105
106 get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
107 print_section($SITE, $section, $mods, $modnamesused, true);
108
109 if ($editing) {
110 print_section_add_menus($SITE, $section->section, $modnames);
111 }
112 print_simple_box_end();
113 print_spacer(10);
5fc2f2f site front page can now have a topic section, see http://moodle.org/m…
gustav_delius authored
114 }
115 }
116
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
117 switch ($CFG->frontpage) { /// Display the main part of the front page.
118 case FRONTPAGENEWS:
78ba4d0 Save a db call by using SITE
moodler authored
119 if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
4bab527 some string quote and spacing cleanup
dhawes authored
120 error('Could not find or create a main news forum for the site');
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
121 }
122
123 if (isset($USER->id)) {
4bab527 some string quote and spacing cleanup
dhawes authored
124 $SESSION->fromdiscussion = $CFG->wwwroot;
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
125 if (forum_is_subscribed($USER->id, $newsforum->id)) {
4bab527 some string quote and spacing cleanup
dhawes authored
126 $subtext = get_string('unsubscribe', 'forum');
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
127 } else {
4bab527 some string quote and spacing cleanup
dhawes authored
128 $subtext = get_string('subscribe', 'forum');
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
129 }
98ea2a6 closed some image tags
gustav_delius authored
130 $headertext = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"headingblockcontent\"><tr>
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
131 <td>$newsforum->name</td>
98ea2a6 closed some image tags
gustav_delius authored
132 <td align=\"right\"><font size=\"1\">
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
133 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
134 </td></tr></table>";
135 } else {
136 $headertext = $newsforum->name;
137 }
8c336db _ added the div framework
urs_hunkler authored
138
78ba4d0 Save a db call by using SITE
moodler authored
139 if ($SITE->newsitems) { //print forums only when needed
63fa3f8 If selected news count is zero, dont print forum headers.
paca70 authored
140 print_heading_block($headertext);
141 print_spacer(8,1);
78ba4d0 Save a db call by using SITE
moodler authored
142 forum_print_latest_discussions($newsforum->id, $SITE->newsitems);
8c336db _ added the div framework
urs_hunkler authored
143 }
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
144 break;
145
146 case FRONTPAGECOURSELIST:
147 case FRONTPAGECATEGORYNAMES:
148 if (isset($USER->id) and !isset($USER->admin)) {
4bab527 some string quote and spacing cleanup
dhawes authored
149 print_heading_block(get_string('mycourses'));
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
150 print_spacer(8,1);
151 print_my_moodle();
152 } else {
4bab527 some string quote and spacing cleanup
dhawes authored
153 if (count_records('course_categories') > 1) {
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
154 if ($CFG->frontpage == FRONTPAGECOURSELIST) {
4bab527 some string quote and spacing cleanup
dhawes authored
155 print_heading_block(get_string('availablecourses'));
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
156 } else {
4bab527 some string quote and spacing cleanup
dhawes authored
157 print_heading_block(get_string('categories'));
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
158 }
159 print_spacer(8,1);
4bab527 some string quote and spacing cleanup
dhawes authored
160 print_simple_box_start('center', '100%');
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
161 print_whole_category_list();
162 print_simple_box_end();
4bab527 some string quote and spacing cleanup
dhawes authored
163 print_course_search('', false, 'short');
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
164 } else {
4bab527 some string quote and spacing cleanup
dhawes authored
165 print_heading_block(get_string('availablecourses'));
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
166 print_spacer(8,1);
4bab527 some string quote and spacing cleanup
dhawes authored
167 print_courses(0, '100%');
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
168 }
169 }
170 break;
171
172 }
173
174 echo '</td>';
9b4b78f Da monster-commit of blocks version 2!
defacer authored
175
176
177 // The right column
dffd4bb You know you are beyond hope of redemption when you make "API uniform…
defacer authored
178 if(blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || isadmin()) {
e96ba29 Vastly improved styles, lots of inline styles removed, markup improved.
defacer authored
179 echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
180 if (isadmin()) {
78ba4d0 Save a db call by using SITE
moodler authored
181 echo '<div align="center">'.update_course_icon($SITE->id).'</div>';
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
182 echo '<br />';
183 }
6649232 Since $PAGE knows where the adminblock should be printed, let it do t…
defacer authored
184 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
89adb17 Merging the changes from 1.4 dev branch (site index blocks + various …
defacer authored
185 echo '</td>';
186 }
187 ?>
d887b5a Changes to allow choice of format on home page of site
martin authored
188
3565715 Moved the "turn editing on" button and tidied some other things up a bit
moodler authored
189 </tr>
190 </table>
f9903ed Initial revision
martin authored
191
8c336db _ added the div framework
urs_hunkler authored
192 <?php
193 print_footer('home'); // Please do not modify this line
b5768b9 Removed $THEME from site topic
moodler authored
194 ?>
Something went wrong with that request. Please try again.