Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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 * Library code used by the roles administration interfaces. 19 * 20 * @package core_role 21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * User selector subclass for the list of potential users on the assign roles page, 29 * when we are assigning in a context at or above the course level. In this case we 30 * show all the users in the system who do not already have the role. 31 */ 32 class core_role_potential_assignees_course_and_above extends core_role_assign_user_selector_base { 33 public function find_users($search) { 34 global $DB; 35 36 list($wherecondition, $params) = $this->search_sql($search, ''); 37 38 $fields = 'SELECT ' . $this->required_fields_sql(''); 39 $countfields = 'SELECT COUNT(1)'; 40 41 $sql = " FROM {user} 42 WHERE $wherecondition 43 AND id NOT IN ( 44 SELECT r.userid 45 FROM {role_assignments} r 46 WHERE r.contextid = :contextid 47 AND r.roleid = :roleid)"; 48 49 list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext); 50 $order = ' ORDER BY ' . $sort; 51 52 $params['contextid'] = $this->context->id; 53 $params['roleid'] = $this->roleid; 54 55 if (!$this->is_validating()) { 56 $potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params); 57 if ($potentialmemberscount > $this->maxusersperpage) { 58 return $this->too_many_results($search, $potentialmemberscount); 59 } 60 } 61 62 $availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams)); 63 64 if (empty($availableusers)) { 65 return array(); 66 } 67 68 if ($search) { 69 $groupname = get_string('potusersmatching', 'core_role', $search); 70 } else { 71 $groupname = get_string('potusers', 'core_role'); 72 } 73 74 return array($groupname => $availableusers); 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body