original_string: protected function _initToken()
      {
          if ($this->tracker) {
              return $this->token && $this->token->exists;
          }
  
          $this->tracker = $this->loader->getTracker();
          $this->tokenId = $this->tracker->filterToken($this->_getParam(\MUtil_Model::REQUEST_ID));
          // Now check if the token is valid
          $validator = $this->tracker->getTokenValidator();
  
          if (! $this->tokenId || $validator->isValid($this->tokenId) === false) {
              return false;
          }
  
          $this->token = $this->tracker->getToken($this->tokenId);
  
          if (! $this->token->exists) {
              return false;
          }
  
          if (! ($this->currentUser->isActive() || $this->token->getSurvey()->isTakenByStaff())) {
              $tokenLang = strtolower($this->token->getRespondentLanguage());
              // \MUtil_Echo::track($tokenLang, $this->locale->getLanguage());
              if ($tokenLang != $this->locale->getLanguage()) {
                  $this->currentUser->switchLocale($tokenLang);
              }
  
              $currentOrg = $this->loader->getOrganization();
              $tokenOrgId = $this->token->getOrganizationId();
  
              if ($tokenOrgId != $currentOrg->getId()) {
                  $this->loader->getOrganization($tokenOrgId)
                          ->setAsCurrentOrganization();
              }
          }
  
          return true;
      }
code: protected function _initToken()
      {
          if ($this->tracker) {
              return $this->token && $this->token->exists;
          }
  
          $this->tracker = $this->loader->getTracker();
          $this->tokenId = $this->tracker->filterToken($this->_getParam(\MUtil_Model::REQUEST_ID));
          // Now check if the token is valid
          $validator = $this->tracker->getTokenValidator();
  
          if (! $this->tokenId || $validator->isValid($this->tokenId) === false) {
              return false;
          }
  
          $this->token = $this->tracker->getToken($this->tokenId);
  
          if (! $this->token->exists) {
              return false;
          }
  
          if (! ($this->currentUser->isActive() || $this->token->getSurvey()->isTakenByStaff())) {
              $tokenLang = strtolower($this->token->getRespondentLanguage());
              // \MUtil_Echo::track($tokenLang, $this->locale->getLanguage());
              if ($tokenLang != $this->locale->getLanguage()) {
                  $this->currentUser->switchLocale($tokenLang);
              }
  
              $currentOrg = $this->loader->getOrganization();
              $tokenOrgId = $this->token->getOrganizationId();
  
              if ($tokenOrgId != $currentOrg->getId()) {
                  $this->loader->getOrganization($tokenOrgId)
                          ->setAsCurrentOrganization();
              }
          }
  
          return true;
      }
code_tokens: protected function _initToken ( ) { if ( $ this -> tracker ) { return $ this -> token && $ this -> token -> exists ; } $ this -> tracker = $ this -> loader -> getTracker ( ) ; $ this -> tokenId = $ this -> tracker -> filterToken ( $ this -> _getParam ( \ MUtil_Model :: REQUEST_ID ) ) ; // Now check if the token is valid $ validator = $ this -> tracker -> getTokenValidator ( ) ; if ( ! $ this -> tokenId || $ validator -> isValid ( $ this -> tokenId ) === false ) { return false ; } $ this -> token = $ this -> tracker -> getToken ( $ this -> tokenId ) ; if ( ! $ this -> token -> exists ) { return false ; } if ( ! ( $ this -> currentUser -> isActive ( ) || $ this -> token -> getSurvey ( ) -> isTakenByStaff ( ) ) ) { $ tokenLang = strtolower ( $ this -> token -> getRespondentLanguage ( ) ) ; // \MUtil_Echo::track($tokenLang, $this->locale->getLanguage()); if ( $ tokenLang != $ this -> locale -> getLanguage ( ) ) { $ this -> currentUser -> switchLocale ( $ tokenLang ) ; } $ currentOrg = $ this -> loader -> getOrganization ( ) ; $ tokenOrgId = $ this -> token -> getOrganizationId ( ) ; if ( $ tokenOrgId != $ currentOrg -> getId ( ) ) { $ this -> loader -> getOrganization ( $ tokenOrgId ) -> setAsCurrentOrganization ( ) ; } } return true ; }
docstring: Common handler utility to initialize tokens from parameters
  
  @return boolean True if there is a real token specified in the request
docstring_tokens: Common handler utility to initialize tokens from parameters