Ejemplo n.º 1
0
 /**
  * Constructor.
  * @param $template string
  * @param $user PKPUser
  */
 function PKPProfileForm($user)
 {
     parent::PKPUserForm('user/profile.tpl');
     $this->_user = $user;
     assert($user);
     // Validation checks for this form
     $this->_addBaseUserFieldChecks();
     $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array($user->getId(), true), true));
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  */
 function PKPRegistrationForm($site, $existingUser = false)
 {
     parent::PKPUserForm('user/register.tpl');
     $this->implicitAuth = Config::getVar('security', 'implicit_auth');
     if ($this->implicitAuth) {
         // If implicit auth - it is always an existing user
         $this->existingUser = true;
     } else {
         $this->existingUser = $existingUser;
         $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha');
         // Validation checks for this form
         $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired'));
         $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired'));
         if ($this->existingUser) {
             // Existing user -- check login
             $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.login.loginError', create_function('$username,$form', 'return Validation::checkCredentials($form->getData(\'username\'), $form->getData(\'password\'));'), array(&$this)));
         } else {
             // New user -- check required profile fields
             $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true));
             $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric'));
             $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength()));
             $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this)));
             // Add base user form checks (first name, last name, ...)
             $this->_addBaseUserFieldChecks();
             // Email checks
             $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired'));
             $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array(&$this)));
             $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true));
             if ($this->captchaEnabled) {
                 $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha'));
             }
             $authDao = DAORegistry::getDAO('AuthSourceDAO');
             $this->defaultAuth =& $authDao->getDefaultPlugin();
             if (isset($this->defaultAuth)) {
                 $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth)));
             }
         }
     }
 }