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");
|
|
|
|
require_once("lib.php");
|
|
|
|
|
2009-11-01 09:10:09 +00:00
|
|
|
$site = get_site();
|
2003-08-07 16:01:31 +00:00
|
|
|
|
2012-07-23 15:59:04 +08:00
|
|
|
$systemcontext = context_system::instance();
|
2004-01-14 08:27:40 +00:00
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$PAGE->set_url('/course/index.php');
|
2009-09-25 05:24:13 +00:00
|
|
|
$PAGE->set_context($systemcontext);
|
2010-05-14 07:07:15 +00:00
|
|
|
$PAGE->set_pagelayout('admin');
|
2009-05-07 08:55:10 +00:00
|
|
|
|
2013-01-29 15:06:37 +11:00
|
|
|
if ($CFG->forcelogin) {
|
2009-09-25 05:24:13 +00:00
|
|
|
require_login();
|
|
|
|
}
|
2003-08-07 16:01:31 +00:00
|
|
|
|
2013-01-29 15:06:37 +11:00
|
|
|
$countcategories = $DB->count_records('course_categories');
|
|
|
|
if (can_edit_in_category()) {
|
|
|
|
$managebutton = $OUTPUT->single_button(new moodle_url('/course/manage.php'),
|
|
|
|
get_string('managecourses'), 'get');
|
2009-09-25 05:24:13 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 15:06:37 +11:00
|
|
|
$showaddcoursebutton = true;
|
|
|
|
if ($countcategories > 1 || ($countcategories == 1 && $DB->count_records('course') > 200)) {
|
|
|
|
$strcategories = get_string('categories');
|
2009-09-25 05:24:13 +00:00
|
|
|
|
2013-01-29 15:06:37 +11:00
|
|
|
$PAGE->set_title("$site->shortname: $strcategories");
|
|
|
|
$PAGE->set_heading($COURSE->fullname);
|
|
|
|
if (isset($managebutton)) {
|
|
|
|
$PAGE->set_button($managebutton);
|
2009-09-25 05:24:13 +00:00
|
|
|
}
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header();
|
2013-01-29 15:06:37 +11:00
|
|
|
echo $OUTPUT->heading($strcategories);
|
|
|
|
echo $OUTPUT->skip_link_target();
|
|
|
|
echo $OUTPUT->box_start('categorybox');
|
|
|
|
print_whole_category_list();
|
|
|
|
echo $OUTPUT->box_end();
|
|
|
|
print_course_search();
|
|
|
|
} else {
|
|
|
|
$strfulllistofcourses = get_string('fulllistofcourses');
|
2009-09-25 05:24:13 +00:00
|
|
|
|
2013-01-29 15:06:37 +11:00
|
|
|
$PAGE->set_title("$site->shortname: $strfulllistofcourses");
|
|
|
|
$PAGE->set_heading($COURSE->fullname);
|
|
|
|
if (isset($managebutton)) {
|
|
|
|
$PAGE->set_button($managebutton);
|
2008-06-16 14:25:53 +00:00
|
|
|
}
|
2013-01-29 15:06:37 +11:00
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->skip_link_target();
|
|
|
|
echo $OUTPUT->box_start('courseboxes');
|
|
|
|
$showaddcoursebutton = print_courses(0);
|
|
|
|
echo $OUTPUT->box_end();
|
2009-09-25 05:24:13 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 15:06:37 +11:00
|
|
|
echo $OUTPUT->container_start('buttons');
|
|
|
|
if (has_capability('moodle/course:create', $systemcontext) && $showaddcoursebutton) {
|
|
|
|
// Print link to create a new course, for the 1st available category.
|
|
|
|
$options = array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat');
|
2010-01-03 15:46:14 +00:00
|
|
|
echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get');
|
2009-09-25 05:24:13 +00:00
|
|
|
}
|
|
|
|
print_course_request_buttons($systemcontext);
|
2013-01-29 15:06:37 +11:00
|
|
|
echo $OUTPUT->container_end();
|
2009-09-25 05:24:13 +00:00
|
|
|
echo $OUTPUT->footer();
|