+ function reset_password($company, $email) {
+ global $SysPrefs;
+
+ $this->set_company($company);
+ $this->logged = false;
+
+ set_global_connection();
+
+ $user = get_user_by_email($email);
+
+ if ($user != false) {
+
+ $password = generate_password();
+ $hash = md5($password);
+
+ update_user_password($user['id'], $user['user_id'], $hash);
+
+ $sender = get_company_pref('email');
+ if (empty($sender))
+ $header = "";
+ else
+ $header = "From: $sender";
+
+ mail($email, _("New password for")." ".$SysPrefs->app_title, $password, $header);
+
+ return true;
+ }
+ return false;
+ }
+