Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-19608 fixed potential issue when too many users selected, replace…

…d redirect by continue
  • Loading branch information...
commit 61b7eaffa72e09f1d1fa8a6b115cbe28c66b0a48 1 parent 0a4b736
Petr Skoda skodak authored
Showing with 19 additions and 13 deletions.
  1. +19 −13 admin/user/user_bulk_forcepasswordchange.php
32 admin/user/user_bulk_forcepasswordchange.php
View
@@ -4,6 +4,7 @@
*/
require_once('../../config.php');
+require_once('lib.php');
require_once($CFG->libdir.'/adminlib.php');
$confirm = optional_param('confirm', 0, PARAM_BOOL);
@@ -20,29 +21,34 @@
admin_externalpage_print_header();
-//TODO: add support for large number of users
-
if ($confirm and confirm_sesskey()) {
$primaryadmin = get_admin();
- $in = implode(',', $SESSION->bulk_users);
- if ($rs = get_recordset_select('user', "id IN ($in)")) {
- while ($user = rs_fetch_next_record($rs)) {
- if ($primaryadmin->id != $user->id and $USER->id != $user->id
- and set_user_preference('auth_forcepasswordchange', 1, $user->id)) {
- unset($SESSION->bulk_users[$user->id]);
- } else {
- notify(get_string('forcepasswordchangenot', '', fullname($user, true)));
+ $parts = array_chunk($SESSION->bulk_users, 300);
+ foreach ($parts as $users) {
+ $in = implode(',', $users);
+ if ($rs = get_recordset_select('user', "id IN ($in)")) {
+ while ($user = rs_fetch_next_record($rs)) {
+ if ($primaryadmin->id != $user->id and $USER->id != $user->id
+ and set_user_preference('auth_forcepasswordchange', 1, $user->id)) {
+ unset($SESSION->bulk_users[$user->id]);
+ } else {
+ notify(get_string('forcepasswordchangenot', '', fullname($user, true)));
+ }
}
+ rs_close($rs);
}
- rs_close($rs);
}
- redirect($return, get_string('changessaved'));
+ notify(get_string('changessaved'), 'notifysuccess');
+ print_continue($return);
} else {
$in = implode(',', $SESSION->bulk_users);
- $userlist = get_records_select_menu('user', "id IN ($in)", 'fullname', 'id,'.sql_fullname().' AS fullname');
+ $userlist = get_records_select_menu('user', "id IN ($in)", 'fullname', 'id,'.sql_fullname().' AS fullname', 0, MAX_BULK_USERS);
$usernames = implode(', ', $userlist);
+ if (count($SESSION->bulk_users) > MAX_BULK_USERS) {
+ $usernames .= ', ...';
+ }
$optionsyes = array();
$optionsyes['confirm'] = 1;
$optionsyes['sesskey'] = sesskey();
Please sign in to comment.
Something went wrong with that request. Please try again.