X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fcurrent_user.inc;h=5dd2c197e02a52587af77ce1fd31b78b8feff9d4;hb=0b63d898491b6577a5a5bf90e771dca0dcbbcf1f;hp=ae0a4d753dcf152924a014a28d8520c7b2c90bf7;hpb=264c09696d65efe4532c197f317162daf8c24f32;p=fa-stable.git diff --git a/includes/current_user.inc b/includes/current_user.inc index ae0a4d75..5dd2c197 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -22,6 +22,7 @@ class current_user var $loginname; var $username; var $name; + var $email; var $company; // user's company var $pos; var $access; @@ -53,7 +54,7 @@ class current_user function set_company($company) { - $this->company = $company; + $this->company = (int)$company; } function login($company, $loginname, $password) @@ -130,6 +131,7 @@ class current_user $this->username = $this->loginname; $this->prefs = new user_prefs($myrow); $this->user = @$myrow["id"]; + $this->email = @$myrow["email"]; update_user_visitdate($this->username); $this->logged = true; $this->last_act = time(); @@ -139,6 +141,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(); + + $myrow = get_user_by_email($email); + + if ($myrow['id'] != "") { + + $bytes = openssl_random_pseudo_bytes(8, $cstrong); + $password = base64_encode($bytes); + + $hash = md5($password); + + update_user_password($myrow['id'], $myrow['user_id'], $hash); + + mail($myrow['email'], _("New password for")." ".$app_title, $password); + + return true; + } + return false; + } + function check_user_access() { global $security_groups; @@ -631,6 +659,14 @@ function array_search_key($needle, $haystack, $valuekey=null) return @$keys[0]; } +// Recalculate report columns if orientation is landscape. +function recalculate_cols(&$cols) +{ + $factor = (user_pagesize() == "A4" ? 1.4 : 1.3); + foreach($cols as $key => $col) + $cols[$key] = intval($col * $factor); +} + function flush_dir($path, $wipe = false) { $dir = opendir($path);