2009-10-15 03:43:28 +00:00
|
|
|
<?php
|
2006-08-23 08:39:15 +00:00
|
|
|
|
2010-09-06 12:01:57 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle 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 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moodle frontpage.
|
|
|
|
*
|
|
|
|
* @package core
|
|
|
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
2006-08-23 08:39:15 +00:00
|
|
|
|
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
|
|
|
|
2012-03-12 13:58:01 +01:00
|
|
|
$urlparams = array();
|
2012-03-30 12:14:41 +08:00
|
|
|
if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && optional_param('redirect', 1, PARAM_BOOL) === 0) {
|
2012-03-12 13:58:01 +01:00
|
|
|
$urlparams['redirect'] = 0;
|
|
|
|
}
|
|
|
|
$PAGE->set_url('/', $urlparams);
|
|
|
|
$PAGE->set_course($SITE);
|
|
|
|
|
2012-05-17 10:09:27 +12:00
|
|
|
// Prevent caching of this page to stop confusion when changing page after making AJAX changes
|
|
|
|
$PAGE->set_cacheable(false);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-10-10 10:17:00 +13:00
|
|
|
$hassiteconfig = has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
|
|
|
|
2009-05-31 14:42:29 +00:00
|
|
|
/// If the site is currently under maintenance, then print a message
|
2011-10-10 10:17:00 +13:00
|
|
|
if (!empty($CFG->maintenance_enabled) and !$hassiteconfig) {
|
2009-05-31 14:42:29 +00:00
|
|
|
print_maintenance_message();
|
|
|
|
}
|
|
|
|
|
2011-10-10 10:17:00 +13:00
|
|
|
if ($hassiteconfig && moodle_needs_upgrading()) {
|
|
|
|
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_home_page() != HOMEPAGE_SITE) {
|
2010-05-13 09:57:43 +00:00
|
|
|
// Redirect logged-in users to My Moodle overview if required
|
|
|
|
if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
|
|
|
|
set_user_preference('user_home_page_preference', HOMEPAGE_SITE);
|
2012-03-30 12:14:41 +08:00
|
|
|
} else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && optional_param('redirect', 1, PARAM_BOOL) === 1) {
|
2010-05-13 09:57:43 +00:00
|
|
|
redirect($CFG->wwwroot .'/my/');
|
2012-03-30 12:14:41 +08:00
|
|
|
} else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) {
|
2010-05-13 09:57:43 +00:00
|
|
|
$PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
|
2009-01-15 22:09:57 +00:00
|
|
|
}
|
2003-05-03 05:57:29 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
if (isloggedin()) {
|
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
|
|
|
|
2010-05-16 16:23:27 +00:00
|
|
|
/// If the hub plugin is installed then we let it take over the homepage here
|
2010-05-14 07:04:17 +00:00
|
|
|
if (get_config('local_hub', 'hubenabled') && file_exists($CFG->dirroot.'/local/hub/lib.php')) {
|
|
|
|
require_once($CFG->dirroot.'/local/hub/lib.php');
|
|
|
|
$hub = new local_hub();
|
2010-10-08 08:54:36 +00:00
|
|
|
$continue = $hub->display_homepage();
|
|
|
|
//display_homepage() return true if the hub home page is not displayed
|
|
|
|
//mostly when search form is not displayed for not logged users
|
|
|
|
if (empty($continue)) {
|
|
|
|
exit;
|
|
|
|
}
|
2010-05-14 07:04:17 +00:00
|
|
|
}
|
|
|
|
|
2009-07-27 10:33:00 +00:00
|
|
|
$PAGE->set_pagetype('site-index');
|
2009-05-06 09:02:48 +00:00
|
|
|
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
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-29 17:26:29 +00:00
|
|
|
echo $OUTPUT->header();
|
2005-01-18 11:05:46 +00:00
|
|
|
|
2011-07-03 15:02:46 +02:00
|
|
|
/// Print Section or custom info
|
MDL-31096 Convert course resource/section javascript to YUI3 Module
AMOS BEGIN
MOV [hideweekfromothers,moodle],[hidefromothers,format_week]
MOV [showweekfromothers,moodle],[showfromothers,format_week]
MOV [hidetopicfromothers,moodle],[hidefromothers,format_topics]
MOV [showtopicfromothers,moodle],[showfromothers,format_topics]
AMOS END
2012-01-05 16:53:02 +00:00
|
|
|
get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
2011-07-03 15:02:46 +02:00
|
|
|
if (!empty($CFG->customfrontpageinclude)) {
|
|
|
|
include($CFG->customfrontpageinclude);
|
|
|
|
|
|
|
|
} else 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
|
2012-03-30 19:02:58 +02:00
|
|
|
$section = new stdClass();
|
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 = '';
|
2010-06-10 18:25:06 +00:00
|
|
|
$section->summaryformat = FORMAT_HTML;
|
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);
|
2012-04-02 12:16:13 +01:00
|
|
|
rebuild_course_cache($SITE->id, true);
|
2004-07-09 05:33:07 +00:00
|
|
|
}
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2010-07-03 13:37:13 +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);
|
2010-07-03 13:37:13 +00:00
|
|
|
$summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id);
|
2010-09-21 08:44:02 +00:00
|
|
|
$summaryformatoptions = new stdClass();
|
2009-02-17 16:18:05 +00:00
|
|
|
$summaryformatoptions->noclean = true;
|
2010-11-05 02:53:47 +00:00
|
|
|
$summaryformatoptions->overflowdiv = true;
|
2009-02-17 16:18:05 +00:00
|
|
|
|
2010-05-27 03:07:54 +00:00
|
|
|
echo format_text($summarytext, $section->summaryformat, $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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2012-05-14 09:48:04 +01:00
|
|
|
include_course_ajax($SITE, $modnamesused, $modnames);
|
MDL-31096 Convert course resource/section javascript to YUI3 Module
AMOS BEGIN
MOV [hideweekfromothers,moodle],[hidefromothers,format_week]
MOV [showweekfromothers,moodle],[showfromothers,format_week]
MOV [hidetopicfromothers,moodle],[hidefromothers,format_topics]
MOV [showtopicfromothers,moodle],[showfromothers,format_topics]
AMOS END
2012-01-05 16:53:02 +00:00
|
|
|
|
2004-07-02 09:32:17 +00:00
|
|
|
|
2010-07-03 13:37:13 +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;
|
|
|
|
}
|
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
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
|
|
|
}
|
2011-08-29 14:24:27 +02:00
|
|
|
|
|
|
|
// fetch news forum context for proper filtering to happen
|
|
|
|
$newsforumcm = get_coursemodule_from_instance('forum', $newsforum->id, $SITE->id, false, MUST_EXIST);
|
|
|
|
$newsforumcontext = get_context_instance(CONTEXT_MODULE, $newsforumcm->id, MUST_EXIST);
|
|
|
|
|
|
|
|
$forumname = format_string($newsforum->name, true, array('context' => $newsforumcontext));
|
2012-01-21 13:34:14 +01:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block'));
|
2005-12-14 21:42:44 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
if (isloggedin()) {
|
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');
|
|
|
|
}
|
2011-08-29 14:24:27 +02:00
|
|
|
echo $OUTPUT->heading($forumname, 2, 'headingblock header');
|
2011-01-05 12:40:38 +01:00
|
|
|
$suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $newsforum->id, 'sesskey' => sesskey()));
|
|
|
|
echo html_writer::tag('div', html_writer::link($suburl, $subtext), array('class' => 'subscribelink'));
|
2005-03-08 17:32:08 +00:00
|
|
|
} else {
|
2011-08-29 14:24:27 +02:00
|
|
|
echo $OUTPUT->heading($forumname, 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');
|
2010-06-23 08:54:19 +00:00
|
|
|
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipsitenews'));
|
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
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
case FRONTPAGECOURSELIST:
|
2011-10-10 10:17:00 +13:00
|
|
|
if (isloggedin() and !$hassiteconfig and !isguestuser() and empty($CFG->disablemycourses)) {
|
2012-01-21 13:34:14 +01:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block'));
|
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();
|
2010-06-23 08:54:19 +00:00
|
|
|
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipmycourses'));
|
2011-10-10 10:17:00 +13:00
|
|
|
} else if ((!$hassiteconfig 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
|
2012-01-21 13:34:14 +01:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block'));
|
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);
|
2010-06-23 08:54:19 +00:00
|
|
|
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipavailablecourses'));
|
2010-07-03 13:37:13 +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:
|
2012-01-21 13:34:14 +01:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block'));
|
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');
|
2010-06-23 08:54:19 +00:00
|
|
|
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipcategories'));
|
2006-01-30 22:54:12 +00:00
|
|
|
break;
|
|
|
|
|
2006-07-19 12:10:07 +00:00
|
|
|
case FRONTPAGECATEGORYCOMBO:
|
2012-01-21 13:34:14 +01:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block'));
|
2010-06-23 08:54:19 +00:00
|
|
|
echo $OUTPUT->heading(get_string('courses'), 2, 'headingblock header');
|
2010-05-27 01:40:11 +00:00
|
|
|
$renderer = $PAGE->get_renderer('core','course');
|
2011-03-14 17:04:06 +08:00
|
|
|
// if there are too many courses, budiling course category tree could be slow,
|
|
|
|
// users should go to course index page to see the whole list.
|
|
|
|
$coursecount = $DB->count_records('course');
|
|
|
|
if (empty($CFG->numcoursesincombo)) {
|
|
|
|
// if $CFG->numcoursesincombo hasn't been set, use default value 500
|
|
|
|
$CFG->numcoursesincombo = 500;
|
|
|
|
}
|
|
|
|
if ($coursecount > $CFG->numcoursesincombo) {
|
|
|
|
$link = new moodle_url('/course/');
|
|
|
|
echo $OUTPUT->notification(get_string('maxnumcoursesincombo', 'moodle', array('link'=>$link->out(), 'maxnumofcourses'=>$CFG->numcoursesincombo, 'numberofcourses'=>$coursecount)));
|
|
|
|
} else {
|
|
|
|
echo $renderer->course_category_tree(get_course_category_tree());
|
|
|
|
}
|
2006-07-19 12:10:07 +00:00
|
|
|
print_course_search('', false, 'short');
|
2010-06-23 08:54:19 +00:00
|
|
|
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipcourses'));
|
2006-07-19 12:10:07 +00:00
|
|
|
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();
|