X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fcurrent_user.inc;h=0a5b7481dc381bba29617ae769f30ef60a24dae0;hb=7840540918bfd37c886877a5d52e3ba0b3373289;hp=27d69e3dd1fe5e32b45ff3b02205bc0df8731111;hpb=e7e5de3900498c8447d730d9087986e707350107;p=fa-stable.git diff --git a/includes/current_user.inc b/includes/current_user.inc index 27d69e3d..0a5b7481 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -63,11 +63,20 @@ class current_user $this->set_company($company); $this->logged = false; - $Auth_Result = get_user_for_login($loginname, $password); + set_global_connection(); - if (db_num_rows($Auth_Result) > 0) + // Use external authentication source if any. + // Keep in mind you need to have user data set for $loginname + // in FA users table anyway to successfully log in. + $Auth_Result = hook_authenticate($loginname, $password); + + if (!isset($Auth_Result)) // if not used: standard method + $Auth_Result = get_user_auth($loginname, md5($password)); + + if ($Auth_Result) { - $myrow = db_fetch($Auth_Result); + $myrow = get_user_by_login($loginname); + $this->old_db = isset($myrow["full_access"]); if (! @$myrow["inactive"]) { if ($this->old_db) { @@ -202,6 +211,20 @@ function number_format2($number, $decimals=0) return $decimals==='max' ? rtrim($num, '0') : $num; } + +/* price/float comparision helper to be used in any suspicious place for zero values? +usage: +if (!floatcmp($value1, $value2)) + compare value is 0 +*/ + +define('FLOAT_COMP_DELTA', 0.004); + +function floatcmp($a, $b) +{ + return $a - $b > FLOAT_COMP_DELTA ? 1 : $b - $a > FLOAT_COMP_DELTA ? -1 : 0; +} + // // Current ui mode. // @@ -411,6 +434,11 @@ function user_startup_tab() return $_SESSION["wa_current_user"]->prefs->start_up_tab(); } +function user_check_access($sec_area) +{ + return $_SESSION["wa_current_user"]->can_access($sec_area); +} + function set_user_prefs($prefs) { $_SESSION["wa_current_user"]->update_prefs($prefs); @@ -522,6 +550,7 @@ function flush_dir($path, $wipe = false) $dir = opendir($path); if(!$dir) return; + while(false !== ($fname = readdir($dir))) { if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue; if(is_dir($path.'/'.$fname)) {