MDL-37009 function print_course_search() is moved to course renderer
[moodle.git] / course / index.php
CommitLineData
d9cb06dc 1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
2c49fb4c 19 * Lists the course categories
d9cb06dc 20 *
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package course
24 */
25
26require_once("../config.php");
27require_once("lib.php");
28
3f77c158 29$site = get_site();
d2b6ba70 30
9a5e297b 31$systemcontext = context_system::instance();
29aab4ac 32
a6855934 33$PAGE->set_url('/course/index.php');
d9cb06dc 34$PAGE->set_context($systemcontext);
c07dfe70 35$PAGE->set_pagelayout('admin');
f4b571ab 36$courserenderer = $PAGE->get_renderer('core', 'course');
f474a4e5 37
2c49fb4c 38if ($CFG->forcelogin) {
d9cb06dc 39 require_login();
d9cb06dc 40}
d2b6ba70 41
2c49fb4c
MG
42$countcategories = $DB->count_records('course_categories');
43if (can_edit_in_category()) {
44 $managebutton = $OUTPUT->single_button(new moodle_url('/course/manage.php'),
45 get_string('managecourses'), 'get');
d9cb06dc 46}
d9cb06dc 47
2c49fb4c
MG
48$showaddcoursebutton = true;
49if ($countcategories > 1 || ($countcategories == 1 && $DB->count_records('course') > 200)) {
50 $strcategories = get_string('categories');
d9cb06dc 51
2c49fb4c
MG
52 $PAGE->set_title("$site->shortname: $strcategories");
53 $PAGE->set_heading($COURSE->fullname);
54 if (isset($managebutton)) {
55 $PAGE->set_button($managebutton);
d9cb06dc 56 }
61ef8f9f 57 echo $OUTPUT->header();
2c49fb4c
MG
58 echo $OUTPUT->heading($strcategories);
59 echo $OUTPUT->skip_link_target();
60 echo $OUTPUT->box_start('categorybox');
61 print_whole_category_list();
62 echo $OUTPUT->box_end();
f4b571ab 63 echo $courserenderer->course_search_form();
2c49fb4c
MG
64} else {
65 $strfulllistofcourses = get_string('fulllistofcourses');
d9cb06dc 66
2c49fb4c
MG
67 $PAGE->set_title("$site->shortname: $strfulllistofcourses");
68 $PAGE->set_heading($COURSE->fullname);
69 if (isset($managebutton)) {
70 $PAGE->set_button($managebutton);
0cbe8111 71 }
2c49fb4c
MG
72 echo $OUTPUT->header();
73 echo $OUTPUT->skip_link_target();
74 echo $OUTPUT->box_start('courseboxes');
75 $showaddcoursebutton = print_courses(0);
76 echo $OUTPUT->box_end();
d9cb06dc 77}
78
2c49fb4c
MG
79echo $OUTPUT->container_start('buttons');
80if (has_capability('moodle/course:create', $systemcontext) && $showaddcoursebutton) {
81 // Print link to create a new course, for the 1st available category.
82 $options = array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat');
5c2ed7e2 83 echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get');
d9cb06dc 84}
d9cb06dc 85print_course_request_buttons($systemcontext);
2c49fb4c 86echo $OUTPUT->container_end();
d9cb06dc 87echo $OUTPUT->footer();