projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merged last changes from stable.
[fa-stable.git]
/
includes
/
current_user.inc
diff --git
a/includes/current_user.inc
b/includes/current_user.inc
index 7f04eb778329e347b017f0523ad4d67f0eb2d68c..7d80febbe3b4f02f8f1acb00a5bd1a8d6f3d1903 100644
(file)
--- a/
includes/current_user.inc
+++ b/
includes/current_user.inc
@@
-22,6
+22,7
@@
class current_user
var $loginname;
var $username;
var $name;
var $loginname;
var $username;
var $name;
+ var $email;
var $company; // user's company
var $pos;
var $access;
var $company; // user's company
var $pos;
var $access;
@@
-58,12
+59,15
@@
class current_user
function login($company, $loginname, $password)
{
function login($company, $loginname, $password)
{
- global $security_areas, $security_groups, $security_headings, $path_to_root, $login_delay;
+ global $security_areas, $security_groups, $security_headings, $path_to_root, $
dflt_lang, $
login_delay;
$this->set_company($company);
$this->logged = false;
$this->set_company($company);
$this->logged = false;
- set_global_connection();
+ set_global_connection($company);
+ $lang = &$_SESSION['language'];
+ $lang->set_language($_SESSION['language']->code);
+ db_set_encoding($_SESSION['language']->encoding);
// Use external authentication source if any.
// Keep in mind you need to have user data set for $loginname
// Use external authentication source if any.
// Keep in mind you need to have user data set for $loginname
@@
-79,6
+83,13
@@
class current_user
if ($Auth_Result)
{
$myrow = get_user_by_login($loginname);
if ($Auth_Result)
{
$myrow = get_user_by_login($loginname);
+ if ($myrow['language'] != $dflt_lang)
+ { // refresh language and user data
+ $lang->set_language($myrow['language']);
+ db_set_encoding($_SESSION['language']->encoding);
+ $myrow = get_user_by_login($loginname);
+ }
+
$this->old_db = isset($myrow["full_access"]);
if (! @$myrow["inactive"]) {
if ($this->old_db) {
$this->old_db = isset($myrow["full_access"]);
if (! @$myrow["inactive"]) {
if ($this->old_db) {
@@
-120,6
+131,7
@@
class current_user
$this->username = $this->loginname;
$this->prefs = new user_prefs($myrow);
$this->user = @$myrow["id"];
$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();
update_user_visitdate($this->username);
$this->logged = true;
$this->last_act = time();
@@
-139,20
+151,20
@@
class current_user
return !isset($security_groups) && is_array($this->role_set);
}
return !isset($security_groups) && is_array($this->role_set);
}
- function can_access($
page_level
)
+ function can_access($
sec_area
)
{
global $security_groups, $security_areas;
if (isset($security_groups)) {
{
global $security_groups, $security_areas;
if (isset($security_groups)) {
- return
$this->company == 0
&&
+ return
is_admin_company()
&&
in_array(20, $security_groups[$this->access]);
}
in_array(20, $security_groups[$this->access]);
}
- if ($
page_level
=== 'SA_OPEN')
+ if ($
sec_area
=== 'SA_OPEN')
return true;
return true;
- if ($
page_level === 'SA_DENIED' || $page_level
=== '')
+ if ($
sec_area === 'SA_DENIED' || $sec_area
=== '')
return false;
return false;
- $code = $security_areas[$
page_level
][0];
+ $code = $security_areas[$
sec_area
][0];
// only first registered company has site admin privileges
return $code && in_array($code, $this->role_set)
// only first registered company has site admin privileges
return $code && in_array($code, $this->role_set)
@@
-504,6
+516,17
@@
function user_startup_tab()
return $_SESSION["wa_current_user"]->prefs->start_up_tab();
}
return $_SESSION["wa_current_user"]->prefs->start_up_tab();
}
+function user_transaction_days()
+{
+ return $_SESSION["wa_current_user"]->prefs->transaction_days();
+}
+
+
+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);
function set_user_prefs($prefs)
{
$_SESSION["wa_current_user"]->update_prefs($prefs);
@@
-623,6
+646,7
@@
function flush_dir($path, $wipe = false)
$dir = opendir($path);
if(!$dir)
return;
$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)) {
while(false !== ($fname = readdir($dir))) {
if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue;
if(is_dir($path.'/'.$fname)) {
@@
-648,5
+672,9
@@
function company_path($comp=null)
. '/'.$comp;
}
. '/'.$comp;
}
+function is_admin_company()
+{
+ return $this->company == 0;
+}
?>
\ No newline at end of file
?>
\ No newline at end of file