validate() public method

Checks if context allows user registration.
public validate ( $request )
$request PKPRequest
 /**
  * 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 #2
0
 /**
  * Opatan Inc. :
  * Activate reviewer if the activation url has been clicked.
  */
 function activateReviewer($args)
 {
     $reviewerId = (int) $args[0];
     $reviewerDao =& DAORegistry::getDAO('ReviewerDAO');
     $reviewer =& $reviewerDao->getReviewer($reviewerId);
     // mark this reviewer as assigned
     $reviewer->setStatus(2);
     $reviewerDao->updateReviewerStatus($reviewer);
     // enroll as reviewer
     RegistrationHandler::validate();
     import('user.form.RegistrationForm');
     parent::setupTemplate(true);
     $regForm =& new RegistrationForm();
     $regForm->initData();
     $regForm->setData('isReviewer', 1);
     $regForm->setData('reviewerId', $reviewer->getReviewerId());
     $regForm->setData('firstName', $reviewer->getFirstName(null));
     $regForm->setData('lastName', $reviewer->getLastName(null));
     $regForm->setData('username', $reviewer->getEmail());
     if ($reviewer->getMiddleName(null)) {
         $regForm->setData('middleName', $reviewer->getMiddleName(null));
     }
     if ($reviewer->getAffiliation(null)) {
         $regForm->setData('affiliation', $reviewer->getAffiliation(null));
     }
     $regForm->display();
 }