Ejemplo n.º 1
0
 /**
  * A method to switch the active account to a different one
  *
  * @static
  * @param int $accountId
  * @param boolean $hasAccess  Can be used for optimization - if we know that user
  *                            has access to the account he is switching to there is
  *                            no need to check it again
  */
 public static function switchAccount($accountId, $hasAccess = false)
 {
     if ($hasAccess || self::hasAccess($accountId)) {
         $oUser =& self::getCurrentUser();
         $oUser->loadAccountData($accountId);
     }
     // Force session save
     phpAds_SessionDataRegister('user', $oUser);
     // If exists previous message related to switchAccount remove it
     OA_Admin_UI::removeOneMessage('switchAccount');
     // Queue confirmation message
     $translation = new OX_Translation();
     $translated_message = $translation->translate($GLOBALS['strYouAreNowWorkingAsX'], array(htmlspecialchars($oUser->aAccount['account_name'])));
     OA_Admin_UI::queueMessage($translated_message, 'global', 'info', null, 'switchAccount');
 }