MDL-58659 enroll: Add start and end date fields required by overview
[moodle.git] / admin / user / lib.php
blobaccf4173b3dff1c46e3a88cb94060fd3fa7793af
1 <?php
3 require_once($CFG->dirroot.'/user/filters/lib.php');
5 if (!defined('MAX_BULK_USERS')) {
6 define('MAX_BULK_USERS', 2000);
9 function add_selection_all($ufiltering) {
10 global $SESSION, $DB, $CFG;
12 list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest));
14 $rs = $DB->get_recordset_select('user', $sqlwhere, $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');
15 foreach ($rs as $user) {
16 if (!isset($SESSION->bulk_users[$user->id])) {
17 $SESSION->bulk_users[$user->id] = $user->id;
20 $rs->close();
23 function get_selection_data($ufiltering) {
24 global $SESSION, $DB, $CFG;
26 // get the SQL filter
27 list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest));
29 $total = $DB->count_records_select('user', "id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest));
30 $acount = $DB->count_records_select('user', $sqlwhere, $params);
31 $scount = count($SESSION->bulk_users);
33 $userlist = array('acount'=>$acount, 'scount'=>$scount, 'ausers'=>false, 'susers'=>false, 'total'=>$total);
34 $userlist['ausers'] = $DB->get_records_select_menu('user', $sqlwhere, $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname', 0, MAX_BULK_USERS);
36 if ($scount) {
37 if ($scount < MAX_BULK_USERS) {
38 $bulkusers = $SESSION->bulk_users;
39 } else {
40 $bulkusers = array_slice($SESSION->bulk_users, 0, MAX_BULK_USERS, true);
42 list($in, $inparams) = $DB->get_in_or_equal($bulkusers);
43 $userlist['susers'] = $DB->get_records_select_menu('user', "id $in", $inparams, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');
46 return $userlist;