Added new access levels
[fa-stable.git] / includes / session.inc
index 4a67da7aa964d5e5f68e941dff95a9ee355eaded..e327b3bbe96a0430d2bf9472e33e5dc9b64cf759 100644 (file)
@@ -61,7 +61,11 @@ function check_page_security($page_security)
 
        if (!$_SESSION["wa_current_user"]->can_access_page($page_security))
        {
-               page(_("Access denied"));
+               // no_menu parameter guess here is ugly hack, but works for now.
+               // Better solution is to use global switch for menu, set before 
+               // session.inc inclusion.
+               page(_("Access denied"), strpos($_SERVER['PHP_SELF'], '/view/'));
+
                echo "<center><br><br><br><b>";
                echo _("The security settings on your account do not permit you to access this function");
                echo "</b>";
@@ -103,6 +107,7 @@ include_once($path_to_root . "/includes/current_user.inc");
 include_once($path_to_root . "/includes/lang/language.php");
 include_once($path_to_root . "/config_db.php");
 include_once($path_to_root . "/includes/ajax.inc");
+include_once($path_to_root . "/includes/ui/ui_msgs.inc");
 
 /*
        Make sure this directory exists and is writable!
@@ -114,34 +119,37 @@ session_start();
 // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
 header("Cache-control: private");
 
+get_text::init();
+
 // Page Initialisation
 if (!isset($_SESSION['languages'])) 
 {
-       language::load_languages();
+       language::load_languages(); // sets also default $_SESSION['language']
 }
 
-$lang = $_SESSION['language'];
+language::set_language($_SESSION['language']->code);
 
-// get_text support
-get_text::init();
-get_text::set_language($lang->code, $lang->encoding);
-//get_text::add_domain("wa", $path_to_root . "/lang");
-get_text::add_domain($lang->code, $path_to_root . "/lang");
-
-// Necessary for ajax calls. Due to bug in php 4.3.10 for this 
-// version set globally in php.ini
-ini_set('default_charset', $_SESSION['language']->encoding);
+// include $Hooks object if locale file exists
+if(@include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) 
+{
+       $Hooks = new Hooks();
+}
 
 include_once($path_to_root . "/config.php");
+include_once($path_to_root . "/includes/main.inc");
 
+// Ajax communication object
 $Ajax =& new Ajax();
 
-include_once($path_to_root . "/includes/main.inc");
-
-include_once($path_to_root . "/includes/ui/ui_msgs.inc");
+// js/php validation rules container
+$Validate = array();
+// bindings for editors
+$Editors = array();
+// page help. Currently help for function keys.
+$Pagehelp = array();
 
 // intercept all output to destroy it in case of ajax call
-register_shutdown_function('ob_end_flush');
+register_shutdown_function('end_flush');
 ob_start('output_html',0);
 
 // colect all error msgs
@@ -149,6 +157,7 @@ set_error_handler('error_handler' /*, errtypes */);
 
 if (!isset($_SESSION["wa_current_user"]))
        $_SESSION["wa_current_user"] = new current_user();
+set_global_connection();
 
 if (!$_SESSION["wa_current_user"]->logged_in())
 {
@@ -170,10 +179,14 @@ if (!$_SESSION["wa_current_user"]->logged_in())
                        login_fail();
                }
                $lang = $_SESSION['language'];
-               get_text::set_language($lang->code, $lang->encoding);
+               language::set_language($_SESSION['language']->code);
        }
 }
 
+if (!isset($_SESSION["App"])) {
+       $_SESSION["App"] = new front_accounting();
+       $_SESSION["App"]->init();
+}
 
 // Run with debugging messages for the system administrator(s) but not anyone else
 /*if (in_array(15, $security_groups[$_SESSION["AccessLevel"]])) {