From b982d15183249ce9aa9161f64634718367b58cfc Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 25 Jul 2010 09:22:42 +0000 Subject: [PATCH] Fixed language file switching on package version change. --- admin/db/company_db.inc | 5 ++++- includes/current_user.inc | 33 ++++++++++++++++++++++++++++++++- includes/lang/language.php | 2 +- includes/session.inc | 2 +- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/admin/db/company_db.inc b/admin/db/company_db.inc index b3988454..52185138 100644 --- a/admin/db/company_db.inc +++ b/admin/db/company_db.inc @@ -30,7 +30,7 @@ function update_company_prefs( $params, $pref = TB_PREF ) $prefs can be preference name, array of names, or null for all preferences. */ -function get_company_pref($prefs = null, $tbpref = TB_PREF) +function get_company_pref($prefs = null, $tbpref = null) { global $SysPrefs, $core_version; @@ -38,6 +38,9 @@ function get_company_pref($prefs = null, $tbpref = TB_PREF) $_SESSION['SysPrefs'] = new sys_prefs(); + if (!isset($tbpref)) + $tbpref = TB_PREF; + $sql = "SELECT name, value FROM {$tbpref}sys_prefs"; $result = @db_query($sql); // supress errors before 2.3 db structure upgrade diff --git a/includes/current_user.inc b/includes/current_user.inc index 57177992..a7a35303 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -281,7 +281,9 @@ function user_numeric($input) { function user_company() { - return $_SESSION["wa_current_user"]->company; + global $def_coy; + + return isset($_SESSION["wa_current_user"]) ? $_SESSION["wa_current_user"]->company : $def_coy; } function user_pos() @@ -499,4 +501,33 @@ function array_search_key($needle, $haystack, $valuekey=null) $keys = array_search_keys($needle, $haystack, $valuekey); return @$keys[0]; } + +function flush_dir($path, $wipe = false) +{ + $dir = opendir($path); + while(false !== ($fname = readdir($dir))) { + if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue; + if(is_dir($path.'/'.$fname)) { + flush_dir($path.'/'.$fname, $wipe); + if ($wipe) @rmdir($path.'/'.$fname); + } else + @unlink($path.'/'.$fname); + } +} +/* + Returns current path to company private folder. + (Current path can change after chdir). +*/ +function company_path($comp=null) +{ + global $path_to_root, $comp_path; + + if (!isset($comp)) + $comp = user_company(); + + // if path is relative, set current path_to_root + return ($comp_path[0]=='.' ? $path_to_root.'/'.basename($comp_path) : $comp_path) + . '/'.$comp; +} + ?> \ No newline at end of file diff --git a/includes/lang/language.php b/includes/lang/language.php index 54302ebe..f6a09ded 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -50,8 +50,8 @@ class language { global $path_to_root, $installed_languages; - $changed = $this->code != $code; $lang = array_search_value($code, $installed_languages, 'code'); + $changed = $this->code != $code || $this->version != $lang['version']; if ($lang && $changed) { diff --git a/includes/session.inc b/includes/session.inc index 54de6a15..4a6b083a 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -180,6 +180,7 @@ session_start(); // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks header("Cache-control: private"); +include_once($path_to_root . "/config.php"); get_text_init(); // Page Initialisation @@ -200,7 +201,6 @@ if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.in } include_once($path_to_root . "/includes/access_levels.inc"); -include_once($path_to_root . "/config.php"); include_once($path_to_root . "/version.php"); include_once($path_to_root . "/includes/main.inc"); -- 2.30.2