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);
|
2013-06-05 18:06:56 +10:00
|
|
|
$PAGE->set_other_editing_capability('moodle/course:update');
|
|
|
|
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
|
|
|
$PAGE->set_other_editing_capability('moodle/course:activityvisibility');
|
2012-03-12 13:58:01 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-02 11:20:48 +08:00
|
|
|
$hassiteconfig = has_capability('moodle/site:config', context_system::instance());
|
2011-10-10 10:17:00 +13:00
|
|
|
|
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
|
2012-05-15 15:40:22 +02:00
|
|
|
if (file_exists($CFG->dirroot.'/local/hub/lib.php') and get_config('local_hub', 'hubenabled')) {
|
2010-05-14 07:04:17 +00:00
|
|
|
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 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);
|
2013-03-06 16:40:07 +11:00
|
|
|
$courserenderer = $PAGE->get_renderer('core', 'course');
|
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
|
2012-11-02 14:32:17 +08:00
|
|
|
$siteformatoptions = course_get_format($SITE)->get_format_options();
|
2012-09-25 10:34:18 +08:00
|
|
|
$modinfo = get_fast_modinfo($SITE);
|
|
|
|
$modnames = get_module_types_names();
|
|
|
|
$modnamesplural = get_module_types_names(true);
|
|
|
|
$modnamesused = $modinfo->get_used_module_names();
|
|
|
|
$mods = $modinfo->get_cms();
|
|
|
|
|
2011-07-03 15:02:46 +02:00
|
|
|
if (!empty($CFG->customfrontpageinclude)) {
|
|
|
|
include($CFG->customfrontpageinclude);
|
|
|
|
|
2012-11-02 14:32:17 +08:00
|
|
|
} else if ($siteformatoptions['numsections'] > 0) {
|
2012-09-25 10:34:18 +08:00
|
|
|
if ($editing) {
|
2012-10-08 10:36:01 +08:00
|
|
|
// make sure section with number 1 exists
|
|
|
|
course_create_sections_if_missing($SITE, 1);
|
2012-09-25 10:34:18 +08:00
|
|
|
// re-request modinfo in case section was created
|
|
|
|
$modinfo = get_fast_modinfo($SITE);
|
2004-07-09 05:33:07 +00:00
|
|
|
}
|
2012-09-25 10:34:18 +08:00
|
|
|
$section = $modinfo->get_section_info(1);
|
|
|
|
if (($section && (!empty($modinfo->sections[1]) 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
|
|
|
|
2012-08-02 11:20:48 +08:00
|
|
|
$context = context_course::instance(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
|
|
|
|
2013-06-05 18:06:56 +10:00
|
|
|
if ($editing && has_capability('moodle/course:update', $context)) {
|
2005-03-07 17:24:32 +00:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
2013-01-15 12:14:31 +11:00
|
|
|
$courserenderer = $PAGE->get_renderer('core', 'course');
|
2012-12-14 11:32:21 +08:00
|
|
|
echo $courserenderer->course_section_cm_list($SITE, $section);
|
2007-08-24 04:22:30 +00:00
|
|
|
|
2012-12-14 10:10:45 +08:00
|
|
|
echo $courserenderer->course_section_add_cm_control($SITE, $section->section);
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2004-07-02 09:32:17 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-25 10:20:34 +00:00
|
|
|
// Include course AJAX
|
2012-12-12 13:46:01 +08:00
|
|
|
include_course_ajax($SITE, $modnamesused);
|
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);
|
2012-08-02 11:20:48 +08:00
|
|
|
$newsforumcontext = context_module::instance($newsforumcm->id, MUST_EXIST);
|
2011-08-29 14:24:27 +02:00
|
|
|
|
|
|
|
$forumname = format_string($newsforum->name, true, array('context' => $newsforumcontext));
|
2013-08-06 20:58:28 +02:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block'));
|
2005-12-14 21:42:44 +00:00
|
|
|
|
2012-12-20 17:38:08 +00:00
|
|
|
// wraps site news forum in div container.
|
|
|
|
echo html_writer::start_tag('div', array('id'=>'site-news-forum'));
|
|
|
|
|
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');
|
|
|
|
}
|
2013-10-01 16:42:04 +08:00
|
|
|
echo $OUTPUT->heading($forumname);
|
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 {
|
2013-10-01 16:42:04 +08:00
|
|
|
echo $OUTPUT->heading($forumname);
|
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');
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//end site news forum div container
|
|
|
|
echo html_writer::end_tag('div');
|
|
|
|
|
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
|
|
|
|
2013-03-26 13:04:42 +11:00
|
|
|
case FRONTPAGEENROLLEDCOURSELIST:
|
|
|
|
$mycourseshtml = $courserenderer->frontpage_my_courses();
|
|
|
|
if (!empty($mycourseshtml)) {
|
2013-08-06 20:58:28 +02:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block'));
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//wrap frontpage course list in div container
|
|
|
|
echo html_writer::start_tag('div', array('id'=>'frontpage-course-list'));
|
|
|
|
|
2013-10-01 16:42:04 +08:00
|
|
|
echo $OUTPUT->heading(get_string('mycourses'));
|
2013-03-20 13:04:12 +11:00
|
|
|
echo $mycourseshtml;
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//end frontpage course list div container
|
|
|
|
echo html_writer::end_tag('div');
|
|
|
|
|
2010-06-23 08:54:19 +00:00
|
|
|
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipmycourses'));
|
2013-03-26 13:04:42 +11:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// No "break" here. If there are no enrolled courses - continue to 'Available courses'.
|
|
|
|
|
|
|
|
case FRONTPAGEALLCOURSELIST:
|
|
|
|
$availablecourseshtml = $courserenderer->frontpage_available_courses();
|
|
|
|
if (!empty($availablecourseshtml)) {
|
2013-08-06 20:58:28 +02:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block'));
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//wrap frontpage course list in div container
|
|
|
|
echo html_writer::start_tag('div', array('id'=>'frontpage-course-list'));
|
|
|
|
|
2013-10-01 16:42:04 +08:00
|
|
|
echo $OUTPUT->heading(get_string('availablecourses'));
|
2013-03-26 13:04:42 +11:00
|
|
|
echo $availablecourseshtml;
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//end frontpage course list div container
|
|
|
|
echo html_writer::end_tag('div');
|
|
|
|
|
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:
|
2013-08-06 20:58:28 +02:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block'));
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//wrap frontpage category names in div container
|
|
|
|
echo html_writer::start_tag('div', array('id'=>'frontpage-category-names'));
|
|
|
|
|
2013-10-01 16:42:04 +08:00
|
|
|
echo $OUTPUT->heading(get_string('categories'));
|
2013-03-20 13:04:12 +11:00
|
|
|
echo $courserenderer->frontpage_categories_list();
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//end frontpage category names div container
|
|
|
|
echo html_writer::end_tag('div');
|
|
|
|
|
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:
|
2013-08-06 20:58:28 +02:00
|
|
|
echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block'));
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//wrap frontpage category combo in div container
|
|
|
|
echo html_writer::start_tag('div', array('id'=>'frontpage-category-combo'));
|
|
|
|
|
2013-10-01 16:42:04 +08:00
|
|
|
echo $OUTPUT->heading(get_string('courses'));
|
2013-03-26 13:04:42 +11:00
|
|
|
echo $courserenderer->frontpage_combo_list();
|
2012-12-20 17:38:08 +00:00
|
|
|
|
|
|
|
//end frontpage category combo div container
|
|
|
|
echo html_writer::end_tag('div');
|
|
|
|
|
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;
|
|
|
|
|
2013-03-26 13:04:42 +11:00
|
|
|
case FRONTPAGECOURSESEARCH:
|
|
|
|
echo $OUTPUT->box($courserenderer->course_search_form('', 'short'), 'mdl-align');
|
2005-12-14 21:42:44 +00:00
|
|
|
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
|
|
|
}
|
2013-06-07 15:27:59 +08:00
|
|
|
if ($editing && has_capability('moodle/course:create', context_system::instance())) {
|
|
|
|
echo $courserenderer->add_new_course_button();
|
|
|
|
}
|
2009-07-09 07:35:03 +00:00
|
|
|
echo $OUTPUT->footer();
|