Implemented customizable authentication timeout.
[fa-stable.git] / includes / current_user.inc
index 97afe9d0cdbd1d2e55df7b858a2d0632a184afdd..ee9e38f05c06c54718af2d653707c52c03396ffa 100644 (file)
@@ -22,6 +22,8 @@ class current_user
        var $company;
        var $pos;
        var $access;
+       var $timeout;
+       var $last_act;
 
        var $logged;
        var $ui_mode = 0;
@@ -30,7 +32,10 @@ class current_user
 
        function current_user()
        {
-               $this->loginname = $this->username = $this->name = $this->company = "";
+               global $def_coy;
+               
+               $this->loginname = $this->username = $this->name = "";
+               $this->company = isset($def_coy)? $def_coy : 0;
                $this->logged = false;
 
                $this->prefs = new user_prefs();
@@ -66,6 +71,8 @@ class current_user
                    $this->user = @$myrow["id"];
                        update_user_visitdate($this->username);
                        $this->logged = true;
+                               $this->last_act = time();
+                               $this->timeout = session_timeout();
                        }
                }
 
@@ -147,6 +154,7 @@ function price_format($number) {
     return number_format2($number,
        $_SESSION["wa_current_user"]->prefs->price_dec());
 }
+
 // 2008-06-15. Added extra parameter $stock_id and reference for $dec
 //--------------------------------------------------------------------
 function qty_format($number, $stock_id=null, &$dec) {
@@ -315,7 +323,7 @@ function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl
 }
 
 function add_user_js_data() {
-       global $path_to_root, $thoseps, $decseps;
+       global $path_to_root, $thoseps, $decseps, $date_system, $dateseps;
 
        $ts = $thoseps[user_tho_sep()];
        $ds = $decseps[user_dec_sep()];
@@ -324,7 +332,10 @@ function add_user_js_data() {
          . "var user = {\n"
          . "theme: '". $path_to_root . '/themes/'. user_theme().'/'."',\n"
          . "loadtxt: '"._('Requesting data...')."',\n"
-         . "date: '".Today()."',\n"
+         . "date: '".Today()."',\n"    // server date
+         . "datesys: ".$date_system.",\n"
+         . "datefmt: ".user_date_format().",\n"
+         . "datesep: '".$dateseps[user_date_sep()]."',\n"
          . "ts: '$ts',\n"
          . "ds: '$ds',\n"
          . "pdec : " . user_price_dec() . "}\n";
@@ -334,4 +345,8 @@ function add_user_js_data() {
 
 //--------------------------------------------------------------------------
 
+function session_timeout()
+{
+       return get_company_pref('login_tout');
+}
 ?>
\ No newline at end of file