} if (empty($_GET['uid']) || !($login = trim($_GET['uid']))) { return; } strenc_todb($val); echo change_phone($login, $val); exit; } elseif (isset($_GET['a']) && $_GET['a'] == 'change_role') { if (empty($_GET['val']) || !($val = trim($_GET['val']))) { return; } if (empty($_GET['uid']) || !($login = trim($_GET['uid']))) { return; } strenc_todb($val); echo change_role($login, $val); exit; } elseif (isset($_GET['a']) && $_GET['a'] == 'deluid') { if (empty($_GET['uid']) || !($login = trim($_GET['uid']))) { return; } strenc_todb($val); user_delete($login); header('Location: users.php'); exit; } elseif (isset($_GET['a']) && $_GET['a'] == 'newuid') { if (empty($_GET['val']) || !($login = trim($_GET['val']))) { return; } strenc_todb($val); user_create($login);
// So now we need to: // - build the users list // - loop through the users changing their role for all contexts $role_from = $form_data->role_from; $role_to = $form_data->role_to; $users = $mform_change->get_file_content('usersfile'); if (is_null($role_from) || is_null($role_to) || $role_from === $role_to) { $message = get_string('invalidrole', 'local_roles'); } if (!$users) { $users = $form_data->users; } if (!$message) { $user_array = split_form_data($users); // Here is where the work gets done $successes = change_role($role_from, $role_to, $user_array); $numberChanged = count($successes); $message = "Role changed for {$numberSent} user" . ($numberChanged == 1 ? "" : "s") . "."; } } } $nav = get_string('change_role_nav', 'local_roles'); $title = get_string('change_role_title', 'local_roles'); $PAGE->navbar->add($nav); $PAGE->set_title($title); $PAGE->set_heading($SITE->fullname); echo $OUTPUT->header(); if ($message) { notice($message, "{$CFG->wwwroot}/local/roles/changerole.php"); } else { $mform_change->display();