3 include_once($path_to_root . "/includes/prefs/userprefs.inc");
5 //--------------------------------------------------------------------------
20 function current_user()
22 $this->loginname = $username = $this->name = $this->company = "";
23 $this->logged = false;
33 function set_company($company)
35 $this->company = $company;
38 function login($company, $loginname, $password)
40 $this->set_company($company);
42 $Auth_Result = get_user_for_login($loginname, $password);
44 if (db_num_rows($Auth_Result) > 0)
46 $myrow = db_fetch($Auth_Result);
48 $this->access = $myrow["full_access"];
49 $this->name = $myrow["real_name"];
50 $this->loginname = $loginname;
51 $this->username = $this->loginname;
52 $this->prefs = new user_prefs($myrow);
54 update_user_visitdate($loginname);
59 $this->logged = false;
65 function check_user_access()
67 global $security_groups;
68 return is_array($security_groups[$this->access]);
71 function can_access_page($page_level)
73 global $security_groups;
74 return isset($page_level) && in_array($page_level, $security_groups[$this->access]);
77 function get_db_connection()
79 global $db_connections;
81 $connection = $db_connections[$this->company];
83 //print_r($connection);
85 $db = mysql_connect($connection["host"] ,
86 $connection["dbuser"], $connection["dbpassword"]);
87 mysql_select_db($connection["dbname"],$db);
89 if (!defined('TB_PREF'))
90 define('TB_PREF', $connection["tbpref"]);
95 function update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
96 $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) {
97 update_user_display_prefs($this->username, $price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl,
98 $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize);
101 $user = get_user($this->username);
102 $this->prefs = new user_prefs($user);
106 //--------------------------------------------------------------------------
108 function number_format2($number, $decimals=0)
110 global $thoseps, $decseps;
111 $tsep = $thoseps[$_SESSION["wa_current_user"]->prefs->tho_sep()];
112 $dsep = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()];
113 return number_format($number, $decimals, $dsep, $tsep);
116 function user_company()
118 return $_SESSION["wa_current_user"]->company;
121 function user_language()
123 return $_SESSION["wa_current_user"]->prefs->language();
126 function user_qty_dec()
128 return $_SESSION["wa_current_user"]->prefs->qty_dec();
131 function user_price_dec()
133 return $_SESSION["wa_current_user"]->prefs->price_dec();
136 function user_exrate_dec()
138 return $_SESSION["wa_current_user"]->prefs->exrate_dec();
141 function user_percent_dec()
143 return $_SESSION["wa_current_user"]->prefs->percent_dec();
146 function user_show_gl_info()
148 return $_SESSION["wa_current_user"]->prefs->show_gl_info();
151 function user_show_codes()
153 return $_SESSION["wa_current_user"]->prefs->show_codes();
156 function user_date_format()
158 return $_SESSION["wa_current_user"]->prefs->date_format();
161 function user_date_display()
163 return $_SESSION["wa_current_user"]->prefs->date_display();
166 function user_date_sep()
168 return $_SESSION["wa_current_user"]->prefs->date_sep();
171 function user_tho_sep()
173 return $_SESSION["wa_current_user"]->prefs->tho_sep();
176 function user_dec_sep()
178 return $_SESSION["wa_current_user"]->prefs->dec_sep();
181 function user_theme()
183 return $_SESSION["wa_current_user"]->prefs->get_theme();
186 function user_pagesize()
188 return $_SESSION["wa_current_user"]->prefs->get_pagesize();
191 function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
192 $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize)
195 $_SESSION["wa_current_user"]->update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
196 $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize);
199 //--------------------------------------------------------------------------