MDL-21437 data - checkbox and multimenu fields search working + require all too
[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');
6db3eee0
SH
27require_once("$CFG->dirroot/enrol/locallib.php");
28require_once("$CFG->dirroot/enrol/renderer.php");
29require_once("$CFG->dirroot/group/lib.php");
df997f84
PS
30
31$id = required_param('id', PARAM_INT); // course id
32$action = optional_param('action', '', PARAM_ACTION);
6db3eee0 33$filter = optional_param('ifilter', 0, PARAM_INT);
df997f84
PS
34
35$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
36$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
37
38require_login($course);
39require_capability('moodle/role:assign', $context);
40
41if ($course->id == SITEID) {
42 redirect("$CFG->wwwroot/");
43}
44
6db3eee0 45$PAGE->set_url('/enrol/otherusers.php', array('id'=>$course->id));
df997f84
PS
46$PAGE->set_pagelayout('admin');
47
6db3eee0
SH
48$manager = new course_enrolment_manager($course, $filter);
49$table = new course_enrolment_other_users_table($manager, $PAGE->url);
50$pageurl = new moodle_url($PAGE->url, $manager->get_url_params()+$table->get_url_params());
df997f84 51
6db3eee0
SH
52/***
53 * Actions will go here
54 */
df997f84 55
6db3eee0
SH
56/*$fields = array(
57 'userdetails' => array (
58 'picture' => false,
59 'firstname' => get_string('firstname'),
60 'lastname' => get_string('lastname'),
61 'email' => get_string('email')
62 ),
63 'lastseen' => get_string('lastaccess'),
64 'role' => array(
65 'roles' => get_string('roles', 'role'),
66 'context' => get_string('context')
67 )
68);*/
69$fields = array(
70 'userdetails' => array (
71 'picture' => false,
72 'firstname' => get_string('firstname'),
73 'lastname' => get_string('lastname'),
74 'email' => get_string('email')
75 ),
76 'lastseen' => get_string('lastaccess'),
77 'role' => get_string('roles', 'role')
78);
9f49935e 79$table->set_fields($fields, $OUTPUT);
6db3eee0
SH
80
81//$users = $manager->get_other_users($table->sort, $table->sortdirection, $table->page, $table->perpage);
82
83$renderer = $PAGE->get_renderer('core_enrol');
84$canassign = has_capability('moodle/role:assign', $manager->get_context());
85$users = $manager->get_other_users_for_display($renderer, $pageurl, $table->sort, $table->sortdirection, $table->page, $table->perpage);
9f15347e 86$assignableroles = $manager->get_assignable_roles(true);
6db3eee0
SH
87foreach ($users as $userid=>&$user) {
88 $user['picture'] = $OUTPUT->render($user['picture']);
89 $user['role'] = $renderer->user_roles_and_actions($userid, $user['roles'], $assignableroles, $canassign, $pageurl);
90}
df997f84 91
6db3eee0
SH
92$table->set_total_users($manager->get_total_other_users());
93$table->set_users($users);
df997f84 94
6db3eee0
SH
95$PAGE->set_title($course->fullname.': '.get_string('totalotherusers', 'enrol', $manager->get_total_other_users()));
96$PAGE->set_heading($PAGE->title);
df997f84 97
6db3eee0
SH
98echo $OUTPUT->header();
99echo $renderer->render($table);
df997f84 100echo $OUTPUT->footer();