Rerun. Fixed wrong calculaiton of standard cost during Advanced Manufacturing. Petros
[fa-stable.git] / includes / current_user.inc
index 7c7592e8139fa4da2c06e21941ae30305635c2d8..515f6e4e0d57bcd8f04e3c62cd0ff7d3918e0586 100644 (file)
@@ -131,6 +131,32 @@ class current_user
                return $this->logged;
        }
 
+       function reset_password($company, $email) {
+               global $app_title;
+
+               $this->set_company($company);
+               $this->logged = false;
+
+               set_global_connection();
+
+               $user = get_user_by_email($email);
+
+               if ($user != false) {
+
+                       $bytes = openssl_random_pseudo_bytes(8, $cstrong);
+                       $password   = base64_encode($bytes);
+
+                       $hash = md5($password);
+
+                       update_user_password($user['id'], $user['user_id'], $hash);
+
+                       mail($user['email'], _("New password for")." ".$app_title, $password);
+
+                       return true;
+               }
+               return false;
+    }
+
        function check_user_access()
        {
                global $security_groups;