2009-10-15 03:43:28 +00:00
|
|
|
<?php
|
2002-12-07 07:27:18 +00:00
|
|
|
// index.php - the front page.
|
2004-05-28 10:53:54 +00:00
|
|
|
|
2006-08-23 08:39:15 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
|
|
|
// http://moodle.org //
|
|
|
|
// //
|
2007-06-27 07:24:24 +00:00
|
|
|
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
2006-08-23 08:39:15 +00:00
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License for more details: //
|
|
|
|
// //
|
|
|
|
// http://www.gnu.org/copyleft/gpl.html //
|
|
|
|
// //
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
if (!file_exists('./config.php')) {
|
|
|
|
header('Location: install.php');
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2007-03-07 09:47:23 +00:00
|
|
|
require_once('config.php');
|
|
|
|
require_once($CFG->dirroot .'/course/lib.php');
|
2009-02-17 16:18:05 +00:00
|
|
|
require_once($CFG->libdir .'/filelib.php');
|
2007-08-24 04:22:30 +00:00
|
|
|
|
2009-07-10 08:44:01 +00:00
|
|
|
redirect_if_major_upgrade_required();
|
2007-03-06 16:56:00 +00:00
|
|
|
|
2004-01-14 08:27:18 +00:00
|
|
|
if ($CFG->forcelogin) {
|
|
|
|
require_login();
|
2008-04-15 21:46:04 +00:00
|
|
|
} else {
|
|
|
|
user_accesstime_log();
|
2004-01-14 08:27:18 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 14:42:29 +00:00
|
|
|
/// If the site is currently under maintenance, then print a message
|
|
|
|
if (!empty($CFG->maintenance_enabled) and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
|
|
|
print_maintenance_message();
|
|
|
|
}
|
|
|
|
|
2009-01-15 22:09:57 +00:00
|
|
|
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
|
|
|
if (moodle_needs_upgrading()) {
|
2004-10-22 02:33:18 +00:00
|
|
|
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
|
2002-08-09 02:45:15 +00:00
|
|
|
}
|
2009-01-15 22:09:57 +00:00
|
|
|
} else if (!empty($CFG->mymoodleredirect)) { // Redirect logged-in users to My Moodle overview if required
|
2009-05-31 14:42:29 +00:00
|
|
|
if (isloggedin() && !isguestuser()) {
|
2009-01-15 22:09:57 +00:00
|
|
|
redirect($CFG->wwwroot .'/my/index.php');
|
|
|
|
}
|
2003-05-03 05:57:29 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 05:08:37 +00:00
|
|
|
|
2009-01-02 13:42:43 +00:00
|
|
|
if (get_moodle_cookie() == '') {
|
|
|
|
set_moodle_cookie('nobody'); // To help search for cookies on login page
|
2005-04-17 05:47:40 +00:00
|
|
|
}
|
|
|
|
|
2005-03-03 04:41:46 +00:00
|
|
|
if (!empty($USER->id)) {
|
2004-12-28 15:12:46 +00:00
|
|
|
add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID);
|
2002-06-16 03:25:10 +00:00
|
|
|
}
|
2003-01-20 08:01:46 +00:00
|
|
|
|
2009-07-27 10:33:00 +00:00
|
|
|
$PAGE->set_pagetype('site-index');
|
|
|
|
$PAGE->set_course($SITE);
|
|
|
|
|
2003-05-03 06:50:29 +00:00
|
|
|
if (empty($CFG->langmenu)) {
|
2004-10-22 02:33:18 +00:00
|
|
|
$langmenu = '';
|
2003-05-03 06:50:29 +00:00
|
|
|
} else {
|
|
|
|
$currlang = current_language();
|
|
|
|
$langs = get_list_of_languages();
|
2009-08-10 03:39:21 +00:00
|
|
|
|
2009-08-10 08:38:45 +00:00
|
|
|
$select = html_select::make_popup_form($CFG->wwwroot .'/index.php', 'lang', $langs, 'chooselang', $currlang);
|
2009-08-10 03:39:21 +00:00
|
|
|
$select->nothinglabel = false;
|
|
|
|
$select->set_label(get_accesshide(get_string('language')));
|
2009-12-16 18:00:58 +00:00
|
|
|
//TODO: MDL-21123
|
|
|
|
$langmenu = '<div class="langmenu">'.$OUTPUT->select($select).'</div>';
|
2003-05-03 06:50:29 +00:00
|
|
|
}
|
2009-05-06 09:02:48 +00:00
|
|
|
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
2009-05-06 08:55:53 +00:00
|
|
|
$PAGE->set_url('');
|
2009-05-06 08:48:13 +00:00
|
|
|
$PAGE->set_docs_path('');
|
2009-12-27 12:02:04 +00:00
|
|
|
$PAGE->set_pagelayout('frontpage');
|
2009-05-06 08:55:53 +00:00
|
|
|
$editing = $PAGE->user_is_editing();
|
2009-07-09 07:35:03 +00:00
|
|
|
$PAGE->set_title($SITE->fullname);
|
|
|
|
$PAGE->set_heading($SITE->fullname);
|
2009-12-16 18:00:58 +00:00
|
|
|
$PAGE->set_headingmenu($langmenu);
|
|
|
|
echo $OUTPUT->header($langmenu);
|
2005-01-18 11:05:46 +00:00
|
|
|
|
2004-07-02 09:32:17 +00:00
|
|
|
/// Print Section
|
2005-02-12 15:07:25 +00:00
|
|
|
if ($SITE->numsections > 0) {
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2008-05-15 21:40:00 +00:00
|
|
|
if (!$section = $DB->get_record('course_sections', array('course'=>$SITE->id, 'section'=>1))) {
|
2008-06-02 21:52:27 +00:00
|
|
|
$DB->delete_records('course_sections', array('course'=>$SITE->id, 'section'=>1)); // Just in case
|
2005-02-12 15:07:25 +00:00
|
|
|
$section->course = $SITE->id;
|
2004-07-09 05:33:07 +00:00
|
|
|
$section->section = 1;
|
|
|
|
$section->summary = '';
|
2005-03-07 17:24:32 +00:00
|
|
|
$section->sequence = '';
|
2004-07-09 05:33:07 +00:00
|
|
|
$section->visible = 1;
|
2008-05-15 21:40:00 +00:00
|
|
|
$section->id = $DB->insert_record('course_sections', $section);
|
2004-07-09 05:33:07 +00:00
|
|
|
}
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2005-03-07 17:24:32 +00:00
|
|
|
if (!empty($section->sequence) or !empty($section->summary) or $editing) {
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_start('generalbox sitetopic');
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2005-03-07 17:24:32 +00:00
|
|
|
/// If currently moving a file then show the current clipboard
|
|
|
|
if (ismoving($SITE->id)) {
|
2008-06-09 16:53:30 +00:00
|
|
|
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
|
2005-03-07 17:24:32 +00:00
|
|
|
echo '<p><font size="2">';
|
2009-01-02 10:51:26 +00:00
|
|
|
echo "$stractivityclipboard (<a href=\"course/mod.php?cancelcopy=true&sesskey=".sesskey()."\">". get_string('cancel') .'</a>)';
|
2005-03-07 17:24:32 +00:00
|
|
|
echo '</font></p>';
|
|
|
|
}
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2009-02-17 16:18:05 +00:00
|
|
|
$context = get_context_instance(CONTEXT_COURSE, SITEID);
|
2009-04-01 04:34:58 +00:00
|
|
|
$summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course_section', $section->id);
|
2009-02-17 16:18:05 +00:00
|
|
|
$summaryformatoptions = new object();
|
|
|
|
$summaryformatoptions->noclean = true;
|
|
|
|
|
|
|
|
echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions);
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2005-03-07 17:24:32 +00:00
|
|
|
if ($editing) {
|
|
|
|
$streditsummary = get_string('editsummary');
|
|
|
|
echo "<a title=\"$streditsummary\" ".
|
2009-12-16 21:50:45 +00:00
|
|
|
" href=\"course/editsection.php?id=$section->id\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" ".
|
2007-01-08 09:14:05 +00:00
|
|
|
" class=\"iconsmall\" alt=\"$streditsummary\" /></a><br /><br />";
|
2005-03-07 17:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
|
|
|
print_section($SITE, $section, $mods, $modnamesused, true);
|
2007-08-24 04:22:30 +00:00
|
|
|
|
2005-03-07 17:24:32 +00:00
|
|
|
if ($editing) {
|
|
|
|
print_section_add_menus($SITE, $section->section, $modnames);
|
|
|
|
}
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2004-07-02 09:32:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-15 03:43:28 +00:00
|
|
|
if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
|
2006-07-19 12:10:07 +00:00
|
|
|
$frontpagelayout = $CFG->frontpageloggedin;
|
|
|
|
} else {
|
|
|
|
$frontpagelayout = $CFG->frontpage;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (explode(',',$frontpagelayout) as $v) {
|
2005-12-14 21:42:44 +00:00
|
|
|
switch ($v) { /// Display the main part of the front page.
|
2007-12-19 17:35:20 +00:00
|
|
|
case FRONTPAGENEWS:
|
2005-12-14 21:42:44 +00:00
|
|
|
if ($SITE->newsitems) { // Print forums only when needed
|
|
|
|
require_once($CFG->dirroot .'/mod/forum/lib.php');
|
|
|
|
|
|
|
|
if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
|
2008-04-30 04:09:29 +00:00
|
|
|
print_error('cannotfindorcreateforum', 'forum');
|
2005-12-14 21:42:44 +00:00
|
|
|
}
|
|
|
|
|
2006-09-02 11:44:04 +00:00
|
|
|
if (!empty($USER->id)) {
|
2005-12-14 21:42:44 +00:00
|
|
|
$SESSION->fromdiscussion = $CFG->wwwroot;
|
2009-03-03 01:03:56 +00:00
|
|
|
$subtext = '';
|
2008-04-13 19:15:02 +00:00
|
|
|
if (forum_is_subscribed($USER->id, $newsforum)) {
|
2009-02-25 05:27:21 +00:00
|
|
|
if (!forum_is_forcesubscribed($newsforum)) {
|
|
|
|
$subtext = get_string('unsubscribe', 'forum');
|
|
|
|
}
|
2005-12-14 21:42:44 +00:00
|
|
|
} else {
|
|
|
|
$subtext = get_string('subscribe', 'forum');
|
|
|
|
}
|
2009-08-06 01:26:12 +00:00
|
|
|
echo $OUTPUT->heading($newsforum->name, 2, 'headingblock header');
|
2007-01-05 16:10:13 +00:00
|
|
|
echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id='.$newsforum->id.'">'.$subtext.'</a></div>';
|
2005-03-08 17:32:08 +00:00
|
|
|
} else {
|
2009-08-06 01:26:12 +00:00
|
|
|
echo $OUTPUT->heading($newsforum->name, 2, 'headingblock header');
|
2005-03-08 17:32:08 +00:00
|
|
|
}
|
2005-12-14 21:42:44 +00:00
|
|
|
|
2006-04-05 01:54:41 +00:00
|
|
|
forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
|
2004-05-28 10:53:54 +00:00
|
|
|
}
|
2005-12-14 21:42:44 +00:00
|
|
|
break;
|
2004-05-28 10:53:54 +00:00
|
|
|
|
2005-12-14 21:42:44 +00:00
|
|
|
case FRONTPAGECOURSELIST:
|
2005-03-08 17:32:08 +00:00
|
|
|
|
2009-10-15 03:43:28 +00:00
|
|
|
if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguestuser() and empty($CFG->disablemycourses)) {
|
2009-08-06 01:26:12 +00:00
|
|
|
echo $OUTPUT->heading(get_string('mycourses'), 2, 'headingblock header');
|
2005-12-14 21:42:44 +00:00
|
|
|
print_my_moodle();
|
2009-10-15 03:43:28 +00:00
|
|
|
} else if ((!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguestuser()) or ($DB->count_records('course') <= FRONTPAGECOURSELIMIT)) {
|
2006-07-19 13:37:09 +00:00
|
|
|
// admin should not see list of courses when there are too many of them
|
2009-08-06 01:26:12 +00:00
|
|
|
echo $OUTPUT->heading(get_string('availablecourses'), 2, 'headingblock header');
|
2007-09-19 07:51:02 +00:00
|
|
|
print_courses(0);
|
2004-05-28 10:53:54 +00:00
|
|
|
}
|
2005-12-14 21:42:44 +00:00
|
|
|
break;
|
2004-05-28 10:53:54 +00:00
|
|
|
|
2006-01-30 22:54:12 +00:00
|
|
|
case FRONTPAGECATEGORYNAMES:
|
|
|
|
|
2009-08-06 01:26:12 +00:00
|
|
|
echo $OUTPUT->heading(get_string('categories'), 2, 'headingblock header');
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_start('generalbox categorybox');
|
2006-07-19 13:16:57 +00:00
|
|
|
print_whole_category_list(NULL, NULL, NULL, -1, false);
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2006-01-30 22:54:12 +00:00
|
|
|
print_course_search('', false, 'short');
|
|
|
|
break;
|
|
|
|
|
2006-07-19 12:10:07 +00:00
|
|
|
case FRONTPAGECATEGORYCOMBO:
|
|
|
|
|
2009-08-06 01:26:12 +00:00
|
|
|
echo $OUTPUT->heading(get_string('categories'), 2, 'headingblock header');
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_start('generalbox categorybox');
|
2006-07-19 12:10:07 +00:00
|
|
|
print_whole_category_list(NULL, NULL, NULL, -1, true);
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2006-07-19 12:10:07 +00:00
|
|
|
print_course_search('', false, 'short');
|
|
|
|
break;
|
|
|
|
|
2005-12-14 21:42:44 +00:00
|
|
|
case FRONTPAGETOPICONLY: // Do nothing!! :-)
|
|
|
|
break;
|
2005-04-02 09:29:59 +00:00
|
|
|
|
2005-12-14 21:42:44 +00:00
|
|
|
}
|
|
|
|
echo '<br />';
|
2004-05-28 10:53:54 +00:00
|
|
|
}
|
|
|
|
|
2009-07-09 07:35:03 +00:00
|
|
|
echo $OUTPUT->footer();
|