pages/login/LoginHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 
00018 import('pages.login.PKPLoginHandler');
00019 
00020 class LoginHandler extends PKPLoginHandler {
00025    function signInAsUser($args) {
00026       $this->addCheck(new HandlerValidatorConference($this));     
00027       $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_SITE_ADMIN, ROLE_ID_CONFERENCE_MANAGER)));
00028       $this->validate();
00029 
00030       if (isset($args[0]) && !empty($args[0])) {
00031          $userId = (int)$args[0];
00032          $conference =& Request::getConference();
00033 
00034          if (!Validation::canAdminister($conference->getId(), $userId)) {
00035             $this->setupTemplate();
00036             // We don't have administrative rights
00037             // over this user. Display an error.
00038             $templateMgr =& TemplateManager::getManager();
00039             $templateMgr->assign('pageTitle', 'manager.people');
00040             $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
00041             $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
00042             $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
00043             return $templateMgr->display('common/error.tpl');
00044          }
00045 
00046          $userDao =& DAORegistry::getDAO('UserDAO');
00047          $newUser =& $userDao->getUser($userId);
00048          $session =& Request::getSession();
00049 
00050          // FIXME Support "stack" of signed-in-as user IDs?
00051          if (isset($newUser) && $session->getUserId() != $newUser->getId()) {
00052             $session->setSessionVar('signedInAs', $session->getUserId());
00053             $session->setSessionVar('userId', $userId);
00054             $session->setUserId($userId);
00055             $session->setSessionVar('username', $newUser->getUsername());
00056             Request::redirect(null, null, 'user');
00057          }
00058       }
00059       Request::redirect(null, null, Request::getRequestedPage());
00060    }
00061 
00065    function signOutAsUser() {
00066       $this->validate();
00067 
00068       $session =& Request::getSession();
00069       $signedInAs = $session->getSessionVar('signedInAs');
00070 
00071       if (isset($signedInAs) && !empty($signedInAs)) {
00072          $signedInAs = (int)$signedInAs;
00073 
00074          $userDao =& DAORegistry::getDAO('UserDAO');
00075          $oldUser =& $userDao->getUser($signedInAs);
00076 
00077          $session->unsetSessionVar('signedInAs');
00078 
00079          if (isset($oldUser)) {
00080             $session->setSessionVar('userId', $signedInAs);
00081             $session->setUserId($signedInAs);
00082             $session->setSessionVar('username', $oldUser->getUsername());
00083          }
00084       }
00085 
00086       Request::redirect(null, 'user');
00087    }
00088 
00092    function _getLoginUrl() {
00093       return Request::url(null, null, 'login', 'signIn');
00094    }
00095 
00100    function _setMailFrom(&$mail) {
00101       $site =& Request::getSite();
00102       $conference =& Request::getConference();
00103       $schedConf =& Request::getSchedConf();
00104       
00105       // Set the sender to one of three different settings, based on context
00106       if ($schedConf && $schedConf->getSetting('supportEmail')) {
00107          $mail->setFrom($schedConf->getSetting('supportEmail'), $schedConf->getSetting('supportName'));
00108       } elseif ($conference && $conference->getSetting('contactEmail')) {
00109          $mail->setFrom($conference->getSetting('contactEmail'), $conference->getSetting('contactName'));
00110       } else {
00111          $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName());
00112       }
00113    }
00114 
00118    function setupTemplate() {
00119       AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_MANAGER, LOCALE_COMPONENT_PKP_MANAGER));
00120       parent::setupTemplate();
00121    }
00122 }
00123 
00124 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7