MDL-23187 Generic ratings and comments permissions now appear on course pages, AND...
[moodle.git] / enrol / otherusers.php
CommitLineData
df997f84
PS
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/**
18 * List and modify users that are not enrolled but still have a role in course.
19 *
20 * @package core
21 * @subpackage enrol
22 * @copyright 2010 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26require('../config.php');
27
28$id = required_param('id', PARAM_INT); // course id
29$action = optional_param('action', '', PARAM_ACTION);
30$confirm = optional_param('confirm', 0, PARAM_BOOL);
31
32$ifilter = optional_param('ifilter', 0, PARAM_INT); // only one instance
33$page = optional_param('page', 0, PARAM_INT);
34$perpage = optional_param('perpage', 20, PARAM_INT);
35$sort = optional_param('sort', 'lastname', PARAM_ALPHA);
36$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
37
38$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
39$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
40
41require_login($course);
42require_capability('moodle/role:assign', $context);
43
44if ($course->id == SITEID) {
45 redirect("$CFG->wwwroot/");
46}
47
48$instances = enrol_get_instances($course->id, true);
49$plugins = enrol_get_plugins(true);
50$inames = array();
51foreach ($instances as $k=>$i) {
52 if (!isset($plugins[$i->enrol])) {
53 // weird, some broken stuff in plugin
54 unset($instances[$k]);
55 continue;
56 }
57 $inames[$k] = $plugins[$i->enrol]->get_instance_name($i);
58}
59
60// validate paging params
61if ($ifilter != 0 and !isset($instances[$ifilter])) {
62 $ifilter = 0;
63}
64if ($perpage < 3) {
65 $perpage = 3;
66}
67if ($page < 0) {
68 $page = 0;
69}
70if (!in_array($dir, array('ASC', 'DESC'))) {
71 $dir = 'ASC';
72}
73if (!in_array($sort, array('firstname', 'lastname', 'email', 'lastseen'))) {
74 $dir = 'lastname';
75}
76
77$PAGE->set_url('/enrol/notenrolled.php', array('id'=>$course->id, 'page'=>$page, 'sort'=>$sort, 'dir'=>$dir, 'perpage'=>$perpage, 'ifilter'=>$ifilter));
78$PAGE->set_pagelayout('admin');
79
80//lalala- nav hack
81navigation_node::override_active_url(new moodle_url('/enrol/otherusers.php', array('id'=>$course->id)));
82
83echo $OUTPUT->header();
84
85//TODO: MDL-22854 add some new role related UI for users that are not enrolled but still got a role somehow in this course context
86
87notify('This page is not implemented yet, sorry. See MDL-21782 in our tracker for more information.');
88
89echo $OUTPUT->single_button(new moodle_url('/admin/roles/assign.php', array('contextid'=>$context->id)), 'Continue to old Assign roles UI');
90
91echo $OUTPUT->footer();