See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]
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_enrol 21 * @copyright 2010 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require('../config.php'); 26 require_once("$CFG->dirroot/enrol/locallib.php"); 27 require_once("$CFG->dirroot/enrol/renderer.php"); 28 require_once("$CFG->dirroot/group/lib.php"); 29 30 $id = required_param('id', PARAM_INT); // course id 31 $action = optional_param('action', '', PARAM_ALPHANUMEXT); 32 $filter = optional_param('ifilter', 0, PARAM_INT); 33 34 $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); 35 $context = context_course::instance($course->id, MUST_EXIST); 36 37 require_login($course); 38 require_capability('moodle/course:reviewotherusers', $context); 39 40 if ($course->id == SITEID) { 41 redirect("$CFG->wwwroot/"); 42 } 43 44 $PAGE->set_pagelayout('admin'); 45 46 $manager = new course_enrolment_manager($PAGE, $course, $filter); 47 $table = new course_enrolment_other_users_table($manager, $PAGE); 48 $PAGE->set_url('/enrol/otherusers.php', $manager->get_url_params()+$table->get_url_params()); 49 navigation_node::override_active_url(new moodle_url('/enrol/otherusers.php', array('id' => $id))); 50 51 $userdetails = array ( 52 'picture' => false, 53 'userfullnamedisplay' => false, 54 'firstname' => get_string('firstname'), 55 'lastname' => get_string('lastname'), 56 ); 57 // TODO Does not support custom user profile fields (MDL-70456). 58 $extrafields = \core_user\fields::get_identity_fields($context, false); 59 foreach ($extrafields as $field) { 60 $userdetails[$field] = \core_user\fields::get_display_name($field); 61 } 62 63 $fields = array( 64 'userdetails' => $userdetails, 65 'lastaccess' => get_string('lastaccess'), 66 'role' => get_string('roles', 'role') 67 ); 68 69 // Remove hidden fields if the user has no access 70 if (!has_capability('moodle/course:viewhiddenuserfields', $context)) { 71 $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields)); 72 if (isset($hiddenfields['lastaccess'])) { 73 unset($fields['lastaccess']); 74 } 75 } 76 77 $table->set_fields($fields, $OUTPUT); 78 79 //$users = $manager->get_other_users($table->sort, $table->sortdirection, $table->page, $table->perpage); 80 81 $renderer = $PAGE->get_renderer('core_enrol'); 82 $canassign = has_capability('moodle/role:assign', $manager->get_context()); 83 $users = $manager->get_other_users_for_display($renderer, $PAGE->url, $table->sort, $table->sortdirection, $table->page, $table->perpage); 84 $assignableroles = $manager->get_assignable_roles(true); 85 foreach ($users as $userid=>&$user) { 86 $user['picture'] = $OUTPUT->render($user['picture']); 87 $user['role'] = $renderer->user_roles_and_actions($userid, $user['roles'], $assignableroles, $canassign, $PAGE->url); 88 } 89 90 $table->set_total_users($manager->get_total_other_users()); 91 $table->set_users($users); 92 93 $PAGE->set_title($course->fullname.': '.get_string('totalotherusers', 'enrol', $manager->get_total_other_users())); 94 $PAGE->set_heading($PAGE->title); 95 96 echo $OUTPUT->header(); 97 98 // Check we have a search button to render. 99 $searchbuttonrender = null; 100 if ($searchbutton = $table->get_user_search_button()) { 101 $searchbutton->primary = true; 102 $searchbuttonrender = $OUTPUT->render($searchbutton); 103 } 104 105 echo $OUTPUT->render_participants_tertiary_nav($course, $searchbuttonrender); 106 echo $renderer->render($table); 107 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body