+function lostpass_generate_password($user)
+{
+ $o = '';
+ $a = get_app();
+
+ $new_password = User::generateNewPassword();
+ $result = User::updatePassword($user['uid'], $new_password);
+ if (DBM::is_result($result)) {
+ $tpl = get_markup_template('pwdreset.tpl');
+ $o .= replace_macros($tpl, [
+ '$lbl1' => L10n::t('Password Reset'),
+ '$lbl2' => L10n::t('Your password has been reset as requested.'),
+ '$lbl3' => L10n::t('Your new password is'),
+ '$lbl4' => L10n::t('Save or copy your new password - and then'),
+ '$lbl5' => '<a href="' . System::baseUrl() . '">' . L10n::t('click here to login') . '</a>.',
+ '$lbl6' => L10n::t('Your password may be changed from the <em>Settings</em> page after successful login.'),
+ '$newpass' => $new_password,
+ '$baseurl' => System::baseUrl()
+ ]);
+
+ info("Your password has been reset." . EOL);
+
+ $sitename = $a->config['sitename'];
+ $preamble = deindent(L10n::t('
+ Dear %1$s,
+ Your password has been changed as requested. Please retain this
+ information for your records ' . "\x28" . 'or change your password immediately to
+ something that you will remember' . "\x29" . '.
+ ', $user['username']));
+ $body = deindent(L10n::t('
+ Your login details are as follows:
+
+ Site Location: %1$s
+ Login Name: %2$s
+ Password: %3$s
+
+ You may change that password from your account settings page after logging in.
+ ', System::baseUrl(), $user['email'], $new_password));
+
+ notification([
+ 'type' => SYSTEM_EMAIL,
+ 'to_email' => $user['email'],
+ 'uid' => $user['uid'],
+ 'subject' => L10n::t('Your password has been changed at %s', $sitename),
+ 'preamble' => $preamble,
+ 'body' => $body
+ ]);