|
26 | 26 | require_once(__DIR__ . '/../../../config.php');
|
27 | 27 | require_once($CFG->libdir . '/adminlib.php');
|
28 | 28 |
|
29 |
| -admin_externalpage_setup('userbulk'); |
| 29 | +admin_externalpage_setup('tool_emailutils_bounces'); |
30 | 30 | require_capability('moodle/user:update', context_system::instance());
|
31 | 31 |
|
32 | 32 | $confirm = optional_param('confirm', 0, PARAM_BOOL);
|
| 33 | +$userid = optional_param('id', null, PARAM_INT); |
| 34 | +$returnurl = optional_param('returnurl', null, PARAM_LOCALURL); |
33 | 35 |
|
34 |
| -$return = new moodle_url('/admin/user/user_bulk.php'); |
| 36 | +$users = empty($userid) ? $SESSION->bulk_users : [$userid]; |
| 37 | +$return = new moodle_url($returnurl ?? '/admin/tool/emailutils/bounces.php'); |
35 | 38 |
|
36 |
| -if (empty($SESSION->bulk_users)) { |
| 39 | +if (empty($users)) { |
37 | 40 | redirect($return);
|
38 | 41 | }
|
39 | 42 |
|
40 | 43 | echo $OUTPUT->header();
|
41 | 44 | echo $OUTPUT->heading(get_string('resetbounces', 'tool_emailutils'));
|
42 | 45 |
|
43 | 46 | if ($confirm && confirm_sesskey()) {
|
44 |
| - list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); |
| 47 | + list($in, $params) = $DB->get_in_or_equal($users); |
45 | 48 | $rs = $DB->get_recordset_select('user', "id $in", $params, '', 'id, ' . \tool_emailutils\helper::get_username_fields());
|
46 | 49 | foreach ($rs as $user) {
|
47 | 50 | \tool_emailutils\helper::reset_bounce_count($user);
|
|
50 | 53 | echo $OUTPUT->box_start('generalbox', 'notice');
|
51 | 54 | echo $OUTPUT->notification(get_string('bouncesreset', 'tool_emailutils'), 'notifysuccess');
|
52 | 55 |
|
53 |
| - $continue = new single_button(new moodle_url($return), get_string('continue'), 'post'); |
| 56 | + $continue = new single_button(new moodle_url($return), get_string('continue')); |
54 | 57 | echo $OUTPUT->render($continue);
|
55 | 58 | echo $OUTPUT->box_end();
|
56 | 59 | } else {
|
57 |
| - list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); |
| 60 | + list($in, $params) = $DB->get_in_or_equal($users); |
58 | 61 | $userlist = $DB->get_records_select_menu('user', "id $in", $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');
|
59 |
| - $usernames = implode(', ', $userlist); |
60 |
| - echo $OUTPUT->heading(get_string('confirmation', 'admin')); |
61 |
| - $formcontinue = new single_button(new moodle_url('reset_bounces.php', ['confirm' => 1]), get_string('yes')); |
62 |
| - $formcancel = new single_button(new moodle_url('/admin/user/user_bulk.php'), get_string('no'), 'get'); |
63 |
| - echo $OUTPUT->confirm(get_string('bouncecheckfull', 'tool_emailutils', $usernames), $formcontinue, $formcancel); |
| 62 | + |
| 63 | + if (empty($userlist)) { |
| 64 | + echo $OUTPUT->notification(get_string('invaliduserid', 'error')); |
| 65 | + $continue = new single_button(new moodle_url($return), get_string('continue')); |
| 66 | + echo $OUTPUT->render($continue); |
| 67 | + } else { |
| 68 | + $usernames = implode(', ', $userlist); |
| 69 | + $params = array_filter([ |
| 70 | + 'confirm' => 1, |
| 71 | + 'id' => $userid, |
| 72 | + 'returnurl' => $returnurl, |
| 73 | + ]); |
| 74 | + $formcontinue = new single_button(new moodle_url('reset_bounces.php', $params), get_string('yes')); |
| 75 | + $formcancel = new single_button($return, get_string('no')); |
| 76 | + echo $OUTPUT->confirm(get_string('bouncecheckfull', 'tool_emailutils', $usernames), $formcontinue, $formcancel); |
| 77 | + } |
64 | 78 | }
|
65 | 79 | echo $OUTPUT->footer();
|
0 commit comments