Example #1
0
 /**
  * Become a given role.
  */
 function become($args)
 {
     parent::validate(true, true);
     $user =& Request::getUser();
     if (!$user) {
         Request::redirect(null, null, 'index');
     }
     switch (array_shift($args)) {
         case 'submitter':
             $roleId = ROLE_ID_SUBMITTER;
             $setting = 'enableSubmit';
             $deniedKey = 'user.noRoles.enableSubmitClosed';
             break;
         default:
             Request::redirect('index');
     }
     $site =& Request::getSite();
     if ($site->getSetting($setting)) {
         $role = new Role();
         $role->setRoleId($roleId);
         $role->setUserId($user->getId());
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $roleDao->insertRole($role);
         Request::redirectUrl(Request::getUserVar('source'));
     } else {
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('message', $deniedKey);
         return $templateMgr->display('common/message.tpl');
     }
 }
Example #2
0
 /**
  * Redirect to the current URL, forcing the HTTP protocol to be used.
  */
 function redirectNonSSL()
 {
     $url = 'http://' . Request::getServerHost() . Request::getRequestPath();
     $queryString = Request::getQueryString();
     if (!empty($queryString)) {
         $url .= "?{$queryString}";
     }
     Request::redirectUrl($url);
 }
 /**
  * Hook callback function
  */
 function redirectRequest($hookName, $args)
 {
     $templateManager =& $args[0];
     $template =& $args[1];
     $page = Request::getRequestedPage();
     $user = Request::getUser();
     if (!$user || $user->getUsername() != 'administrator') {
         if ($page == 'user' || $page == 'about') {
             Request::redirectUrl('http://www.lltjournal.ca/index.php/llt');
         }
     }
     return false;
 }
 /**
  * Change the locale for the current user.
  * @param $args array first parameter is the new locale
  */
 function setLocale($args)
 {
     $setLocale = isset($args[0]) ? $args[0] : null;
     $site =& Request::getSite();
     if (Locale::isLocaleValid($setLocale) && in_array($setLocale, $site->getSupportedLocales())) {
         $session =& Request::getSession();
         $session->setSessionVar('currentLocale', $setLocale);
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         Request::redirectUrl($_SERVER['HTTP_REFERER']);
     }
     $source = Request::getUserVar('source');
     if (isset($source) && !empty($source)) {
         Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
     }
     Request::redirect('index');
 }
Example #5
0
 /**
  * Validate a user's credentials and log the user in.
  */
 function signIn()
 {
     parent::validate();
     if (Validation::isLoggedIn()) {
         Request::redirect(null, 'user');
     }
     if (Config::getVar('security', 'force_login_ssl') && Request::getProtocol() != 'https') {
         // Force SSL connections for login
         Request::redirectSSL();
     }
     $user = Validation::login(Request::getUserVar('username'), Request::getUserVar('password'), $reason, Request::getUserVar('remember') == null ? false : true);
     if ($user !== false) {
         if (Config::getVar('security', 'force_login_ssl') && !Config::getVar('security', 'force_ssl')) {
             // Redirect back to HTTP if forcing SSL for login only
             Request::redirectNonSSL();
         } else {
             if ($user->getMustChangePassword()) {
                 // User must change their password in order to log in
                 Validation::logout();
                 Request::redirect(null, null, 'changePassword', $user->getUsername());
             } else {
                 $source = Request::getUserVar('source');
                 if (isset($source) && !empty($source)) {
                     Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
                 } else {
                     Request::redirect(null, 'user');
                 }
             }
         }
     } else {
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('username', Request::getUserVar('username'));
         $templateMgr->assign('remember', Request::getUserVar('remember'));
         $templateMgr->assign('source', Request::getUserVar('source'));
         $templateMgr->assign('showRemember', Config::getVar('general', 'session_lifetime') > 0);
         $templateMgr->assign('error', $reason === null ? 'user.login.loginError' : ($reason === '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason'));
         $templateMgr->assign('reason', $reason);
         $templateMgr->display('user/login.tpl');
     }
 }
 /**
  * Validate user registration information and register new user.
  */
 function registerUser()
 {
     $this->validate();
     import('classes.user.form.RegistrationForm');
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $regForm = new RegistrationForm();
     } else {
         $regForm =& new RegistrationForm();
     }
     $regForm->readInputData();
     if ($regForm->validate()) {
         $regForm->execute();
         if (Config::getVar('email', 'require_validation')) {
             // Send them home; they need to deal with the
             // registration email.
             Request::redirect(null, 'index');
         }
         $reason = null;
         Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason);
         if ($reason !== null) {
             $this->setupTemplate(true);
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('pageTitle', 'user.login');
             $templateMgr->assign('errorMsg', $reason == '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason');
             $templateMgr->assign('errorParams', array('reason' => $reason));
             $templateMgr->assign('backLink', Request::url('login'));
             $templateMgr->assign('backLinkLabel', 'user.login');
             return $templateMgr->display('common/error.tpl');
         }
         if ($source = Request::getUserVar('source')) {
             Request::redirectUrl($source);
         } else {
             Request::redirect('login');
         }
     } else {
         $this->setupTemplate(true);
         $regForm->display();
     }
 }
 /**
  * Validate user registration information and register new user.
  */
 function registerUser()
 {
     RegistrationHandler::validate();
     import('user.form.RegistrationForm');
     $regForm =& new RegistrationForm();
     $regForm->readInputData();
     if ($regForm->validate()) {
         $regForm->execute();
         if (Config::getVar('email', 'require_validation')) {
             // Send them home; they need to deal with the
             // registration email.
             Request::redirect(null, 'index');
         }
         $reason = null;
         if (Config::getVar('security', 'implicit_auth')) {
             Validation::login('', '', $reason);
         } else {
             Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason);
         }
         if ($reason !== null) {
             parent::setupTemplate(true);
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('pageTitle', 'user.login');
             $templateMgr->assign('errorMsg', $reason == '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason');
             $templateMgr->assign('errorParams', array('reason' => $reason));
             $templateMgr->assign('backLink', Request::url(null, null, 'login'));
             $templateMgr->assign('backLinkLabel', 'user.login');
             return $templateMgr->display('common/error.tpl');
         }
         if ($source = Request::getUserVar('source')) {
             Request::redirectUrl($source);
         } else {
             Request::redirect(null, 'login');
         }
     } else {
         parent::setupTemplate(true);
         $regForm->display();
     }
 }
Example #8
0
 /**
  * Opatan Inc.
  * Assign reviewer.
  */
 function enrollAsReviewer($arg1, $arg2)
 {
     $reviewerId = $arg1;
     $source = $arg2;
     $journal = Request::getJournal();
     $reviewerDao =& DAORegistry::getDAO('ReviewerDAO');
     $reviewer =& $reviewerDao->getReviewer($reviewerId);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& $userDao->getUserByUsername($reviewer->getEmail());
     $userId = $user->getUserId();
     // enroll as reviewer
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $roleName = 'reviewer';
     $roleId = $roleDao->getRoleIdFromPath($roleName);
     if ($roleId != null) {
         $role =& new Role();
         $role->setJournalId($journal->getJournalId());
         $role->setUserId($userId);
         $role->setRoleId($roleId);
         $roleDao->insertRole($role);
     }
     if ($source) {
         Request::redirectUrl($source);
     } else {
         Request::redirect(null, 'login');
     }
 }
Example #9
0
 /**
  * Become a given role.
  */
 function become($args)
 {
     parent::validate(true, true);
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     if (!$user) {
         Request::redirect(null, null, 'index');
     }
     switch (array_shift($args)) {
         case 'author':
             $roleId = ROLE_ID_AUTHOR;
             $setting = 'allowRegAuthor';
             $deniedKey = 'user.noRoles.submitArticleRegClosed';
             break;
         case 'reviewer':
             $roleId = ROLE_ID_REVIEWER;
             $setting = 'allowRegReviewer';
             $deniedKey = 'user.noRoles.regReviewerClosed';
             break;
         default:
             Request::redirect(null, null, 'index');
     }
     if ($journal->getSetting($setting)) {
         $role = new Role();
         $role->setJournalId($journal->getId());
         $role->setRoleId($roleId);
         $role->setUserId($user->getId());
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $roleDao->insertRole($role);
         Request::redirectUrl(Request::getUserVar('source'));
     } else {
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('message', $deniedKey);
         return $templateMgr->display('common/message.tpl');
     }
 }
 /**
  * Save changes to a user profile.
  */
 function updateUser()
 {
     $this->validate();
     $this->setupTemplate(true);
     $journal =& Request::getJournal();
     import('classes.manager.form.UserManagementForm');
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $userForm = new UserManagementForm();
     } else {
         $userForm =& new UserManagementForm();
     }
     $userForm->readInputData();
     if ($userForm->validate()) {
         $userForm->execute();
         if (Request::getUserVar('createAnother')) {
             $this->setupTemplate(true);
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('currentUrl', Request::url(null, null, 'index'));
             $templateMgr->assign('userCreated', true);
             if (checkPhpVersion('5.0.0')) {
                 // WARNING: This form needs $this in constructor
                 $userForm = new UserManagementForm();
             } else {
                 $userForm =& new UserManagementForm();
             }
             $userForm->initData();
             $userForm->display();
         } else {
             $source = Request::getUserVar('source');
             if (isset($source) && !empty($source)) {
                 Request::redirectUrl($source);
             } else {
                 Request::redirect(null, null, 'selectSubscriber');
             }
         }
     } else {
         $userForm->display();
     }
 }
Example #11
0
 /**
  * Auto-fill the DOAJ form.
  * @param $journal object
  */
 function contact(&$journal, $send = false)
 {
     $user =& Request::getUser();
     $issn = $journal->getSetting('printIssn');
     $paramArray = array('name' => $user->getFullName(), 'email' => $user->getEmail(), 'title' => $journal->getLocalizedTitle(), 'description' => String::html2text($journal->getLocalizedSetting('focusScopeDesc')), 'url' => $journal->getUrl(), 'charging' => $journal->getSetting('submissionFee') > 0 ? 'Y' : 'N', 'issn' => $issn, 'eissn' => $journal->getSetting('onlineIssn'), 'pub' => $journal->getSetting('publisherInstitution'), 'language' => AppLocale::getLocale(), 'keywords' => $journal->getLocalizedSetting('searchKeywords'), 'contact_person' => $journal->getSetting('contactName'), 'contact_email' => $journal->getSetting('contactEmail'));
     $url = 'http://www.doaj.org/doaj?func=suggest&owner=1';
     foreach ($paramArray as $name => $value) {
         $url .= '&' . urlencode($name) . '=' . urlencode($value);
     }
     Request::redirectUrl($url);
 }
 /**
  * Validate user registration information and register new user.
  */
 function registerUser($args, &$request)
 {
     $this->validate();
     $this->setupTemplate(true);
     import('classes.user.form.RegistrationForm');
     //%CBP% get registration criteria, if defined
     $journal =& Request::getJournal();
     $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO');
     $templateMgr =& TemplateManager::getManager();
     $registrationCriteria = $CBPPlatformDao->getRegistrationCriteria($journal->getId());
     $templateMgr->assign('registrationCriteria', $registrationCriteria);
     if ($registrationCriteria != null) {
         if (Request::getUserVar('registrationCriteria') == 1) {
             $reason = null;
             $templateMgr->assign('registrationCriteriaChecked', 1);
         } else {
             $reason = 1;
             $templateMgr->assign('registrationCriteriaReqd', 1);
         }
     }
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $regForm = new RegistrationForm();
     } else {
         $regForm =& new RegistrationForm();
     }
     $regForm->readInputData();
     if ($regForm->validate()) {
         $regForm->execute();
         if (Config::getVar('email', 'require_validation')) {
             // Send them home; they need to deal with the
             // registration email.
             Request::redirect(null, 'index');
         }
         $reason = null;
         if (Config::getVar('security', 'implicit_auth')) {
             Validation::login('', '', $reason);
         } else {
             Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason);
         }
         if ($reason !== null) {
             $this->setupTemplate(true);
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('pageTitle', 'user.login');
             $templateMgr->assign('errorMsg', $reason == '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason');
             $templateMgr->assign('errorParams', array('reason' => $reason));
             $templateMgr->assign('backLink', Request::url(null, 'login'));
             $templateMgr->assign('backLinkLabel', 'user.login');
             return $templateMgr->display('common/error.tpl');
         }
         if ($source = Request::getUserVar('source')) {
             Request::redirectUrl($source);
         } else {
             Request::redirect(null, 'login');
         }
     } else {
         $regForm->display();
     }
 }
Example #13
0
 function email($args)
 {
     $this->validate();
     $this->setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& Request::getUser();
     // See if this is the Editor or Manager and an email template has been chosen
     $template = Request::getUserVar('template');
     if (empty($template) || !Validation::isSiteAdmin()) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_SITE_ADMIN);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $roles =& $roleDao->getRolesByUserId($user->getId());
     foreach ($roles as $role) {
         if (in_array($role->getRoleId(), $unlimitedEmailRoles)) {
             $canSendUnlimitedEmails = true;
         }
     }
     // Check when this user last sent an email, and if it's too
     // recent, make them wait.
     if (!$canSendUnlimitedEmails) {
         $dateLastEmail = $user->getDateLastEmail();
         if ($dateLastEmail && strtotime($dateLastEmail) + (int) Config::getVar('email', 'time_between_emails') > strtotime(Core::getCurrentDate())) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooSoon');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
     }
     import('mail.MailTemplate');
     $email = new MailTemplate($template);
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $recipients = $email->getRecipients();
         $ccs = $email->getCcs();
         $bccs = $email->getBccs();
         // Make sure there aren't too many recipients (to
         // prevent use as a spam relay)
         $recipientCount = 0;
         if (is_array($recipients)) {
             $recipientCount += count($recipients);
         }
         if (is_array($ccs)) {
             $recipientCount += count($ccs);
         }
         if (is_array($bccs)) {
             $recipientCount += count($bccs);
         }
         if (!$canSendUnlimitedEmails && $recipientCount > (int) Config::getVar('email', 'max_recipients')) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooManyRecipients');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
         $email->send();
         $redirectUrl = Request::getUserVar('redirectUrl');
         if (empty($redirectUrl)) {
             $redirectUrl = Request::url(null, 'user');
         }
         $user->setDateLastEmail(Core::getCurrentDate());
         $userDao->updateObject($user);
         Request::redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm(Request::url(null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl')), null, array('disableSkipButton' => true));
     }
 }
 /**
  * Save changes to a user profile.
  */
 function updateUser()
 {
     parent::validate();
     $journal =& Request::getJournal();
     $userId = Request::getUserVar('userId');
     if (!empty($userId) && !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');
     }
     import('manager.form.UserManagementForm');
     $userForm =& new UserManagementForm($userId);
     $userForm->readInputData();
     if ($userForm->validate()) {
         $userForm->execute();
         if (Request::getUserVar('createAnother')) {
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('currentUrl', Request::url(null, null, 'people', 'all'));
             $templateMgr->assign('userCreated', true);
             $userForm =& new UserManagementForm();
             $userForm->initData();
             $userForm->display();
         } else {
             if ($source = Request::getUserVar('source')) {
                 Request::redirectUrl($source);
             } else {
                 Request::redirect(null, null, 'people', 'all');
             }
         }
     } else {
         parent::setupTemplate(true);
         $userForm->display();
     }
 }
Example #15
0
 function createFile($args)
 {
     list($plugin) = TranslatorHandler::validate();
     TranslatorHandler::setupTemplate();
     $locale = array_shift($args);
     if (!Locale::isLocaleValid($locale)) {
         Request::redirect(null, null, 'index');
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!TranslatorAction::isLocaleFile($locale, $filename)) {
         Request::redirect(null, null, 'edit', $locale);
     }
     import('file.FileManager');
     FileManager::copyFile(TranslatorAction::determineReferenceFilename($locale, $filename), $filename);
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
Example #16
0
 /**
  * Become a given role.
  */
 function become($args)
 {
     parent::validate(true);
     $press =& Request::getPress();
     $user =& Request::getUser();
     switch (array_shift($args)) {
         case 'author':
             $roleId = ROLE_ID_AUTHOR;
             $setting = 'allowRegAuthor';
             $deniedKey = 'user.noRoles.submitMonographRegClosed';
             break;
         case 'reviewer':
             $roleId = ROLE_ID_REVIEWER;
             $setting = 'allowRegReviewer';
             $deniedKey = 'user.noRoles.regReviewerClosed';
             break;
         default:
             Request::redirect(null, null, 'index');
     }
     if ($press->getSetting($setting)) {
         $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
         $userGroup =& $userGroupDao->getDefaultByRoleId($press->getId(), $roleId);
         $userGroupDao->assignUserToGroup($user->getId(), $userGroup->getId());
         Request::redirectUrl(Request::getUserVar('source'));
     } else {
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('message', $deniedKey);
         return $templateMgr->display('common/message.tpl');
     }
 }
Example #17
0
 function email($args)
 {
     $this->validate();
     $this->setupTemplate(true);
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $templateMgr =& TemplateManager::getManager();
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& Request::getUser();
     // See if this is the Director or Manager and an email template has been chosen
     $template = Request::getUserVar('template');
     if (!$conference || empty($template) || !Validation::isConferenceManager() && !Validation::isDirector() && !Validation::isTrackDirector()) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_CONFERENCE_MANAGER, ROLE_ID_DIRECTOR, ROLE_ID_TRACK_DIRECTOR);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     if ($conference) {
         $roles =& $roleDao->getRolesByUserId($user->getId(), $conference->getId());
         foreach ($roles as $role) {
             if (in_array($role->getRoleId(), $unlimitedEmailRoles)) {
                 $canSendUnlimitedEmails = true;
             }
         }
     }
     // Check when this user last sent an email, and if it's too
     // recent, make them wait.
     if (!$canSendUnlimitedEmails) {
         $dateLastEmail = $user->getDateLastEmail();
         if ($dateLastEmail && strtotime($dateLastEmail) + (int) Config::getVar('email', 'time_between_emails') > strtotime(Core::getCurrentDate())) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooSoon');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
     }
     $email = null;
     if ($paperId = Request::getUserVar('paperId')) {
         // This message is in reference to a paper.
         // Determine whether the current user has access
         // to the paper in some form, and if so, use an
         // PaperMailTemplate.
         $paperDao =& DAORegistry::getDAO('PaperDAO');
         $paper =& $paperDao->getPaper($paperId);
         $hasAccess = false;
         // First, conditions where access is OK.
         // 1. User is submitter
         if ($paper && $paper->getUserId() == $user->getId()) {
             $hasAccess = true;
         }
         // 2. User is director
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($paperId);
         while ($editAssignment =& $editAssignments->next()) {
             if ($editAssignment->getDirectorId() === $user->getId()) {
                 $hasAccess = true;
             }
         }
         if (Validation::isDirector()) {
             $hasAccess = true;
         }
         // 3. User is reviewer
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         foreach ($reviewAssignmentDao->getBySubmissionId($paperId) as $reviewAssignment) {
             if ($reviewAssignment->getReviewerId() === $user->getId()) {
                 $hasAccess = true;
             }
         }
         // Last, "deal-breakers" -- access is not allowed.
         if ($paper && $paper->getSchedConfId() !== $schedConf->getId()) {
             $hasAccess = false;
         }
         if ($hasAccess) {
             import('classes.mail.PaperMailTemplate');
             $email = new PaperMailTemplate($paperDao->getPaper($paperId));
         }
     }
     if ($email === null) {
         import('classes.mail.MailTemplate');
         $email = new MailTemplate();
     }
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $recipients = $email->getRecipients();
         $ccs = $email->getCcs();
         $bccs = $email->getBccs();
         // Make sure there aren't too many recipients (to
         // prevent use as a spam relay)
         $recipientCount = 0;
         if (is_array($recipients)) {
             $recipientCount += count($recipients);
         }
         if (is_array($ccs)) {
             $recipientCount += count($ccs);
         }
         if (is_array($bccs)) {
             $recipientCount += count($bccs);
         }
         if (!$canSendUnlimitedEmails && $recipientCount > (int) Config::getVar('email', 'max_recipients')) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooManyRecipients');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
         $email->send();
         $redirectUrl = Request::getUserVar('redirectUrl');
         if (empty($redirectUrl)) {
             $redirectUrl = Request::url(null, null, 'user');
         }
         $user->setDateLastEmail(Core::getCurrentDate());
         $userDao->updateObject($user);
         Request::redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm(Request::url(null, null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl'), 'paperId' => $paperId), null, array('disableSkipButton' => true));
     }
 }
 function saveLocaleFile($args)
 {
     $this->validate();
     $plugin =& PluginRegistry::getPlugin('generic', 'CustomLocalePlugin');
     $this->setupTemplate($plugin, true);
     $locale = array_shift($args);
     if (!Locale::isLocaleValid($locale)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'index');
         Request::redirect(null, null, null, $path);
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!CustomLocaleAction::isLocaleFile($locale, $filename)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'edit', $locale);
         Request::redirect(null, null, null, $path);
     }
     $journal =& Request::getJournal();
     $journalId = $journal->getId();
     $changes = Request::getUserVar('changes');
     $customFilesDir = Config::getVar('files', 'public_files_dir') . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale;
     $customFilePath = $customFilesDir . DIRECTORY_SEPARATOR . $filename;
     // Create empty custom locale file if it doesn't exist
     import('file.FileManager');
     import('file.EditableLocaleFile');
     if (!FileManager::fileExists($customFilePath)) {
         $numParentDirs = substr_count($customFilePath, DIRECTORY_SEPARATOR);
         $parentDirs = '';
         for ($i = 0; $i < $numParentDirs; $i++) {
             $parentDirs .= '..' . DIRECTORY_SEPARATOR;
         }
         $newFileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $newFileContents .= '<!DOCTYPE locale SYSTEM "' . $parentDirs . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'dtd' . DIRECTORY_SEPARATOR . 'locale.dtd' . '">' . "\n";
         $newFileContents .= '<locale name="' . $locale . '">' . "\n";
         $newFileContents .= '</locale>';
         FileManager::writeFile($customFilePath, $newFileContents);
     }
     $file = new EditableLocaleFile($locale, $customFilePath);
     while (!empty($changes)) {
         $key = array_shift($changes);
         $value = $this->correctCr(array_shift($changes));
         if (!empty($value)) {
             if (!$file->update($key, $value)) {
                 $file->insert($key, $value);
             }
         } else {
             $file->delete($key);
         }
     }
     $file->write();
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
 function email($args)
 {
     parent::validate();
     parent::setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     // See if this is the Editor or Manager and an email template has been chosen
     $template = Request::getUserVar('template');
     if (!$journal || empty($template) || !Validation::isJournalManager($journal->getJournalId()) && !Validation::isEditor($journal->getJournalId()) && !Validation::isSectionEditor($journal->getJournalId())) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_JOURNAL_MANAGER, ROLE_ID_EDITOR, ROLE_ID_SECTION_EDITOR);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     if ($journal) {
         $roles =& $roleDao->getRolesByUserId($user->getUserId(), $journal->getJournalId());
         foreach ($roles as $role) {
             if (in_array($role->getRoleId(), $unlimitedEmailRoles)) {
                 $canSendUnlimitedEmails = true;
             }
         }
     }
     // Check when this user last sent an email, and if it's too
     // recent, make them wait.
     if (!$canSendUnlimitedEmails) {
         $dateLastEmail = $user->getDateLastEmail();
         if ($dateLastEmail && strtotime($dateLastEmail) + (int) Config::getVar('email', 'time_between_emails') > strtotime(Core::getCurrentDate())) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooSoon');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
     }
     $email = null;
     if ($articleId = Request::getUserVar('articleId')) {
         // This message is in reference to an article.
         // Determine whether the current user has access
         // to the article in some form, and if so, use an
         // ArticleMailTemplate.
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $article =& $articleDao->getArticle($articleId);
         $hasAccess = false;
         // First, conditions where access is OK.
         // 1. User is submitter
         if ($article && $article->getUserId() == $user->getUserId()) {
             $hasAccess = true;
         }
         // 2. User is section editor of article or full editor
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($articleId);
         while ($editAssignment =& $editAssignments->next()) {
             if ($editAssignment->getEditorId() === $user->getUserId()) {
                 $hasAccess = true;
             }
         }
         if (Validation::isEditor($journal->getJournalId())) {
             $hasAccess = true;
         }
         // 3. User is reviewer
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         foreach ($reviewAssignmentDao->getReviewAssignmentsByArticleId($articleId) as $reviewAssignment) {
             if ($reviewAssignment->getReviewerId() === $user->getUserId()) {
                 $hasAccess = true;
             }
         }
         // 4. User is copyeditor
         $copyAssignmentDao =& DAORegistry::getDAO('CopyAssignmentDAO');
         $copyAssignment =& $copyAssignmentDao->getCopyAssignmentByArticleId($articleId);
         if ($copyAssignment && $copyAssignment->getCopyeditorId() === $user->getUserId()) {
             $hasAccess = true;
         }
         // 5. User is layout editor
         $layoutAssignmentDao =& DAORegistry::getDAO('LayoutAssignmentDAO');
         $layoutAssignment =& $layoutAssignmentDao->getLayoutAssignmentByArticleId($articleId);
         if ($layoutAssignment && $layoutAssignment->getEditorId() === $user->getUserId()) {
             $hasAccess = true;
         }
         // 6. User is proofreader
         $proofAssignmentDao =& DAORegistry::getDAO('ProofAssignmentDAO');
         $proofAssignment =& $proofAssignmentDao->getProofAssignmentByArticleId($articleId);
         if ($proofAssignment && $proofAssignment->getProofreaderId() === $user->getUserId()) {
             $hasAccess = true;
         }
         // Last, "deal-breakers" -- access is not allowed.
         if (!$article || $article && $article->getJournalId() !== $journal->getJournalId()) {
             $hasAccess = false;
         }
         if ($hasAccess) {
             import('mail.ArticleMailTemplate');
             $email =& new ArticleMailTemplate($articleDao->getArticle($articleId, $template));
         }
     }
     if ($email === null) {
         import('mail.MailTemplate');
         $email =& new MailTemplate($template);
     }
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $recipients = $email->getRecipients();
         $ccs = $email->getCcs();
         $bccs = $email->getBccs();
         // Make sure there aren't too many recipients (to
         // prevent use as a spam relay)
         $recipientCount = 0;
         if (is_array($recipients)) {
             $recipientCount += count($recipients);
         }
         if (is_array($ccs)) {
             $recipientCount += count($ccs);
         }
         if (is_array($bccs)) {
             $recipientCount += count($bccs);
         }
         if (!$canSendUnlimitedEmails && $recipientCount > (int) Config::getVar('email', 'max_recipients')) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooManyRecipients');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
         $email->send();
         $redirectUrl = Request::getUserVar('redirectUrl');
         if (empty($redirectUrl)) {
             $redirectUrl = Request::url(null, 'user');
         }
         $user->setDateLastEmail(Core::getCurrentDate());
         $userDao->updateUser($user);
         Request::redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm(Request::url(null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl'), 'articleId' => $articleId), null, array('disableSkipButton' => true, 'articleId' => $articleId));
     }
 }
Example #20
0
 /**
  * Save changes to a user profile.
  */
 function updateUser()
 {
     $this->validate();
     $this->setupTemplate(true);
     $conference =& Request::getConference();
     $userId = Request::getUserVar('userId');
     if (!empty($userId) && !Validation::canAdminister($conference->getId(), $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, null, 'people', 'all'));
         $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
         return $templateMgr->display('common/error.tpl');
     }
     import('classes.manager.form.UserManagementForm');
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $userForm = new UserManagementForm($userId);
     } else {
         $userForm =& new UserManagementForm($userId);
     }
     $userForm->readInputData();
     if ($userForm->validate()) {
         $userForm->execute();
         if (Request::getUserVar('createAnother')) {
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
             $templateMgr->assign('userCreated', true);
             unset($userForm);
             if (checkPhpVersion('5.0.0')) {
                 // WARNING: This form needs $this in constructor
                 $userForm = new UserManagementForm();
             } else {
                 $userForm =& new UserManagementForm();
             }
             $userForm->initData();
             $userForm->display();
         } else {
             if ($source = Request::getUserVar('source')) {
                 Request::redirectUrl($source);
             } else {
                 Request::redirect(null, null, null, 'people', 'all');
             }
         }
     } else {
         $userForm->display();
     }
 }
 function createFile($args)
 {
     $this->validate();
     $plugin =& $this->plugin;
     $this->setupTemplate();
     $locale = array_shift($args);
     if (!AppLocale::isLocaleValid($locale)) {
         Request::redirect(null, null, 'index');
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!TranslatorAction::isLocaleFile($locale, $filename)) {
         Request::redirect(null, null, 'edit', $locale);
     }
     import('lib.pkp.classes.file.FileManager');
     FileManager::copyFile(TranslatorAction::determineReferenceFilename($locale, $filename), $filename);
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
 function createFile($args)
 {
     $this->validate();
     $plugin =& $this->plugin;
     $this->setupTemplate();
     $locale = array_shift($args);
     if (!AppLocale::isLocaleValid($locale)) {
         Request::redirect(null, null, 'index');
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!TranslatorAction::isLocaleFile($locale, $filename)) {
         Request::redirect(null, null, 'edit', $locale);
     }
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     $fileManager->copyFile(TranslatorAction::determineReferenceFilename($locale, $filename), $filename);
     $localeKeys = LocaleFile::load($filename);
     import('lib.pkp.classes.file.EditableLocaleFile');
     $file = new EditableLocaleFile($locale, $filename);
     // remove default translations from keys
     foreach (array_keys($localeKeys) as $key) {
         $file->update($key, '');
     }
     $file->write();
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
Example #23
0
 /**
  * Become a given role.
  */
 function become($args)
 {
     $this->addCheck(new HandlerValidatorConference($this));
     $this->addCheck(new HandlerValidatorSchedConf($this));
     $this->validate();
     $schedConf =& Request::getSchedConf();
     import('schedConf.SchedConfAction');
     $user =& Request::getUser();
     if (!$user) {
         Request::redirect(null, null, 'index');
     }
     $schedConfAction = new SchedConfAction();
     switch (array_shift($args)) {
         case 'author':
             $roleId = ROLE_ID_AUTHOR;
             $func = 'allowRegAuthor';
             $deniedKey = 'author.submit.authorRegistrationClosed';
             break;
         case 'reviewer':
             $roleId = ROLE_ID_REVIEWER;
             $func = 'allowRegReviewer';
             $deniedKey = 'user.noRoles.regReviewerClosed';
             break;
         default:
             Request::redirect(null, null, 'index');
     }
     if ($schedConfAction->{$func}($schedConf)) {
         $role = new Role();
         $role->setSchedConfId($schedConf->getId());
         $role->setConferenceId($schedConf->getConferenceId());
         $role->setRoleId($roleId);
         $role->setUserId($user->getId());
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $roleDao->insertRole($role);
         Request::redirectUrl(Request::getUserVar('source'));
     } else {
         $this->setupTemplate();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('message', $deniedKey);
         return $templateMgr->display('common/message.tpl');
     }
 }
Example #24
0
 /**
  * Redirect to the specified page within OJS. Shorthand for a common call to Request::redirect(Request::url(...)).
  * @param $journalPath string The path of the journal to redirect to.
  * @param $page string The name of the op to redirect to.
  * @param $op string optional The name of the op to redirect to.
  * @param $path mixed string or array containing path info for redirect.
  * @param $params array Map of name => value pairs for additional parameters
  * @param $anchor string Name of desired anchor on the target page
  */
 function redirect($journalPath = null, $page = null, $op = null, $path = null, $params = null, $anchor = null)
 {
     Request::redirectUrl(Request::url($journalPath, $page, $op, $path, $params, $anchor));
 }