Example #1
0
 /**
  * Initialize Sugar environment
  */
 protected function initSugar()
 {
     if ($this->sugar_initialized) {
         return;
     }
     // BR-385 - This fixes the issues around SugarThemeRegistry fatals.  The cache needs rebuild on stage-post init of sugar
     if ($this->current_stage == 'post') {
         $this->cleanFileCache();
     }
     if (!defined('sugarEntry')) {
         define('sugarEntry', true);
     }
     $this->log("Initializing SugarCRM environment");
     global $beanFiles, $beanList, $objectList, $timedate, $moduleList, $modInvisList, $sugar_config, $locale, $sugar_version, $sugar_flavor, $sugar_build, $sugar_db_version, $sugar_timestamp, $db, $locale, $installing, $bwcModules, $app_list_strings, $modules_exempt_from_availability_check;
     $installing = true;
     include 'include/entryPoint.php';
     $installing = false;
     $GLOBALS['current_language'] = $this->config['default_language'];
     if (empty($GLOBALS['current_language'])) {
         $GLOBALS['current_language'] = 'en_us';
     }
     $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
     $this->db = $GLOBALS['db'] = DBManagerFactory::getInstance();
     //Once we have a DB, we can do a full cache clear
     if ($this->current_stage == 'post') {
         $this->cleanCaches();
     }
     SugarApplication::preLoadLanguages();
     $timedate = TimeDate::getInstance();
     if (empty($locale)) {
         if (method_exists('Localization', 'getObject')) {
             $locale = Localization::getObject();
         } else {
             $locale = new Localization();
         }
     }
     if (!isset($_SERVER['REQUEST_URI'])) {
         $_SERVER['REQUEST_URI'] = '';
     }
     // Load user
     $GLOBALS['current_user'] = $this->getUser();
     // Prepare DB
     if ($this->config['dbconfig']['db_type'] == 'mysql') {
         //Change the db wait_timeout for this session
         $now_timeout = $this->db->getOne("select @@wait_timeout");
         $this->db->query("set wait_timeout=28800");
         $now_timeout = $this->db->getOne("select @@wait_timeout");
         $this->log("DB timeout set to {$now_timeout}");
     }
     // stop trackers
     $trackerManager = TrackerManager::getInstance(true);
     $trackerManager->pause();
     $trackerManager->unsetMonitors();
     $this->sugar_initialized = true;
     $this->loadStrings();
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $this->log("Done initializing SugarCRM environment");
 }
Example #2
0
 ////	SETTING DEFAULT VAR VALUES
 $GLOBALS['log'] = LoggerManager::getLogger();
 $error_notice = '';
 $use_current_user_login = false;
 // Allow for the session information to be passed via the URL for printing.
 if (isset($_GET['PHPSESSID'])) {
     if (!empty($_COOKIE['PHPSESSID']) && strcmp($_GET['PHPSESSID'], $_COOKIE['PHPSESSID']) == 0) {
         session_id($_REQUEST['PHPSESSID']);
     } else {
         unset($_GET['PHPSESSID']);
     }
 }
 if (!empty($sugar_config['session_dir'])) {
     session_save_path($sugar_config['session_dir']);
 }
 SugarApplication::preLoadLanguages();
 $timedate = TimeDate::getInstance();
 $GLOBALS['sugar_version'] = $sugar_version;
 $GLOBALS['sugar_flavor'] = $sugar_flavor;
 $GLOBALS['timedate'] = $timedate;
 $GLOBALS['js_version_key'] = md5($GLOBALS['sugar_config']['unique_key'] . $GLOBALS['sugar_version'] . $GLOBALS['sugar_flavor']);
 $db = DBManagerFactory::getInstance();
 $db->resetQueryCount();
 $locale = new Localization();
 // Emails uses the REQUEST_URI later to construct dynamic URLs.
 // IIS does not pass this field to prevent an error, if it is not set, we will assign it to ''.
 if (!isset($_SERVER['REQUEST_URI'])) {
     $_SERVER['REQUEST_URI'] = '';
 }
 $current_user = new User();
 $current_entity = null;
 public function testpreLoadLanguages()
 {
     try {
         SugarApplication::preLoadLanguages();
         //check that method call got the current_language global variable set.
         $this->assertTrue(isset($GLOBALS['current_language']));
         //check that method call got the app_strings global variable set.
         $this->assertTrue(is_array($GLOBALS['app_strings']) && count($GLOBALS['app_strings']) > 0);
     } catch (Exception $e) {
         $this->fail();
     }
 }