Index: include/class.language.php
===================================================================
--- include/class.language.php	(revision 3864)
+++ include/class.language.php	(working copy)
@@ -37,27 +37,6 @@
  * @author Bryan Alsdorf <bryan@mysql.com>
  */
 
-/**
- * List of available locales present in Eventum.
- *
- * Note that the locales are first tested before they are listed as choices in
- * Preferences page.
- */
-
-$avail_langs = array(
-    'pl_PL' =>  'Polish',
-#    'en_US' =>  'English',
-    'ru_RU' =>  'Russian',
-    'de_DE' =>  'German',
-#    'fr_FR' =>  'French',
-    'it_IT' =>  'Italian',
-    'fi_FI' =>  'Finnish',
-    'es_ES' =>  'Spanish',
-#    'nl_NL' =>  'Dutch',
-    'sv_SE' =>  'Swedish',
-    'pt_BR' =>  'Brazilian Portuguese',
-);
-
 class Language
 {
 
@@ -78,6 +57,26 @@
     }
 
     /**
+     * List of available locales present in Eventum.
+     *
+     * Note that the locales are first tested before they are listed as choices in
+     * Preferences page.
+     */
+    private static $avail_langs = array(
+        'pl_PL' =>  'Polish',
+#       'en_US' =>  'English',
+        'ru_RU' =>  'Russian',
+        'de_DE' =>  'German',
+#       'fr_FR' =>  'French',
+        'it_IT' =>  'Italian',
+        'fi_FI' =>  'Finnish',
+        'es_ES' =>  'Spanish',
+#       'nl_NL' =>  'Dutch',
+        'sv_SE' =>  'Swedish',
+        'pt_BR' =>  'Brazilian Portuguese',
+    );
+
+    /**
      * Method used to get available languages.
 	 * Uses $avail_langs array and verifies that the language can be used.
      *
@@ -86,10 +85,8 @@
      */
     function getAvailableLanguages()
     {
-        global $avail_langs;
-
 		$languages = array();
-		foreach ($avail_langs as $code => $language) {
+		foreach (self::$avail_langs as $code => $language) {
 			$res = Language::set($code);
 			if ($res) {
 				$languages[$code] = $language;
@@ -161,7 +158,7 @@
 				return false;
 			}
 		}
-        User::setLocalizedRoles();
+        User::resetLocalizedRoles();
 
 		return true;
     }
Index: include/class.auth.php
===================================================================
--- include/class.auth.php	(revision 3864)
+++ include/class.auth.php	(working copy)
@@ -34,7 +34,6 @@
 require_once(APP_INC_PATH . "class.user.php");
 require_once(APP_INC_PATH . "class.customer.php");
 require_once(APP_INC_PATH . "class.date_helper.php");
-require_once(APP_CONFIG_PATH . "private_key.php");
 
 /**
  * Class to handle authentication issues.
@@ -45,6 +44,20 @@
 class Auth
 {
     /**
+     * Method used to get private key used for hashing session cookies.
+     *
+     * @access  public
+     * @return  string  The private_key hash.
+     */
+    public static function privateKey() {
+        static $private_key = null;
+        if (is_null($private_key)) {
+            require_once APP_CONFIG_PATH . "/private_key.php";
+        }
+        return $private_key;
+    }
+
+    /**
      * Method used to save the login information into a log file. It will be
      * useful for administrative purposes, so we know which customers were able
      * to login.
@@ -254,7 +267,7 @@
     function isValidCookie($cookie)
     {
         if ((empty($cookie["email"])) || (empty($cookie["hash"])) ||
-               ($cookie["hash"] != md5($GLOBALS["private_key"] . md5($cookie["login_time"]) . $cookie["email"]))) {
+               ($cookie["hash"] != md5(self::privateKey() . md5($cookie["login_time"]) . $cookie["email"]))) {
             return false;
         } else {
             $usr_id = User::getUserIDByEmail(@$cookie["email"]);
@@ -281,7 +294,7 @@
         $cookie = array(
             "email"      => $email,
             "login_time" => $time,
-            "hash"       => md5($GLOBALS["private_key"] . md5($time) . $email),
+            "hash"       => md5(self::privateKey() . md5($time) . $email),
         );
         $cookie = base64_encode(serialize($cookie));
         Auth::setCookie($cookie_name, $cookie, APP_COOKIE_EXPIRE);
@@ -483,15 +496,13 @@
      */
     function createFakeCookie($usr_id, $project = false)
     {
-        require_once(APP_CONFIG_PATH . "private_key.php");
-
         $user_details = User::getDetails($usr_id);
 
         $time = time();
         $cookie = array(
             "email" => $user_details['usr_email'],
             "login_time"    =>  $time,
-            "hash"       => md5($GLOBALS["private_key"] . md5($time) . $user_details['usr_email']),
+            "hash"       => md5(self::privateKey() . md5($time) . $user_details['usr_email']),
         );
         $_COOKIE[APP_COOKIE] = base64_encode(serialize($cookie));
         if ($project) {
Index: include/class.help.php
===================================================================
--- include/class.help.php	(revision 3864)
+++ include/class.help.php	(working copy)
@@ -31,109 +31,6 @@
 
 require_once(APP_INC_PATH . "class.error_handler.php");
 
-$topics = array(
-    "main" => array(
-        "title"  => ev_gettext("Help Topics"),
-        "parent" => ""
-    ),
-    "report" => array(
-        "title"  => ev_gettext("Reporting Issues"),
-        "parent" => "main"
-    ),
-    "report_category" => array(
-        "title"  => ev_gettext("Category Field"),
-        "parent" => "report"
-    ),
-    "report_priority" => array(
-        "title"  => ev_gettext("Priority Field"),
-        "parent" => "report"
-    ),
-    "report_assignment" => array(
-        "title"  => ev_gettext("Assignment Field"),
-        "parent" => "report"
-    ),
-    "report_release" => array(
-        "title"  => ev_gettext("Scheduled Release Field"),
-        "parent" => "report"
-    ),
-    "report_summary" => array(
-        "title"  => ev_gettext("Summary Field"),
-        "parent" => "report"
-    ),
-    "report_description" => array(
-        "title"  => ev_gettext("Description Field"),
-        "parent" => "report"
-    ),
-    "report_estimated_dev_time" => array(
-        "title"  => ev_gettext("Estimated Development Time Field"),
-        "parent" => "report"
-    ),
-    "scm_integration" => array(
-        "title"  => ev_gettext("SCM Integration"),
-        "parent" => "main"
-    ),
-    "scm_integration_usage" => array(
-        "title"  => ev_gettext("Usage Examples"),
-        "parent" => "scm_integration"
-    ),
-    "scm_integration_installation" => array(
-        "title"  => ev_gettext("Installation Instructions"),
-        "parent" => "scm_integration"
-    ),
-    "list" => array(
-        "title"  => ev_gettext("Listing / Searching for Issues"),
-        "parent" => "main"
-    ),
-    "adv_search" => array(
-        "title"  => ev_gettext("Advanced Search / Creating Custom Queries"),
-        "parent" => "main"
-    ),
-    "support_emails" => array(
-        "title"  => ev_gettext("Associate Emails"),
-        "parent" => "main"
-    ),
-    "preferences" => array(
-        "title"  => ev_gettext("Account Preferences"),
-        "parent" => "main"
-    ),
-    "notifications" => array(
-        "title"  => ev_gettext("Email Notifications"),
-        "parent" => "main"
-    ),
-    "view" => array(
-        "title"  => ev_gettext("Viewing Issues"),
-        "parent" => "main"
-    ),
-    "email_blocking" => array(
-        "title"  => ev_gettext("Email Blocking"),
-        "parent" => "main"
-    ),
-    "link_filters" => array(
-        "title"  => ev_gettext("Link Filters"),
-        "parent" => "main"
-    ),
-    "field_display" => array(
-        "title"  => ev_gettext("Edit Fields to Display"),
-        "parent" => "main"
-    ),
-    "column_display" => array(
-        "title"  => ev_gettext("Edit Columns to Display"),
-        "parent" => "main"
-    ),
-    "customize_listing" => array(
-        "title"  => ev_gettext("Customize Issue Listing Screen"),
-        "parent" => "main"
-    ),
-    "segregate_reporter" => array(
-        "title"  => ev_gettext("Segregate Reporters"),
-        "parent" => "main"
-    ),
-    "permission_levels" => array(
-        "title"  => ev_gettext("User Permission Levels"),
-        "parent" => "main"
-    ),
-);
-
 /**
  * Class to handle the business logic related to the help
  * documentation, such as providing a dynamic list of topics related
@@ -145,6 +42,118 @@
 
 class Help
 {
+    static private $topics;
+    private static function getTopics() {
+        if (!is_null(self::$topics)) {
+            return self::$topics;
+        }
+
+        // we need this in function as function calls are not allowed in static properties
+        self::$topics = array(
+            "main" => array(
+                "title"  => ev_gettext("Help Topics"),
+                "parent" => ""
+            ),
+            "report" => array(
+                "title"  => ev_gettext("Reporting Issues"),
+                "parent" => "main"
+            ),
+            "report_category" => array(
+                "title"  => ev_gettext("Category Field"),
+                "parent" => "report"
+            ),
+            "report_priority" => array(
+                "title"  => ev_gettext("Priority Field"),
+                "parent" => "report"
+            ),
+            "report_assignment" => array(
+                "title"  => ev_gettext("Assignment Field"),
+                "parent" => "report"
+            ),
+            "report_release" => array(
+                "title"  => ev_gettext("Scheduled Release Field"),
+                "parent" => "report"
+            ),
+            "report_summary" => array(
+                "title"  => ev_gettext("Summary Field"),
+                "parent" => "report"
+            ),
+            "report_description" => array(
+                "title"  => ev_gettext("Description Field"),
+                "parent" => "report"
+            ),
+            "report_estimated_dev_time" => array(
+                "title"  => ev_gettext("Estimated Development Time Field"),
+                "parent" => "report"
+            ),
+            "scm_integration" => array(
+                "title"  => ev_gettext("SCM Integration"),
+                "parent" => "main"
+            ),
+            "scm_integration_usage" => array(
+                "title"  => ev_gettext("Usage Examples"),
+                "parent" => "scm_integration"
+            ),
+            "scm_integration_installation" => array(
+                "title"  => ev_gettext("Installation Instructions"),
+                "parent" => "scm_integration"
+            ),
+            "list" => array(
+                "title"  => ev_gettext("Listing / Searching for Issues"),
+                "parent" => "main"
+            ),
+            "adv_search" => array(
+                "title"  => ev_gettext("Advanced Search / Creating Custom Queries"),
+                "parent" => "main"
+            ),
+            "support_emails" => array(
+                "title"  => ev_gettext("Associate Emails"),
+                "parent" => "main"
+            ),
+            "preferences" => array(
+                "title"  => ev_gettext("Account Preferences"),
+                "parent" => "main"
+            ),
+            "notifications" => array(
+                "title"  => ev_gettext("Email Notifications"),
+                "parent" => "main"
+            ),
+            "view" => array(
+                "title"  => ev_gettext("Viewing Issues"),
+                "parent" => "main"
+            ),
+            "email_blocking" => array(
+                "title"  => ev_gettext("Email Blocking"),
+                "parent" => "main"
+            ),
+            "link_filters" => array(
+                "title"  => ev_gettext("Link Filters"),
+                "parent" => "main"
+            ),
+            "field_display" => array(
+                "title"  => ev_gettext("Edit Fields to Display"),
+                "parent" => "main"
+            ),
+            "column_display" => array(
+                "title"  => ev_gettext("Edit Columns to Display"),
+                "parent" => "main"
+            ),
+            "customize_listing" => array(
+                "title"  => ev_gettext("Customize Issue Listing Screen"),
+                "parent" => "main"
+            ),
+            "segregate_reporter" => array(
+                "title"  => ev_gettext("Segregate Reporters"),
+                "parent" => "main"
+            ),
+            "permission_levels" => array(
+                "title"  => ev_gettext("User Permission Levels"),
+                "parent" => "main"
+            ),
+        );
+        return self::$topics;
+    }
+
     /**
      * Method used to check whether a specific topic exists or not.
      * This is mainly used in the help documentation main page to see
@@ -230,14 +239,14 @@
      */
     function getNavigationLinks($topic)
     {
-        global $topics;
+        $topics = self::getTopics();
 
         $links = array();
-        $links[] = @array(
+        $links[] = array(
             "topic" => "",
             "title" => $topics[$topic]["title"]
         );
-        while ($parent = Help::getParent($topic)) {
+        while ($parent = self::getParent($topic)) {
             $links[] = array(
                 "topic" => $parent["topic"],
                 "title" => $parent["title"]
Index: include/class.user.php
===================================================================
--- include/class.user.php	(revision 3864)
+++ include/class.user.php	(working copy)
@@ -39,19 +39,7 @@
 require_once(APP_INC_PATH . "class.date_helper.php");
 require_once(APP_INC_PATH . "class.project.php");
 require_once(APP_INC_PATH . "class.setup.php");
-require_once(APP_CONFIG_PATH . "private_key.php");
 
-// definition of roles
-$roles = array(
-    1 => "Viewer",
-    2 => "Reporter",
-    3 => "Customer",
-    4 => "Standard User",
-    5 => "Developer",
-    6 => "Manager",
-    7 => "Administrator"
-);
-
 /**
  * Class to handle the business logic related to the administration
  * of users and permissions in the system.
@@ -62,7 +50,38 @@
 
 class User
 {
+
+    // definition of roles
+    private static $roles = array(
+        1 => "Viewer",
+        2 => "Reporter",
+        3 => "Customer",
+        4 => "Standard User",
+        5 => "Developer",
+        6 => "Manager",
+        7 => "Administrator"
+    );
+
+    private static $localized_roles;
+    private static function getLocalizedRoles()
+    {
+        if (is_null(self::$localized_roles)) {
+            foreach (self::$roles as $id => $role) {
+                self::$localized_roles[$id] = ev_gettext($role);
+            }
+        }
+        return self::$localized_roles;
+    }
+
     /**
+     * Method to reset localized roles, i.e after changing active language.
+     */
+    public static function resetLocalizedRoles()
+    {
+        self::$localized_roles = null;
+    }
+
+    /**
      * Method used to get the user ID associated with the given customer
      * contact ID.
      *
@@ -277,7 +296,7 @@
             if ($res == NULL) {
                 return -2;
             } else {
-                $check_hash = md5($res . md5($email) . $GLOBALS["private_key"]);
+                $check_hash = md5($res . md5($email) . Auth::privateKey());
                 if ($hash != $check_hash) {
                     return -3;
                 } else {
@@ -332,7 +351,7 @@
                 Project::associateUser($projects[$i], $new_usr_id, $role);
             }
             // send confirmation email to user
-            $hash = md5($_POST["full_name"] . md5($_POST["email"]) . $GLOBALS["private_key"]);
+            $hash = md5($_POST["full_name"] . md5($_POST["email"]) . Auth::privateKey());
 
             $tpl = new Template_Helper();
             $tpl->setTemplate('notifications/visitor_account.tpl.text');
@@ -365,7 +384,7 @@
     {
         $info = User::getDetails($usr_id);
         // send confirmation email to user
-        $hash = md5($info["usr_full_name"] . md5($info["usr_email"]) . $GLOBALS["private_key"]);
+        $hash = md5($info["usr_full_name"] . md5($info["usr_email"]) . Auth::privateKey());
 
         $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/password_confirmation.tpl.text');
@@ -540,7 +559,6 @@
         }
     }
 
-
     /**
      * Method used to get an associative array of the available roles.
      *
@@ -549,10 +567,8 @@
      */
     function getAssocRoleIDs()
     {
-        global $roles;
-        reset($roles);
         $assoc_roles = array();
-        while (list($key, $value) = each($roles)) {
+        while (list($key, $value) = each(self::$roles)) {
             $value = str_replace(" ", "_", strtolower($value));
             $assoc_roles[$value] = (integer) $key;
         }
@@ -571,9 +587,9 @@
     function getRoles($exclude_role = FALSE)
     {
         if ($exclude_role == false) {
-            return $GLOBALS['localized_roles'];
+            return self::getLocalizedRoles();
         } else {
-            $roles = $GLOBALS['localized_roles'];
+            $roles = self::getLocalizedRoles();
             if (!is_array($exclude_role)) {
                 $exclude_role = array($exclude_role);
             }
@@ -595,7 +611,8 @@
      */
     function getRole($role_id)
     {
-        return $GLOBALS['localized_roles'][$role_id];
+        $roles = self::getLocalizedRoles();
+        return $roles[$role_id];
     }
 
 
@@ -608,9 +625,7 @@
      */
     function getRoleID($role_title)
     {
-        global $roles;
-
-        foreach ($roles as $role_id => $role) {
+        foreach (self::$roles as $role_id => $role) {
             if (strtolower($role) == strtolower($role_title)) {
                 return $role_id;
             }
@@ -1522,21 +1537,4 @@
         }
         return $res;
     }
-
-
-    function setLocalizedRoles()
-    {
-        $GLOBALS['localized_roles'] = array(
-            1 => ev_gettext("Viewer"),
-            2 => ev_gettext("Reporter"),
-            3 => ev_gettext("Customer"),
-            4 => ev_gettext("Standard User"),
-            5 => ev_gettext("Developer"),
-            6 => ev_gettext("Manager"),
-            7 => ev_gettext("Administrator")
-        );
-    }
-
 }
-
-User::setLocalizedRoles();
