private function populateSiteState(&$state, Oxygen_Http_Request $request) { // See how $site_key gets generated in _update_process_fetch_task() for statistical purposes. $state['siteKey'] = strtr(base64_encode(hash_hmac('sha256', (string) $this->context->getGlobal('base_url'), (string) $this->state->get('drupal_private_key'), true)), array('+' => '-', '/' => '_', '=' => '')); $state['cronKey'] = (string) $this->state->get('cron_key'); $state['cronLastRunAt'] = (int) $this->state->get('cron_last'); $state['siteMail'] = (string) $this->state->get('site_mail'); $state['siteName'] = (string) $this->state->get('site_name'); $state['siteRoot'] = isset($request->server['SCRIPT_FILENAME']) ? Oxygen_Util::normalizePath(dirname($request->server['SCRIPT_FILENAME'])) : ''; $state['drupalRoot'] = Oxygen_Util::normalizePath($this->context->getConstant('DRUPAL_ROOT')); $state['drupalVersion'] = $this->context->getConstant('VERSION'); $state['drupalMajorVersion'] = (int) basename($this->context->getConstant('DRUPAL_CORE_COMPATIBILITY'), '.x'); $state['timezone'] = (string) $this->state->get('date_default_timezone'); }
/** * @internal * * @param string $userUid UID of the user on the management dashboard, not a Drupal's user. * @param string $name * * @return Oxygen_Http_RedirectResponse * * @throws Oxygen_Exception */ public function loginUser($userUid, $name) { if (strlen($name)) { $user = $this->userManager->findUserByName($name); } else { $user = $this->userManager->findUserById(1); } if ($user === null) { throw new Oxygen_Exception(Oxygen_Exception::AUTO_LOGIN_CAN_NOT_FIND_USER, array('name' => $name)); } $this->sessionManager->userLogin($user); $options = array(); $httpResponseCode = 302; $sessionId = $this->sessionManager->getSessionId(); $this->sessionManager->registerSession($userUid, $sessionId); $path = 'admin/dashboard'; $this->context->alter('drupal_goto', $path, $options, $httpResponseCode); $options = array('absolute' => true); // The 'Location' HTTP header must be absolute. $options['absolute'] = true; $url = $this->context->url($path, $options); $response = new Oxygen_Http_RedirectResponse($url, $httpResponseCode); return $response; }
/** * @param stdClass $user */ public function userLogin(stdClass $user) { $this->context->setGlobal('user', $user); $login = array('name' => $user->name); user_login_finalize($login); }