public function setLegacyViewdefs()
 {
     global $current_language;
     $GLOBALS['mod_strings'] = return_module_language($current_language, $this->module);
     SugarACL::setACL($this->module, array(new SidecarMenuMetaDataUpgraderACL()));
     $module_menu = null;
     include $this->fullpath;
     if ($this->basename === 'globalControlLinks') {
         if (isset($global_control_links)) {
             $module_menu = $global_control_links;
             $this->deleteOld = false;
         }
     }
     SugarACL::resetACLs($this->module);
     $this->legacyViewdefs = $module_menu;
 }
 /**
  * Load the authenticated user. If there is not an authenticated user then redirect to login screen.
  */
 function loadUser()
 {
     global $authController, $sugar_config;
     // Double check the server's unique key is in the session.  Make sure this is not an attempt to hijack a session
     $user_unique_key = isset($_SESSION['unique_key']) ? $_SESSION['unique_key'] : '';
     $server_unique_key = isset($sugar_config['unique_key']) ? $sugar_config['unique_key'] : '';
     if (!empty($this->controller->allowed_actions)) {
         $allowed_actions = $this->controller->allowed_actions;
     } else {
         $allowed_actions = array('Authenticate', 'Login', 'LoggedOut');
     }
     if ($user_unique_key != $server_unique_key && !in_array($this->controller->action, $allowed_actions) && !isset($_SESSION['login_error'])) {
         session_destroy();
         if (!empty($this->controller->action)) {
             if (strtolower($this->controller->action) == 'delete') {
                 $this->controller->action = 'DetailView';
             } elseif (strtolower($this->controller->action) == 'save') {
                 $this->controller->action = 'EditView';
             } elseif (strtolower($this->controller->action) == 'quickcreate') {
                 $this->controller->action = 'index';
                 $this->controller->module = 'home';
             } elseif (isset($_REQUEST['massupdate']) || isset($_GET['massupdate']) || isset($_POST['massupdate'])) {
                 $this->controller->action = 'index';
             } elseif (!in_array($this->controller->action, $this->whiteListActions) && $this->isModifyAction()) {
                 $this->controller->action = 'index';
             }
         }
         header('Location: ' . $this->getUnauthenticatedHomeUrl(true));
         exit;
     }
     $authController = AuthenticationController::getInstance();
     $GLOBALS['current_user'] = BeanFactory::getBean('Users');
     if (isset($_SESSION['authenticated_user_id'])) {
         // set in modules/Users/Authenticate.php
         if (!$authController->sessionAuthenticate()) {
             // if the object we get back is null for some reason, this will break - like user prefs are corrupted
             $GLOBALS['log']->fatal('User retrieval for ID: (' . $_SESSION['authenticated_user_id'] . ') does not exist in database or retrieval failed catastrophically.  Calling session_destroy() and sending user to Login page.');
             session_destroy();
             SugarApplication::redirect($this->getUnauthenticatedHomeUrl());
             die;
         } else {
             $trackerManager = TrackerManager::getInstance();
             $monitor = $trackerManager->getMonitor('tracker_sessions');
             $active = $monitor->getValue('active');
             if ($active == 0 && (!isset($GLOBALS['current_user']->portal_only) || $GLOBALS['current_user']->portal_only != 1)) {
                 // We are starting a new session
                 $result = $GLOBALS['db']->query("SELECT id FROM " . $monitor->name . " WHERE user_id = '" . $GLOBALS['db']->quote($GLOBALS['current_user']->id) . "' AND active = 1 AND session_id <> '" . $GLOBALS['db']->quote($monitor->getValue('session_id')) . "' ORDER BY date_end DESC");
                 $activeCount = 0;
                 while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
                     $activeCount++;
                     if ($activeCount > 1) {
                         $GLOBALS['db']->query("UPDATE " . $monitor->name . " SET active = 0 WHERE id = '" . $GLOBALS['db']->quote($row['id']) . "'");
                     }
                 }
             }
         }
     }
     $GLOBALS['log']->debug('Current user is: ' . $GLOBALS['current_user']->user_name);
     $GLOBALS['logic_hook']->call_custom_logic('', 'after_load_user');
     // Reset ACLs in case after_load_user hook changed ACL setups
     SugarACL::resetACLs();
     //set cookies
     if (isset($_SESSION['authenticated_user_theme'])) {
         $GLOBALS['log']->debug("setting cookie ck_login_theme_20 to " . $_SESSION['authenticated_user_theme']);
         self::setCookie('ck_login_theme_20', $_SESSION['authenticated_user_theme'], time() + 86400 * 90);
     }
     if (isset($_SESSION['authenticated_user_theme_color'])) {
         $GLOBALS['log']->debug("setting cookie ck_login_theme_color_20 to " . $_SESSION['authenticated_user_theme_color']);
         self::setCookie('ck_login_theme_color_20', $_SESSION['authenticated_user_theme_color'], time() + 86400 * 90);
     }
     if (isset($_SESSION['authenticated_user_theme_font'])) {
         $GLOBALS['log']->debug("setting cookie ck_login_theme_font_20 to " . $_SESSION['authenticated_user_theme_font']);
         self::setCookie('ck_login_theme_font_20', $_SESSION['authenticated_user_theme_font'], time() + 86400 * 90);
     }
     if (isset($_SESSION['authenticated_user_language'])) {
         $GLOBALS['log']->debug("setting cookie ck_login_language_20 to " . $_SESSION['authenticated_user_language']);
         self::setCookie('ck_login_language_20', $_SESSION['authenticated_user_language'], time() + 86400 * 90);
     }
     //check if user can access
 }
 /**
  * Sets up necessary visibility for a client. Not all clients will set this
  *
  * @return void
  */
 public function setupVisibility()
 {
     // Add the necessary visibility and acl classes to the default bean list
     require_once 'modules/ACL/SugarACLSupportPortal.php';
     $default_acls = SugarBean::getDefaultACL();
     // This one overrides the Static ACL's, so disable that
     unset($default_acls['SugarACLStatic']);
     $default_acls['SugarACLStatic'] = false;
     $default_acls['SugarACLSupportPortal'] = true;
     SugarBean::setDefaultACL($default_acls);
     SugarACL::resetACLs();
     $default_visibility = SugarBean::getDefaultVisibility();
     $default_visibility['SupportPortalVisibility'] = true;
     SugarBean::setDefaultVisibility($default_visibility);
     $GLOBALS['log']->debug("Added SupportPortalVisibility to session.");
 }
 function login_success($name_value_list = array())
 {
     $GLOBALS['log']->info('Begin: SoapHelperWebServices->login_success');
     global $current_language, $sugar_config, $app_strings, $app_list_strings;
     $current_language = $sugar_config['default_language'];
     if (is_array($name_value_list) && !empty($name_value_list)) {
         foreach ($name_value_list as $key => $value) {
             if (isset($value['name']) && $value['name'] == 'language') {
                 $language = $value['value'];
                 $supportedLanguages = $sugar_config['languages'];
                 if (array_key_exists($language, $supportedLanguages)) {
                     $current_language = $language;
                 }
                 // if
             }
             // if
             if (isset($value['name']) && $value['name'] == 'notifyonsave') {
                 if ($value['value']) {
                     $_SESSION['notifyonsave'] = true;
                 }
             }
             // if
         }
         // foreach
     } else {
         if (isset($_SESSION['user_language'])) {
             $current_language = $_SESSION['user_language'];
         }
         // if
     }
     $GLOBALS['log']->info("Users language is = " . $current_language);
     $app_strings = return_application_language($current_language);
     $app_list_strings = return_app_list_strings_language($current_language);
     $GLOBALS['logic_hook']->call_custom_logic('', 'after_load_user');
     // Reset ACLs in case after_load_user hook changed ACL setups
     SugarACL::resetACLs();
     $GLOBALS['log']->info('End: SoapHelperWebServices->login_success');
 }