/** * Validate user registration information and register new user. */ function registerUser($args, &$request) { $this->validate($request); import('classes.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; Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason); if ($reason !== null) { $this->setupTemplate($request, 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($request, true); $regForm->display(); } }
/** * Validate user registration information and register new user. * @param $args array * @param $request PKPRequest */ function registerUser($args, &$request) { $this->validate($request); $this->setupTemplate($request, true); 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(); $reason = null; if (Config::getVar('security', 'implicit_auth')) { Validation::login('', '', $reason); } else { Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason); } if (!Validation::isLoggedIn()) { if (Config::getVar('email', 'require_validation')) { // Inform the user that they need to deal with the // registration email. $this->setupTemplate($request, true); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageTitle', 'user.register.emailValidation'); $templateMgr->assign('errorMsg', 'user.register.emailValidationDescription'); $templateMgr->assign('backLink', $request->url(null, 'login')); $templateMgr->assign('backLinkLabel', 'user.login'); return $templateMgr->display('common/error.tpl'); } } if ($reason !== null) { $this->setupTemplate($request, 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(); } }
/** * Validate user registration information and register new user. * @param $args array * @param $request PKPRequest */ function registerUser($args, $request) { $this->validate($request); $this->setupTemplate($request); import('lib.pkp.classes.user.form.RegistrationForm'); $regForm = new RegistrationForm($request->getSite()); $regForm->readInputData(); if (!$regForm->validate()) { return $regForm->display($request); } $regForm->execute($request); // Inform the user of the email validation process. This must be run // before the disabled account check to ensure new users don't see the // disabled account message. if (Config::getVar('email', 'require_validation')) { $this->setupTemplate($request); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('requireValidation', true); $templateMgr->assign('pageTitle', 'user.login.registrationPendingValidation'); $templateMgr->assign('messageTranslated', __('user.login.accountNotValidated', array('email' => $regForm->getData('email')))); return $templateMgr->fetch('frontend/pages/message.tpl'); } $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($request); $templateMgr = TemplateManager::getManager($request); $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->fetch('frontend/pages/error.tpl'); } if ($source = $request->getUserVar('source')) { return $request->redirectUrlJson($source); } else { $request->redirect(null, 'user', 'registrationComplete'); } }
/** * 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'); } 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'); } // Opatan Inc. if (Request::getUserVar('isReviewer') == 1) { $reviewerId = Request::getUserVar('reviewerId'); $source = Request::getUserVar('source'); RegistrationHandler::enrollAsReviewer($reviewerId, $source); } else { if ($source = Request::getUserVar('source')) { Request::redirectUrl($source); } else { Request::redirect(null, 'login'); } } } else { parent::setupTemplate(true); $regForm->display(); } }
/** * Validate user registration information and register new user. * @param $args array * @param $request PKPRequest */ function registerUser($args, $request) { $this->validate($request); $this->setupTemplate($request); import('lib.pkp.classes.user.form.RegistrationForm'); $regForm = new RegistrationForm($request->getSite()); $regForm->readInputData(); if (!$regForm->validate()) { return new JSONMessage(true, $regForm->fetch($request)); } $regForm->execute($request); if (Config::getVar('email', 'require_validation')) { // Send them home; they need to deal with the // registration email. return $request->redirectUrlJson($request->url(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($request); $templateMgr = TemplateManager::getManager($request); $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->fetchJson('frontend/pages/error.tpl'); } if ($source = $request->getUserVar('source')) { return $request->redirectUrlJson($source); } return $request->redirectUrlJson($request->getRouter()->getHomeUrl($request)); }
/** * Save user's new password. */ function savePassword() { $this->validate(); $this->setupTemplate(); import('classes.user.form.LoginChangePasswordForm'); $passwordForm = new LoginChangePasswordForm(); $passwordForm->readInputData(); if ($passwordForm->validate()) { if ($passwordForm->execute()) { $user = Validation::login($passwordForm->getData('username'), $passwordForm->getData('password'), $reason); } PKPRequest::redirect(null, 'user'); } else { $passwordForm->display(); } }
/** * Save registration. */ function execute() { $schedConf =& Request::getSchedConf(); $user =& Request::getUser(); if (!$user) { // New user $user = new User(); $user->setUsername($this->getData('username')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setInitials($this->getData('initials')); $user->setLastName($this->getData('lastName')); $user->setAffiliation($this->getData('affiliation')); $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setBiography($this->getData('biography'), null); // Localized $user->setInterests($this->getData('interests'), null); // Localized $user->setDateRegistered(Core::getCurrentDate()); $user->setCountry($this->getData('country')); $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password'))); $userDao =& DAORegistry::getDAO('UserDAO'); $userId = $userDao->insertUser($user); if (!$userId) { return REGISTRATION_FAILED; } $conference =& Request::getConference(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $role = new Role(); $role->setRoleId(ROLE_ID_READER); $role->setSchedConfId($schedConf->getId()); $role->setConferenceId($conference->getId()); $role->setUserId($user->getId()); $roleDao->insertRole($role); $sessionManager =& SessionManager::getManager(); $session =& $sessionManager->getUserSession(); $session->setSessionVar('username', $user->getUsername()); // Make sure subsequent requests to Request::getUser work Validation::login($this->getData('username'), $this->getData('password'), $reason); import('user.form.CreateAccountForm'); CreateAccountForm::sendConfirmationEmail($user, $this->getData('password'), true); } // Get the registration type $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO'); $registrationType =& $registrationTypeDao->getRegistrationType($this->getData('registrationTypeId')); if (!$registrationType || $registrationType->getSchedConfId() != $schedConf->getId()) { Request::redirect('index'); } import('payment.ocs.OCSPaymentManager'); $paymentManager =& OCSPaymentManager::getManager(); if (!$paymentManager->isConfigured()) { return REGISTRATION_NO_PAYMENT; } import('registration.Registration'); $registration = new Registration(); $registration->setSchedConfId($schedConf->getId()); $registration->setUserId($user->getId()); $registration->setTypeId($this->getData('registrationTypeId')); $registration->setSpecialRequests($this->getData('specialRequests') ? $this->getData('specialRequests') : null); $registration->setDateRegistered(time()); $registrationDao =& DAORegistry::getDAO('RegistrationDAO'); $registrationId = $registrationDao->insertRegistration($registration); $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO'); $registrationOptions =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId()); $registrationOptionIds = (array) $this->getData('registrationOptionId'); $cost = $registrationType->getCost(); $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($this->getData('registrationTypeId')); while ($registrationOption =& $registrationOptions->next()) { if (in_array($registrationOption->getOptionId(), $registrationOptionIds) && strtotime($registrationOption->getOpeningDate()) < time() && strtotime($registrationOption->getClosingDate()) > time() && $registrationOption->getPublic()) { $registrationOptionDao->insertRegistrationOptionAssoc($registrationId, $registrationOption->getOptionId()); $cost += $registrationOptionCosts[$registrationOption->getOptionId()]; } unset($registrationOption); } $queuedPayment =& $paymentManager->createQueuedPayment($schedConf->getConferenceId(), $schedConf->getId(), QUEUED_PAYMENT_TYPE_REGISTRATION, $user->getId(), $registrationId, $cost, $registrationType->getCurrencyCodeAlpha()); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment, time() + 60 * 60 * 24 * 30); // 30 days to complete if ($cost == 0) { $paymentManager->fulfillQueuedPayment($queuedPaymentId, $queuedPayment); return REGISTRATION_FREE; } else { $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); } return REGISTRATION_SUCCESSFUL; }
/** * Save user's new password. */ function savePassword($args, &$request) { $this->validate(); $this->setupTemplate($request); $site = $request->getSite(); $oneStepReset = $site->getSetting('oneStepReset') ? true : false; $confirmHash = null; if ($oneStepReset) { $confirmHash = $request->getUserVar('confirmHash'); } import('classes.user.form.LoginChangePasswordForm'); $passwordForm = new LoginChangePasswordForm($confirmHash); $passwordForm->readInputData(); if ($passwordForm->validate()) { if ($passwordForm->execute()) { $user = Validation::login($passwordForm->getData('username'), $passwordForm->getData('password'), $reason); } $request->redirect(null, 'user'); } else { $passwordForm->display(); } }
/** * Save user's new password. */ function savePassword($args, $request) { $this->setupTemplate($request); import('lib.pkp.classes.user.form.LoginChangePasswordForm'); $passwordForm = new LoginChangePasswordForm($request->getSite()); $passwordForm->readInputData(); if ($passwordForm->validate()) { if ($passwordForm->execute()) { $user = Validation::login($passwordForm->getData('username'), $passwordForm->getData('password'), $reason); } $this->sendHome($request); } else { $passwordForm->display($request); } }
/** * Validate user information and create new user. */ function createAccount() { $this->validate(); $this->setupTemplate(true); import('classes.user.form.CreateAccountForm'); if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor $regForm = new CreateAccountForm(); } else { $regForm =& new CreateAccountForm(); } $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'); } Validation::login($regForm->getData('username'), $regForm->getData('password'), $reason); if ($reason !== null) { $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, 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, null, 'login'); } } else { $regForm->display(); } }
/** * Save registration. */ function execute() { $schedConf =& Request::getSchedConf(); $user =& Request::getUser(); $registrationOptionIds = (array) $this->getData('registrationOptionId'); if (!$user) { // New user $user = new User(); $user->setUsername($this->getData('username')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setInitials($this->getData('initials')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setBillingAddress($this->getData('billingAddress')); $user->setBiography($this->getData('biography'), null); // Localized $user->setDateRegistered(Core::getCurrentDate()); $user->setCountry($this->getData('country')); $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password'))); $userDao =& DAORegistry::getDAO('UserDAO'); $userId = $userDao->insertUser($user); if (!$userId) { return REGISTRATION_FAILED; } $conference =& Request::getConference(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $role = new Role(); $role->setRoleId(ROLE_ID_READER); $role->setSchedConfId($schedConf->getId()); $role->setConferenceId($conference->getId()); $role->setUserId($user->getId()); $roleDao->insertRole($role); $sessionManager =& SessionManager::getManager(); $session =& $sessionManager->getUserSession(); $session->setSessionVar('username', $user->getUsername()); // Make sure subsequent requests to Request::getUser work Validation::login($this->getData('username'), $this->getData('password'), $reason); import('classes.user.form.CreateAccountForm'); CreateAccountForm::sendConfirmationEmail($user, $this->getData('password'), true); } // Get the registration type $registrationDao =& DAORegistry::getDAO('RegistrationDAO'); $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO'); $registrationType =& $registrationTypeDao->getRegistrationType($this->getData('registrationTypeId')); if (!$registrationType || $registrationType->getSchedConfId() != $schedConf->getId()) { Request::redirect('index'); } import('classes.payment.ocs.OCSPaymentManager'); $paymentManager =& OCSPaymentManager::getManager(); if (!$paymentManager->isConfigured()) { return REGISTRATION_NO_PAYMENT; } if ($this->_registration) { // An existing registration was already in place. Compare and notify someone. $oldRegistration =& $this->_registration; $oldRegistrationType =& $registrationTypeDao->getRegistrationType($oldRegistration->getTypeId()); unset($this->_registration); import('mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTRATION_CHANGE'); $mail->setFrom($schedConf->getSetting('registrationEmail'), $schedConf->getSetting('registrationName')); $mail->addRecipient($schedConf->getSetting('registrationEmail'), $schedConf->getSetting('registrationName')); $optionsDiffer = ''; $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO'); $registrationOptionIterator =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId()); $oldRegistrationOptionIds = $registrationOptionDao->getRegistrationOptions($oldRegistration->getRegistrationId()); while ($registrationOption =& $registrationOptionIterator->next()) { $optionId = $registrationOption->getOptionId(); $previouslyChosen = in_array($optionId, $oldRegistrationOptionIds); $newlyChosen = in_array($optionId, $registrationOptionIds); if ($previouslyChosen && !$newlyChosen) { $optionsDiffer .= Locale::translate('schedConf.registrationOptions.removed', array('option' => $registrationOption->getRegistrationOptionName())) . "\n"; } elseif (!$previouslyChosen && $newlyChosen) { $optionsDiffer .= Locale::translate('schedConf.registrationOptions.added', array('option' => $registrationOption->getRegistrationOptionName())) . "\n"; } unset($registrationOption); } $mail->assignParams(array('managerName' => $schedConf->getSetting('registrationName'), 'registrationId' => $oldRegistration->getRegistrationId(), 'registrantName' => $user->getFullName(), 'oldRegistrationType' => $oldRegistrationType->getSummaryString(), 'newRegistrationType' => $registrationType->getSummaryString(), 'differingOptions' => $optionsDiffer, 'username' => $user->getUsername(), 'registrationContactSignature' => $schedConf->getSetting('registrationName'))); $mail->send(); $registrationDao->deleteRegistrationById($oldRegistration->getRegistrationId()); } import('classes.registration.Registration'); $registration = new Registration(); $registration->setSchedConfId($schedConf->getId()); $registration->setUserId($user->getId()); $registration->setTypeId($this->getData('registrationTypeId')); $registration->setSpecialRequests($this->getData('specialRequests') ? $this->getData('specialRequests') : null); $registration->setDateRegistered(time()); $registrationId = $registrationDao->insertRegistration($registration); $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO'); $registrationOptions =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId()); $cost = $registrationType->getCost(); $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($this->getData('registrationTypeId')); while ($registrationOption =& $registrationOptions->next()) { if (in_array($registrationOption->getOptionId(), $registrationOptionIds) && strtotime($registrationOption->getOpeningDate()) < time() && strtotime($registrationOption->getClosingDate()) > time() && $registrationOption->getPublic()) { $registrationOptionDao->insertRegistrationOptionAssoc($registrationId, $registrationOption->getOptionId()); $cost += $registrationOptionCosts[$registrationOption->getOptionId()]; } unset($registrationOption); } $queuedPayment =& $paymentManager->createQueuedPayment($schedConf->getConferenceId(), $schedConf->getId(), QUEUED_PAYMENT_TYPE_REGISTRATION, $user->getId(), $registrationId, $cost, $registrationType->getCurrencyCodeAlpha()); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment, time() + 60 * 60 * 24 * 30); // 30 days to complete if ($cost == 0) { $paymentManager->fulfillQueuedPayment($queuedPaymentId, $queuedPayment); return REGISTRATION_FREE; } else { $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); } $this->_registration =& $registration; $this->_queuedPayment =& $queuedPayment; // Add reviewing interests to interests table $interestDao =& DAORegistry::getDAO('InterestDAO'); $interests = Request::getUserVar('interestsKeywords'); $interests = array_map('urldecode', $interests); // The interests are coming in encoded -- Decode them for DB storage $interestTextOnly = Request::getUserVar('interests'); if (!empty($interestsTextOnly)) { // If JS is disabled, this will be the input to read $interestsTextOnly = explode(",", $interestTextOnly); } else { $interestsTextOnly = null; } if ($interestsTextOnly && !isset($interests)) { $interests = $interestsTextOnly; } elseif (isset($interests) && !is_array($interests)) { $interests = array($interests); } $interestDao->insertInterests($interests, $user->getId(), true); return REGISTRATION_SUCCESSFUL; }
/** * 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(); } }