/**
  * Perform execution of the application. This method is called from index2.php
  *
  * @param Request $request
  */
 function execute(Request $request)
 {
     global $sugar_config;
     if (!empty($sugar_config['default_module'])) {
         $this->default_module = $sugar_config['default_module'];
     }
     $module = $this->default_module;
     if (!empty($_REQUEST['module'])) {
         $module = $_REQUEST['module'];
     }
     insert_charset_header();
     $this->setupPrint();
     $this->controller = ControllerFactory::getController($module);
     // if the entry point is defined to not need auth, then don't authenicate
     if (!$request->has('entryPoint') || $this->controller->checkEntryPointRequiresAuth($request->query('entryPoint'))) {
         $this->loadUser();
         $this->ACLFilter();
         $this->preProcess();
         $this->getController()->preProcess();
         $this->checkHTTPReferer();
     }
     SugarThemeRegistry::buildRegistry();
     $this->loadLanguages();
     $this->checkDatabaseVersion();
     $this->loadDisplaySettings();
     $this->loadLicense();
     $this->loadGlobals();
     $this->setupResourceManagement($module);
     $this->getController()->execute();
     sugar_cleanup();
 }
 public function testcheckEntryPointRequiresAuth()
 {
     $SugarController = new SugarController();
     //check with a invalid value
     $result = $SugarController->checkEntryPointRequiresAuth('');
     $this->assertTrue($result);
     //cehck with a valid True value
     $result = $SugarController->checkEntryPointRequiresAuth('download');
     $this->assertTrue($result);
     //cehck with a valid False value
     $result = $SugarController->checkEntryPointRequiresAuth('GeneratePassword');
     $this->assertFalse($result);
 }