classes/core/PageRouter.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00017 // $Id$
00018 
00019 
00020 import('core.PKPPageRouter');
00021 
00022 class PageRouter extends PKPPageRouter {
00027    function redirectHome(&$request) {
00028       $roleDao =& DAORegistry::getDAO('RoleDAO');
00029       $user = $request->getUser();
00030       $userId = $user->getId();
00031 
00032       if ($schedConf =& $this->getContext($request, 2)) {
00033          // The user is in the sched. conf. context, see if they have one role only
00034          $roles =& $roleDao->getRolesByUserId($userId, $schedConf->getConferenceId(), $schedConf->getId());
00035          if(count($roles) == 1) {
00036             $role = array_shift($roles);
00037             if ($role->getRoleId() == ROLE_ID_READER) $request->redirect(null, 'index');
00038             $request->redirect(null, null, $role->getRolePath());
00039          } else {
00040             $request->redirect(null, null, 'user');
00041          }
00042       } elseif ($conference =& $this->getContext($request, 1)) {
00043          // The user is in the conference context, see if they have one role only
00044          $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00045          $roles =& $roleDao->getRolesByUserId($userId, $conference->getId());
00046          if(count($roles) == 1) {
00047             $role = array_shift($roles);
00048             $confPath = $conference->getPath();
00049             $schedConfPath = 'index';
00050 
00051             if ($role->getSchedConfId()) {
00052                $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
00053                $schedConfPath = $schedConf->getPath();
00054             }
00055             if ($role->getRoleId() == ROLE_ID_READER) $request->redirect($confPath, $schedConfPath, 'index');
00056             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
00057          } else {
00058             $request->redirect(null, null,  'user');
00059          }
00060       } else {
00061          // The user is at the site context, check to see if they are
00062          // only registered in one conf/SchedConf w/ one role
00063          $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00064          $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00065          $roles = $roleDao->getRolesByUserId($userId);
00066 
00067          if(count($roles) == 1) {
00068             $role = array_shift($roles);
00069             $confPath = 'index';
00070             $schedConfPath = 'index';
00071 
00072             if ($role->getConferenceId()) {
00073                $conference = $conferenceDao->getConference($role->getConferenceId());
00074                isset($conference) ? $confPath = $conference->getPath() :
00075                                $confPath = 'index';
00076             }
00077             if ($role->getSchedConfId()) {
00078                $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
00079                isset($schedConf) ? $schedConfPath = $schedConf->getPath() :
00080                               $schedConfPath = 'index';
00081             }
00082 
00083             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
00084          } else $request->redirect('index', 'index', 'user');
00085       }
00086    }
00087 }
00088 
00089 ?>

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