/** * @throws UserIDMissingException */ public static function rename() { if ($_GET['id']) { $user = new User($_GET['id']); if ($_GET['nextpage'] == 1) { if ($_POST['username']) { if (User::exist_username($_POST['username']) == true and $_POST['username'] != $user->get_username()) { $page_1_passed = false; $error = "This username is already allocated."; } else { $page_1_passed = true; } } else { $page_1_passed = false; $error = "You must enter a username."; } } elseif ($_GET['nextpage'] > 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("base/user/admin/user/rename.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); if ($_POST['username']) { $template->set_var("username", $_POST['username']); } else { $template->set_var("username", $user->get_username()); } $template->output(); } else { $paramquery = $_GET; $paramquery['action'] = "detail"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($user->set_username($_POST['username'])) { Common_IO::step_proceed($params, "Rename User", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Rename User", "Operation Failed", null); } } } else { throw new UserIDMissingException(); } }
/** * @see AuthInterface::forgot_password() * @param string $username * @param string $name * @return bool */ public function forgot_password($username, $mail) { if ($username and $mail) { $system_log = new SystemLog(null); if (User::exist_username($username)) { $user_id = User::get_user_id_by_username($username); $user = new User($user_id); if ($user->check_mail(strtolower($mail))) { if ($user->get_boolean_user_entry("user_inactive") == false) { $new_password = User::generate_password(); $mail = new Mail(); $mail->set_recipient($user_id); $mail->set_subject("Your New Open-LIMS Password"); $mail->set_text("Your new password: "******"must_change_password", true); // Password sended successfully $system_log->create($user_id, 1, 1, "Password Send", "Forgot Password", "auth.php", null, null); return true; } else { // Error via sending throw new AuthForgotPasswordSendFailedException("", 0); } } else { // Inactive User $system_log->create($user_id, 1, 1, "Inactive User", "Forgot Password", "auth.php", null, null); throw new AuthUserNotFoundException("", 0); } } else { // Wrong E-Mail $system_log->create($user_id, 1, 0, "Wrong E-Mail", "Forgot Password", "auth.php", null, null); throw new AuthUserNotFoundException("", 0); } } else { // User Not Found $system_log->create(null, 1, 0, "User \"" . $username . "\" Not Found", "Forgot Password", "auth.php", null, null); throw new AuthUserNotFoundException("", 0); } } else { throw new AuthUserNotFoundException("", 0); } }