2009-09-25 05:24:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// 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/>.
|
|
|
|
|
|
|
|
/**
|
2013-01-29 15:06:37 +11:00
|
|
|
* Lists the course categories
|
2009-09-25 05:24:13 +00:00
|
|
|
*
|
|
|
|
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @package course
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once("../config.php");
|
2013-04-09 12:21:05 +10:00
|
|
|
require_once($CFG->dirroot. '/course/lib.php');
|
2009-09-25 05:24:13 +00:00
|
|
|
|
2013-04-09 12:21:05 +10:00
|
|
|
$categoryid = optional_param('categoryid', 0, PARAM_INT); // Category id
|
2009-11-01 09:10:09 +00:00
|
|
|
$site = get_site();
|
2003-08-07 16:01:31 +00:00
|
|
|
|
2018-06-21 13:34:59 +08:00
|
|
|
if ($CFG->forcelogin) {
|
|
|
|
require_login();
|
|
|
|
}
|
|
|
|
|
|
|
|
$heading = $site->fullname;
|
2013-04-09 12:21:05 +10:00
|
|
|
if ($categoryid) {
|
2018-06-21 13:34:59 +08:00
|
|
|
$category = core_course_category::get($categoryid); // This will validate access.
|
2013-04-09 12:21:05 +10:00
|
|
|
$PAGE->set_category_by_id($categoryid);
|
|
|
|
$PAGE->set_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
|
2013-03-28 16:18:54 +11:00
|
|
|
$PAGE->set_pagetype('course-index-category');
|
2018-06-21 13:34:59 +08:00
|
|
|
$heading = $category->get_formatted_name();
|
|
|
|
} else if ($category = core_course_category::user_top()) {
|
|
|
|
// Check if there is only one top-level category, if so use that.
|
|
|
|
$categoryid = $category->id;
|
|
|
|
$PAGE->set_url('/course/index.php');
|
|
|
|
if ($category->is_uservisible() && $categoryid) {
|
2016-12-08 16:04:27 +08:00
|
|
|
$PAGE->set_category_by_id($categoryid);
|
2018-06-21 13:34:59 +08:00
|
|
|
$PAGE->set_context($category->get_context());
|
|
|
|
if (!core_course_category::is_simple_site()) {
|
|
|
|
$PAGE->set_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
|
|
|
|
$heading = $category->get_formatted_name();
|
|
|
|
}
|
2016-12-08 16:04:27 +08:00
|
|
|
} else {
|
|
|
|
$PAGE->set_context(context_system::instance());
|
|
|
|
}
|
2018-06-21 13:34:59 +08:00
|
|
|
$PAGE->set_pagetype('course-index-category');
|
|
|
|
} else {
|
|
|
|
throw new moodle_exception('cannotviewcategory');
|
2013-04-09 12:21:05 +10:00
|
|
|
}
|
2004-01-14 08:27:40 +00:00
|
|
|
|
2013-04-09 12:21:05 +10:00
|
|
|
$PAGE->set_pagelayout('coursecategory');
|
2022-02-22 12:03:32 +08:00
|
|
|
$PAGE->set_primary_active_tab('home');
|
2021-10-04 16:57:04 +02:00
|
|
|
$PAGE->add_body_class('limitedwidth');
|
2013-03-06 16:40:07 +11:00
|
|
|
$courserenderer = $PAGE->get_renderer('core', 'course');
|
2009-05-07 08:55:10 +00:00
|
|
|
|
2018-06-21 13:34:59 +08:00
|
|
|
$PAGE->set_heading($heading);
|
2013-04-09 12:21:05 +10:00
|
|
|
$content = $courserenderer->course_category($categoryid);
|
2009-09-25 05:24:13 +00:00
|
|
|
|
2021-09-08 09:04:19 +05:30
|
|
|
$PAGE->set_secondary_active_tab('categorymain');
|
|
|
|
|
2013-03-19 15:45:55 +11:00
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->skip_link_target();
|
|
|
|
echo $content;
|
2009-09-25 05:24:13 +00:00
|
|
|
|
2016-09-13 19:23:59 -04:00
|
|
|
// Trigger event, course category viewed.
|
|
|
|
$eventparams = array('context' => $PAGE->context, 'objectid' => $categoryid);
|
|
|
|
$event = \core\event\course_category_viewed::create($eventparams);
|
|
|
|
$event->trigger();
|
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
echo $OUTPUT->footer();
|