public function hasAccess()
 {
     $primaryUser = SwitchUserIdentity::getPrimaryUser();
     //to allow super admins to switch user change the following to
     // Yii::app()->user->userModel->isSuperAdministrator());
     return isset($primaryUser) || Yii::app()->user->userModel->isRootUser;
 }
 public function actionSwitchTo($username)
 {
     $identity = new SwitchUserIdentity($username, null);
     if ($identity->authenticate()) {
         Yii::app()->user->login($identity);
         $this->redirect(Yii::app()->user->returnUrl);
     } else {
         throw new NotSupportedException("Can not switch user");
     }
 }
 protected static function renderUserSwitchControl()
 {
     static::registerUserSwitcherScripts();
     $primaryUser = SwitchUserIdentity::getPrimaryUser();
     $switchedUserContent = '';
     $userSwitcherWrapperClasses = 'user-menu-item';
     if ($primaryUser) {
         $userSwitcherWrapperClasses .= ' switched-user';
         $switchedUserContent = static::renderSwitchedUserContent($primaryUser);
     }
     $userSwitcherContainer = static::renderUserSwitcherContainer($switchedUserContent);
     $content = ZurmoHtml::link('“', '#', array('id' => static::USER_SWITCHER_LINK_ID));
     $content .= $userSwitcherContainer;
     $content = ZurmoHtml::tag('div', array('id' => static::USER_SWITCHER_WRAPPER_ID, 'class' => $userSwitcherWrapperClasses), $content);
     return $content;
 }