Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/admin/user/ -> lib.php (source)
   1  <?php
   2  
   3  require_once($CFG->dirroot.'/user/filters/lib.php');
   4  
   5  if (!defined('MAX_BULK_USERS')) {
   6      define('MAX_BULK_USERS', 2000);
   7  }
   8  
   9  function add_selection_all($ufiltering) {
  10      global $SESSION, $DB, $CFG;
  11  
  12      list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest));
  13  
  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;
  18          }
  19      }
  20      $rs->close();
  21  }
  22  
  23  function get_selection_data($ufiltering) {
  24      global $SESSION, $DB, $CFG;
  25  
  26      // get the SQL filter
  27      list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest));
  28  
  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);
  32  
  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);
  35  
  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);
  41          }
  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');
  44      }
  45  
  46      return $userlist;
  47  }