MDL-42609 course: management default missing bits
[moodle.git] / course / manage.php
CommitLineData
2c49fb4c
MG
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
4d26b7f6 18 * Allows the admin to create, delete and rename course categories rearrange courses
2c49fb4c 19 *
5dc361e1
SH
20 * This script has been deprecated since Moodle 2.6.
21 * Please update your links as
22 *
23 * @deprecated
24 * @todo remove in 2.7 MDL-41502
25 * @package core_course
2c49fb4c
MG
26 * @copyright 2013 Marina Glancy
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 */
29
30require_once("../config.php");
31require_once($CFG->dirroot.'/course/lib.php');
deb65ced 32require_once($CFG->libdir.'/coursecatlib.php');
2c49fb4c 33
5dc361e1
SH
34$id = optional_param('categoryid', 0, PARAM_INT); // Category id.
35$page = optional_param('page', 0, PARAM_INT); // Which page to show.
36$perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); // How many per page.
37$search = optional_param('search', '', PARAM_RAW); // Search words.
837d548e 38$blocklist = optional_param('blocklist', 0, PARAM_INT);
5dc361e1
SH
39$modulelist = optional_param('modulelist', '', PARAM_PLUGIN);
40
41debugging('This script has been deprecated and will be removed in the future. Please update any bookmarks you have.',
42 DEBUG_DEVELOPER);
43
44// Look for legacy actions.
45// If there are any we're going to make and equivalent request to management.php.
46$sesskey = optional_param('sesskey', null, PARAM_RAW);
47if ($sesskey !== null && confirm_sesskey($sesskey)) {
48 // Actions to manage categories.
49 $deletecat = optional_param('deletecat', 0, PARAM_INT);
50 $hidecat = optional_param('hidecat', 0, PARAM_INT);
51 $showcat = optional_param('showcat', 0, PARAM_INT);
52 $movecat = optional_param('movecat', 0, PARAM_INT);
53 $movetocat = optional_param('movetocat', -1, PARAM_INT);
54 $moveupcat = optional_param('moveupcat', 0, PARAM_INT);
55 $movedowncat = optional_param('movedowncat', 0, PARAM_INT);
56
57 // Actions to manage courses.
58 $hide = optional_param('hide', 0, PARAM_INT);
59 $show = optional_param('show', 0, PARAM_INT);
60 $moveup = optional_param('moveup', 0, PARAM_INT);
61 $movedown = optional_param('movedown', 0, PARAM_INT);
62 $moveto = optional_param('moveto', 0, PARAM_INT);
63 $resort = optional_param('resort', 0, PARAM_BOOL);
64
65 $murl = new moodle_url('/course/management.php', array('sesskey' => sesskey()));
66
67 // Process any category actions.
68 if (!empty($deletecat)) {
69 // Redirect to the new management script.
70 redirect(new moodle_url($murl, array('categoryid' => $deletecat, 'action' => 'deletecategory')));
71 }
72
73 if (!empty($movecat) and $movetocat >= 0) {
74 // Redirect to the new management script.
75 redirect(new moodle_url($murl, array(
76 'action' => 'bulkaction',
77 'bulkmovecategories' => true,
78 'movecategoriesto' => $movetocat,
79 'bcat[]' => $movecat
80 )));
81 }
82
83 // Hide or show a category.
84 if ($hidecat) {
85 // Redirect to the new management script.
86 redirect(new moodle_url($murl, array('categoryid' => $hidecat, 'action' => 'hidecategory')));
87 } else if ($showcat) {
88 // Redirect to the new management script.
89 redirect(new moodle_url($murl, array('categoryid' => $showcat, 'action' => 'showcategory')));
90 }
91
92 if (!empty($moveupcat) or !empty($movedowncat)) {
93 // Redirect to the new management script.
94 if (!empty($moveupcat)) {
95 redirect(new moodle_url($murl, array('categoryid' => $moveupcat, 'action' => 'movecategoryup')));
4d26b7f6 96 } else {
5dc361e1 97 redirect(new moodle_url($murl, array('categoryid' => $movedowncat, 'action' => 'movecategorydown')));
2c49fb4c 98 }
2c49fb4c 99 }
2c49fb4c 100
5dc361e1
SH
101 if ($resort && $id) {
102 // Redirect to the new management script.
103 redirect(new moodle_url($murl, array('categoryid' => $id, 'action' => 'resortcategories', 'resort' => 'name')));
2c49fb4c 104 }
4d26b7f6 105
5dc361e1
SH
106 if (!empty($moveto) && ($data = data_submitted())) {
107 // Redirect to the new management script.
108 $courses = array();
109 foreach ($data as $key => $value) {
110 if (preg_match('/^c\d+$/', $key)) {
111 $courses[] = substr($key, 1);
2c49fb4c
MG
112 }
113 }
5dc361e1
SH
114 redirect(new moodle_url($murl, array(
115 'action' => 'bulkaction',
116 'bulkmovecourses' => true,
117 'movecoursesto' => $moveto,
118 'bc' => $courses
119 )));
2c49fb4c
MG
120 }
121
5dc361e1
SH
122 if (!empty($hide) or !empty($show)) {
123 // Redirect to the new management script.
124 if (!empty($hide)) {
125 redirect(new moodle_url($murl, array('courseid' => $hide, 'action' => 'hidecourse')));
2c49fb4c 126 } else {
5dc361e1 127 redirect(new moodle_url($murl, array('courseid' => $show, 'action' => 'showcourse')));
2c49fb4c 128 }
2c49fb4c
MG
129 }
130
5dc361e1
SH
131 if (!empty($moveup) or !empty($movedown)) {
132 // Redirect to the new management script.
133 if (!empty($moveup)) {
134 redirect(new moodle_url($murl, array('courseid' => $moveup, 'action' => 'movecourseup')));
135 } else {
136 redirect(new moodle_url($murl, array('courseid' => $movedown, 'action' => 'movecoursedown')));
837d548e 137 }
2c49fb4c 138 }
2c49fb4c 139}
2c49fb4c 140
5dc361e1
SH
141// Now check if its a search or not. If its not we'll head to the new management page.
142$url = new moodle_url('/course/management.php');
143if ($id !== 0) {
144 // We've got an ID it can't be a search.
145 $url->param('categoryid', $id);
146} else {
147 // No $id, perhaps its a search.
148 if ($search !== '') {
149 $url->param('search', $search);
2c49fb4c 150 }
5dc361e1
SH
151 if ($blocklist !== 0) {
152 $url->param('blocklist', $blocklist);
2c49fb4c 153 }
5dc361e1
SH
154 if ($modulelist !== '') {
155 $url->param('modulelist', $modulelist);
2c49fb4c 156 }
ef5a8210 157}
5dc361e1 158redirect($url);