/** * Perform plugin-specific management functions. */ function plugin($args) { $category = array_shift($args); $plugin = array_shift($args); $verb = array_shift($args); parent::validate(); $plugins =& PluginRegistry::loadCategory($category); if (!isset($plugins[$plugin]) || !$plugins[$plugin]->manage($verb, $args)) { Request::redirect(null, null, 'plugins'); } }
/** * The site setting option 'preventManagerPluginManagement' must not be set for * journal managers to be able to manage plugins. * @param $request PKPRequest */ function validate($request) { parent::validate(); if (!Validation::isSiteAdmin()) { $site =& $request->getSite(); $preventManagerPluginManagement = $site->getSetting('preventManagerPluginManagement'); if ($preventManagerPluginManagement) { $request->redirect(null, 'manager', 'plugins'); } } }
/** * Validate that user has permissions to manage e-mail templates. * Redirects to user index page if not properly authenticated. * @param $request PKPRequest */ function validate(&$request) { parent::validate(); $schedConf =& $request->getSchedConf(); // If the user is a Conference Manager, but has specified a scheduled conference, // redirect so no scheduled conference is present (otherwise they would end up managing // scheduled conference e-mails.) if ($schedConf && !Validation::isConferenceManager()) { $request->redirect(null, 'index', $request->getRequestedPage(), $request->getRequestedOp()); } return true; }
/** * Save changes to a track. */ function updateTrack() { parent::validate(); $this->setupTemplate(true); import('manager.form.TrackForm'); $trackForm = new TrackForm(Request::getUserVar('trackId')); $trackForm->readInputData(); if ($trackForm->validate()) { $trackForm->execute(); Request::redirect(null, null, null, 'tracks'); } else { $trackForm->display(); } }
/** * Save changes to a track. */ function updateTrack($args, &$request) { parent::validate(); $this->setupTemplate($request, true); import('classes.manager.form.TrackForm'); $trackForm = new TrackForm($request->getUserVar('trackId')); $trackForm->readInputData(); if ($trackForm->validate()) { $trackForm->execute(); $request->redirect(null, null, null, 'tracks'); } else { $trackForm->display(); } }
/** * Display journal management index page. */ function index() { ManagerHandler::validate(); ManagerHandler::setupTemplate(); $journal =& Request::getJournal(); $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $subscriptionsEnabled = $journalSettingsDao->getSetting($journal->getJournalId(), 'enableSubscriptions'); $announcementsEnabled = $journalSettingsDao->getSetting($journal->getJournalId(), 'enableAnnouncements'); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('subscriptionsEnabled', $subscriptionsEnabled); $templateMgr->assign('announcementsEnabled', $announcementsEnabled); $templateMgr->assign('helpTopicId', 'journal.index'); $templateMgr->display('manager/index.tpl'); }
function reloadLocalizedDefaultSettings() { // make sure the locale is valid $locale = Request::getUserVar('localeToLoad'); if (!Locale::isLocaleValid($locale)) { Request::redirect(null, null, 'languages'); } parent::validate(); parent::setupTemplate(true); $journal =& Request::getJournal(); $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $journalSettingsDao->reloadLocalizedDefaultSettings($journal->getJournalId(), 'registry/journalSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'journalPath' => $journal->getData('path'), 'primaryLocale' => $journal->getPrimaryLocale(), 'journalName' => $journal->getTitle($journal->getPrimaryLocale())), $locale); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, Request::getRequestedPage()), 'backLinkLabel' => 'manager.journalManagement')); $templateMgr->display('common/message.tpl'); }
/** * Save changes to language settings. */ function saveLanguageSettings() { parent::validate(); parent::setupTemplate(true); import('manager.form.LanguageSettingsForm'); $settingsForm =& new LanguageSettingsForm(); $settingsForm->readInputData(); if ($settingsForm->validate()) { $settingsForm->execute(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, Request::getRequestedPage()), 'backLinkLabel' => 'manager.journalManagement')); $templateMgr->display('common/message.tpl'); } else { $settingsForm->display(); } }
function importexport($args) { parent::validate(); parent::setupTemplate(true); PluginRegistry::loadCategory(IMPORTEXPORT_PLUGIN_CATEGORY); $templateMgr =& TemplateManager::getManager(); if (array_shift($args) === 'plugin') { $pluginName = array_shift($args); $plugin =& PluginRegistry::getPlugin(IMPORTEXPORT_PLUGIN_CATEGORY, $pluginName); if ($plugin) { return $plugin->display($args); } } $templateMgr->assign_by_ref('plugins', PluginRegistry::getPlugins(IMPORTEXPORT_PLUGIN_CATEGORY)); $templateMgr->assign('helpTopicId', 'journal.managementPages.importExport'); $templateMgr->display('manager/importexport/plugins.tpl'); }
function fileDelete($args) { parent::validate(); FilesHandler::parseDirArg($args, $currentDir, $parentDir); $currentPath = FilesHandler::getRealFilesDir($currentDir); import('file.FileManager'); $fileMgr =& new FileManager(); if (@is_file($currentPath)) { $fileMgr->deleteFile($currentPath); } else { // TODO Use recursive delete (rmtree) instead? @$fileMgr->rmdir($currentPath); } Request::redirect(null, null, 'files', explode('/', $parentDir)); }
/** * Change the sequence of a section. */ function moveSection() { parent::validate(); $journal =& Request::getJournal(); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $section =& $sectionDao->getSection(Request::getUserVar('sectionId'), $journal->getJournalId()); if ($section != null) { $section->setSequence($section->getSequence() + (Request::getUserVar('d') == 'u' ? -1.5 : 1.5)); $sectionDao->updateSection($section); $sectionDao->resequenceSections($journal->getJournalId()); } Request::redirect(null, null, 'sections'); }
/** * Save changes to an announcement type. */ function updateAnnouncementType() { parent::validate(); import('manager.form.AnnouncementTypeForm'); $journal =& Request::getJournal(); $typeId = Request::getUserVar('typeId') == null ? null : (int) Request::getUserVar('typeId'); $announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO'); if ($typeId != null && $announcementTypeDao->getAnnouncementTypeJournalId($typeId) == $journal->getJournalId() || $typeId == null) { $announcementTypeForm =& new AnnouncementTypeForm($typeId); $announcementTypeForm->readInputData(); if ($announcementTypeForm->validate()) { $announcementTypeForm->execute(); if (Request::getUserVar('createAnother')) { Request::redirect(null, null, 'createAnnouncementType'); } else { Request::redirect(null, null, 'announcementTypes'); } } else { AnnouncementHandler::setupTemplate(true); $templateMgr =& TemplateManager::getManager(); $templateMgr->append('pageHierarchy', array(Request::url(null, 'manager', 'announcementTypes'), 'manager.announcementTypes')); if ($typeId == null) { $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.createTitle'); } else { $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.editTitle'); } $announcementTypeForm->display(); } } else { Request::redirect(null, null, 'announcementTypes'); } }
/** * Save changes to a timeBlock. */ function updateTimeBlock() { parent::validate(); SchedulerHandler::setupTemplate(true); import('manager.form.scheduler.TimeBlockForm'); $schedConf =& Request::getSchedConf(); $timeBlockId = Request::getUserVar('timeBlockId') == null ? null : (int) Request::getUserVar('timeBlockId'); $timeBlockDao =& DAORegistry::getDAO('TimeBlockDAO'); if ($timeBlockId != null && $timeBlockDao->getTimeBlockSchedConfId($timeBlockId) == $schedConf->getId() || $timeBlockId == null) { if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor $timeBlockForm = new TimeBlockForm($timeBlockId); } else { $timeBlockForm =& new TimeBlockForm($timeBlockId); } $timeBlockForm->readInputData(); if ($timeBlockForm->validate()) { $timeBlockForm->execute(); if (Request::getUserVar('createAnother')) { // Provide last block as template return $timeBlockForm->display(); } else { Request::redirect(null, null, null, 'timeBlocks'); } } else { $templateMgr =& TemplateManager::getManager(); $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'timeBlocks'), 'manager.scheduler.timeBlocks')); if ($timeBlockId == null) { $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.createTimeBlock'); } else { $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.editTimeBlock'); } $timeBlockForm->display(); } } else { Request::redirect(null, null, null, 'timeBlocks'); } }
function reportGenerator($args) { parent::validate(); $journal =& Request::getJournal(); $fromDate = Request::getUserDateVar('dateFrom', 1, 1); if ($fromDate !== null) { $fromDate = date('Y-m-d H:i:s', $fromDate); } $toDate = Request::getUserDateVar('dateTo', 32, 12, null, 23, 59, 59); if ($toDate !== null) { $toDate = date('Y-m-d H:i:s', $toDate); } $journalStatisticsDao =& DAORegistry::getDAO('JournalStatisticsDAO'); $reportType = (int) Request::getUserVar('reportType'); switch ($reportType) { case REPORT_TYPE_EDITOR: $report =& $journalStatisticsDao->getEditorReport($journal->getJournalId(), $fromDate, $toDate); break; case REPORT_TYPE_REVIEWER: $report =& $journalStatisticsDao->getReviewerReport($journal->getJournalId(), $fromDate, $toDate); break; case REPORT_TYPE_SECTION: $report =& $journalStatisticsDao->getSectionReport($journal->getJournalId(), $fromDate, $toDate); break; case REPORT_TYPE_JOURNAL: default: $reportType = REPORT_TYPE_JOURNAL; $report =& $journalStatisticsDao->getJournalReport($journal->getJournalId(), $fromDate, $toDate); break; } $templateMgr =& TemplateManager::getManager(); header('content-type: text/comma-separated-values'); header('content-disposition: attachment; filename=report.csv'); $separator = ','; // Display the heading row. switch ($reportType) { case REPORT_TYPE_EDITOR: echo Locale::translate('user.role.editor') . $separator; break; case REPORT_TYPE_REVIEWER: echo Locale::translate('user.role.reviewer') . $separator; echo Locale::translate('manager.statistics.reports.singleScore') . $separator; echo Locale::translate('user.affiliation') . $separator; break; case REPORT_TYPE_SECTION: echo Locale::translate('section.section') . $separator; break; } echo Locale::translate('article.submissionId'); for ($i = 0; $i < $report->getMaxAuthors(); $i++) { echo $separator . Locale::translate('manager.statistics.reports.author', array('num' => $i + 1)); echo $separator . Locale::translate('manager.statistics.reports.affiliation', array('num' => $i + 1)); echo $separator . Locale::translate('manager.statistics.reports.country', array('num' => $i + 1)); } echo $separator . Locale::translate('article.title'); if ($reportType !== REPORT_TYPE_SECTION) { echo $separator . Locale::translate('section.section'); } echo $separator . Locale::translate('submissions.submitted'); if ($reportType !== REPORT_TYPE_EDITOR) { for ($i = 0; $i < $report->getMaxEditors(); $i++) { echo $separator . Locale::translate('manager.statistics.reports.editor', array('num' => $i + 1)); } } if ($reportType !== REPORT_TYPE_REVIEWER) { for ($i = 0; $i < $report->getMaxReviewers(); $i++) { echo $separator . Locale::translate('manager.statistics.reports.reviewer', array('num' => $i + 1)); echo $separator . Locale::translate('manager.statistics.reports.score', array('num' => $i + 1)); echo $separator . Locale::translate('manager.statistics.reports.recommendation', array('num' => $i + 1)); } } echo $separator . Locale::translate('editor.article.decision'); echo $separator . Locale::translate('manager.statistics.reports.daysToDecision'); echo $separator . Locale::translate('manager.statistics.reports.daysToPublication'); echo "\n"; // Display the report. $dateFormatShort = Config::getVar('general', 'date_format_short'); while ($row =& $report->next()) { switch ($reportType) { case REPORT_TYPE_EDITOR: echo $row['editor'] . $separator; break; case REPORT_TYPE_REVIEWER: echo $row['reviewer'] . $separator; echo $row['score'] . $separator; echo $row['affiliation'] . $separator; break; case REPORT_TYPE_SECTION: echo $row['section'] . $separator; break; } echo $row['articleId']; for ($i = 0; $i < $report->getMaxAuthors(); $i++) { echo $separator . StatisticsHandler::csvEscape($row['authors'][$i]); echo $separator . StatisticsHandler::csvEscape($row['affiliations'][$i]); echo $separator . StatisticsHandler::csvEscape($row['countries'][$i]); } echo $separator . StatisticsHandler::csvEscape($row['title']); if ($reportType !== REPORT_TYPE_SECTION) { echo $separator . StatisticsHandler::csvEscape($row['section']); } echo $separator . $row['dateSubmitted']; if ($reportType !== REPORT_TYPE_EDITOR) { for ($i = 0; $i < $report->getMaxEditors(); $i++) { echo $separator . StatisticsHandler::csvEscape($row['editors'][$i]); } } if ($reportType !== REPORT_TYPE_REVIEWER) { for ($i = 0; $i < $report->getMaxReviewers(); $i++) { echo $separator . StatisticsHandler::csvEscape($row['reviewers'][$i]); echo $separator . StatisticsHandler::csvEscape($row['scores'][$i]); echo $separator . StatisticsHandler::csvEscape($row['recommendations'][$i]); } } echo $separator . StatisticsHandler::csvEscape($row['decision']); echo $separator . StatisticsHandler::csvEscape($row['daysToDecision']); echo $separator . StatisticsHandler::csvEscape($row['daysToPublication']); echo "\n"; } }
/** * Save subscription policies for the current journal. */ function saveSubscriptionPolicies($args = array()) { parent::validate(); import('subscription.form.SubscriptionPolicyForm'); $subscriptionPolicyForm =& new SubscriptionPolicyForm(); $subscriptionPolicyForm->readInputData(); if ($subscriptionPolicyForm->validate()) { $subscriptionPolicyForm->execute(); SubscriptionHandler::setupTemplate(true); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('helpTopicId', 'journal.managementPages.subscriptions'); $templateMgr->assign('subscriptionPoliciesSaved', '1'); if (Config::getVar('general', 'scheduled_tasks')) { $templateMgr->assign('scheduledTasksEnabled', true); } $subscriptionPolicyForm->display(); } else { $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('helpTopicId', 'journal.managementPages.subscriptions'); if (Config::getVar('general', 'scheduled_tasks')) { $templateMgr->assign('scheduledTasksEnabled', true); } $subscriptionPolicyForm->display(); } }
/** * Validate the request. If a group ID is supplied, the group object * will be fetched and validated against the current journal. If, * additionally, the user ID is supplied, the user and membership * objects will be validated and fetched. * @param $groupId int optional * @param $userId int optional * @param $fetchMembership boolean Whether or not to fetch membership object as last element of return array, redirecting if it doesn't exist; default false * @return array [$journal] iff $groupId is null, [$journal, $group] iff $userId is null and $groupId is supplied, and [$journal, $group, $user] iff $userId and $groupId are both supplied. $fetchMembership===true will append membership info to the last case, redirecting if it doesn't exist. */ function validate($groupId = null, $userId = null, $fetchMembership = false) { parent::validate(); $journal =& Request::getJournal(); $passedValidation = true; if ($groupId !== null) { $groupDao =& DAORegistry::getDAO('GroupDAO'); $group =& $groupDao->getGroup($groupId, ASSOC_TYPE_JOURNAL, $journal->getId()); if (!$group) { $passedValidation = false; } else { $this->group =& $group; } if ($userId !== null) { $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $userDao->getUser($userId); if (!$user) { $passedValidation = false; } else { $this->user =& $user; } if ($fetchMembership === true) { $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO'); $groupMembership =& $groupMembershipDao->getMembership($groupId, $userId); if (!$groupMembership) { $validationPassed = false; } else { $this->groupMembership =& $groupMembership; } } } } if (!$passedValidation) { Request::redirect(null, null, 'groups'); } return true; }
function report($args) { parent::validate(); $journal =& Request::getJournal(); $pluginName = array_shift($args); $reportPlugins =& PluginRegistry::loadCategory('reports'); if ($pluginName == '' || !isset($reportPlugins[$pluginName])) { Request::redirect(null, null, 'statistics'); } $plugin =& $reportPlugins[$pluginName]; $plugin->display($args); }
/** * enables an email template. * @param $args array first parameter is the key of the email to enable */ function enableEmail($args) { parent::validate(); if (isset($args) && !empty($args)) { $journal =& Request::getJournal(); $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO'); $emailTemplate = $emailTemplateDao->getBaseEmailTemplate($args[0], $journal->getJournalId()); if (isset($emailTemplate)) { if ($emailTemplate->getCanDisable()) { $emailTemplate->setEnabled(1); if ($emailTemplate->getEmailId() != null) { $emailTemplateDao->updateBaseEmailTemplate($emailTemplate); } else { $emailTemplateDao->insertBaseEmailTemplate($emailTemplate); } } } } Request::redirect(null, null, 'emails'); }
function downloadLayoutTemplate($args) { parent::validate(); $journal =& Request::getJournal(); $templates = $journal->getSetting('templates'); import('file.JournalFileManager'); $journalFileManager =& new JournalFileManager($journal); $templateId = (int) array_shift($args); if ($templateId >= count($templates) || $templateId < 0) { Request::redirect(null, null, 'setup'); } $template =& $templates[$templateId]; $filename = "template-{$templateId}." . $journalFileManager->parseFileExtension($template['originalFilename']); $journalFileManager->downloadFile($filename, $template['fileType']); }
/** * Save changes to a timeBlock. */ function updateTimeBlock($args, &$request) { parent::validate(); $this->setupTemplate($request, true); import('classes.manager.form.scheduler.TimeBlockForm'); $schedConf =& $request->getSchedConf(); $timeBlockId = $request->getUserVar('timeBlockId') == null ? null : (int) $request->getUserVar('timeBlockId'); $timeBlockDao = DAORegistry::getDAO('TimeBlockDAO'); if ($timeBlockId != null && $timeBlockDao->getTimeBlockSchedConfId($timeBlockId) == $schedConf->getId() || $timeBlockId == null) { $timeBlockForm = new TimeBlockForm($timeBlockId); $timeBlockForm->readInputData(); if ($timeBlockForm->validate()) { $timeBlockForm->execute(); if ($request->getUserVar('createAnother')) { // Provide last block as template return $timeBlockForm->display(); } else { $request->redirect(null, null, null, 'timeBlocks'); } } else { $templateMgr =& TemplateManager::getManager($request); $templateMgr->append('pageHierarchy', array($request->url(null, null, 'manager', 'timeBlocks'), 'manager.scheduler.timeBlocks')); if ($timeBlockId == null) { $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.createTimeBlock'); } else { $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.editTimeBlock'); } $timeBlockForm->display(); } } else { $request->redirect(null, null, null, 'timeBlocks'); } }
/** * Copy review form elemnts to another review form. */ function copyReviewFormElement() { parent::validate(); $copy = Request::getUserVar('copy'); $targetReviewFormId = Request::getUserVar('targetReviewForm'); $journal =& Request::getJournal(); $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO'); if ($reviewFormDao->unusedReviewFormExists($targetReviewFormId, $journal->getJournalId())) { $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO'); foreach ($copy as $reviewFormElementId) { $reviewFormElement =& $reviewFormElementDao->getReviewFormElement($reviewFormElementId); if (isset($reviewFormElement) && $reviewFormDao->unusedReviewFormExists($reviewFormElement->getReviewFormId(), $journal->getJournalId())) { $reviewFormElement->setReviewFormId($targetReviewFormId); $reviewFormElement->setSequence(REALLY_BIG_NUMBER); $reviewFormElementDao->insertReviewFormElement($reviewFormElement); $reviewFormElementDao->resequenceReviewFormElements($targetReviewFormId); } unset($reviewFormElement); } } Request::redirect(null, null, 'reviewFormElements', array($targetReviewFormId)); }
/** * Save changes to payment settings. */ function savePayMethodSettings() { parent::validate(); parent::setupTemplate(true); $journal =& Request::getJournal(); if (!$journal) { Request::redirect(null, null, 'index'); } import('manager.form.PayMethodSettingsForm'); $settingsForm =& new PayMethodSettingsForm(); $settingsForm->readInputData(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('helpTopicId', 'journal.managementPages.payments'); if ($settingsForm->validate()) { $settingsForm->execute(); $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'payMethodSettings'), 'pageTitle' => 'manager.payment.paymentMethods', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, null, 'payMethodSettings'), 'backLinkLabel' => 'manager.payment.paymentMethods')); $templateMgr->display('common/message.tpl'); } else { $settingsForm->display(); } }
/** * Validate the request. If a group ID is supplied, the group object * will be fetched and validated against the current journal. If, * additionally, the user ID is supplied, the user and membership * objects will be validated and fetched. * @param $groupId int optional * @param $userId int optional * @param $fetchMembership boolean Whether or not to fetch membership object as last element of return array, redirecting if it doesn't exist; default false * @return array [$journal] iff $groupId is null, [$journal, $group] iff $userId is null and $groupId is supplied, and [$journal, $group, $user] iff $userId and $groupId are both supplied. $fetchMembership===true will append membership info to the last case, redirecting if it doesn't exist. */ function validate($groupId = null, $userId = null, $fetchMembership = false) { parent::validate(); $journal =& Request::getJournal(); $returner = array(&$journal); $passedValidation = true; if ($groupId !== null) { $groupDao =& DAORegistry::getDAO('GroupDAO'); $group =& $groupDao->getGroup($groupId); if (!$group || $group->getJournalId() !== $journal->getJournalId()) { $passedValidation = false; } else { $returner[] =& $group; } if ($userId !== null) { $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $userDao->getUser($userId); if (!$user) { $passedValidation = false; } else { $returner[] =& $user; } if ($fetchMembership === true) { $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO'); $groupMembership =& $groupMembershipDao->getMembership($groupId, $userId); if (!$groupMembership) { $validationPassed = false; } else { $returner[] =& $groupMembership; } } } } if (!$passedValidation) { Request::redirect(null, null, 'groups'); } return $returner; }
/** * Sign in as another user. * @param $args array ($userId) */ function signInAsUser($args) { parent::validate(); if (isset($args[0]) && !empty($args[0])) { $userId = (int) $args[0]; $journal =& Request::getJournal(); if (!Validation::canAdminister($journal->getJournalId(), $userId)) { // We don't have administrative rights // over this user. Display an error. $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageTitle', 'manager.people'); $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights'); $templateMgr->assign('backLink', Request::url(null, null, 'people', 'all')); $templateMgr->assign('backLinkLabel', 'manager.people.allUsers'); return $templateMgr->display('common/error.tpl'); } $userDao =& DAORegistry::getDAO('UserDAO'); $newUser =& $userDao->getUser($userId); $session =& Request::getSession(); // FIXME Support "stack" of signed-in-as user IDs? if (isset($newUser) && $session->getUserId() != $newUser->getUserId()) { $session->setSessionVar('signedInAs', $session->getUserId()); $session->setSessionVar('userId', $userId); $session->setUserId($userId); $session->setSessionVar('username', $newUser->getUsername()); Request::redirect(null, 'user'); } } Request::redirect(null, Request::getRequestedPage()); }