From 1daab45a7a3eafa242bcfb9cd173c0e27435c095 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 31 May 2013 11:00:40 +0800 Subject: [PATCH] MDL-39863 Administration: Show confirmation/notice and don't redirect automatically --- admin/user/user_bulk_confirm.php | 14 +++++++++++--- admin/user/user_bulk_delete.php | 15 +++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/admin/user/user_bulk_confirm.php b/admin/user/user_bulk_confirm.php index 1483e203ce2..9bfc65bf8cd 100644 --- a/admin/user/user_bulk_confirm.php +++ b/admin/user/user_bulk_confirm.php @@ -23,6 +23,7 @@ echo $OUTPUT->header(); //TODO: add support for large number of users if ($confirm and confirm_sesskey()) { + $notifications = ''; list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); $rs = $DB->get_recordset_select('user', "id $in", $params, '', 'id, username, secret, confirmed, auth, firstname, lastname'); foreach ($rs as $user) { @@ -32,12 +33,19 @@ if ($confirm and confirm_sesskey()) { $auth = get_auth_plugin($user->auth); $result = $auth->user_confirm($user->username, $user->secret); if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) { - echo $OUTPUT->notification(get_string('usernotconfirmed', '', fullname($user, true))); + $notifications .= $OUTPUT->notification(get_string('usernotconfirmed', '', fullname($user, true))); } } $rs->close(); - redirect($return, get_string('changessaved')); - + echo $OUTPUT->box_start('generalbox', 'notice'); + if (!empty($notifications)) { + echo $notifications; + } else { + echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); + } + $continue = new single_button(new moodle_url($return), get_string('continue'), 'post'); + echo $OUTPUT->render($continue); + echo $OUTPUT->box_end(); } else { list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); $userlist = $DB->get_records_select_menu('user', "id $in", $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname'); diff --git a/admin/user/user_bulk_delete.php b/admin/user/user_bulk_delete.php index f8ac0c95343..4dbb75df057 100644 --- a/admin/user/user_bulk_delete.php +++ b/admin/user/user_bulk_delete.php @@ -23,20 +23,27 @@ echo $OUTPUT->header(); //TODO: add support for large number of users if ($confirm and confirm_sesskey()) { - + $notifications = ''; list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); $rs = $DB->get_recordset_select('user', "id $in", $params); foreach ($rs as $user) { if (!is_siteadmin($user) and $USER->id != $user->id and delete_user($user)) { unset($SESSION->bulk_users[$user->id]); } else { - echo $OUTPUT->notification(get_string('deletednot', '', fullname($user, true))); + $notifications .= $OUTPUT->notification(get_string('deletednot', '', fullname($user, true))); } } $rs->close(); session_gc(); // remove stale sessions - redirect($return, get_string('changessaved')); - + echo $OUTPUT->box_start('generalbox', 'notice'); + if (!empty($notifications)) { + echo $notifications; + } else { + echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); + } + $continue = new single_button(new moodle_url($return), get_string('continue'), 'post'); + echo $OUTPUT->render($continue); + echo $OUTPUT->box_end(); } else { list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); $userlist = $DB->get_records_select_menu('user', "id $in", $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');