コード例 #1
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->message)) {
         throw new UserInputException('message');
     }
     if (StringUtil::length($this->message) > WCF::getUser()->getPermission('user.contest.maxSolutionLength')) {
         throw new UserInputException('message', 'tooLong');
     }
 }
コード例 #2
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (count($this->users) == 0) {
         if (empty($this->usernames)) {
             throw new UserInputException('usernames');
         }
         $this->validateUsers();
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (count($this->invitedMails) === 0) {
         if (empty($this->emails)) {
             throw new UserInputException('emails');
         }
         $this->validateEmails();
     }
 }
コード例 #4
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->ownerID != 0) {
         $this->availableGroups = ContestUtil::readAvailableGroups();
         // validate group ids
         if (!array_key_exists($this->ownerID, $this->availableGroups)) {
             throw new UserInputException('ownerID');
         }
     } else {
         if ($this->userid == 0) {
             throw new UserInputException('ownerID');
         }
     }
     if (!array_key_exists($this->state, $this->getStates())) {
         throw new UserInputException('state');
     }
 }
コード例 #5
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // password
     if (empty($this->password)) {
         throw new UserInputException('password');
     }
     if (!WCF::getUser()->checkPassword($this->password)) {
         throw new UserInputException('password', 'false');
     }
     // username
     if ($this->canChangeUsername && $this->username != WCF::getUser()->username) {
         if (StringUtil::toLowerCase($this->username) != StringUtil::toLowerCase(WCF::getUser()->username)) {
             // check for forbidden chars (e.g. the ",")
             if (!UserRegistrationUtil::isValidUsername($this->username)) {
                 throw new UserInputException('username', 'notValid');
             }
             // Check if username exists already.
             if (!UserUtil::isAvailableUsername($this->username)) {
                 throw new UserInputException('username', 'notUnique');
             }
         }
     }
     // password
     if (!empty($this->newPassword) || !empty($this->confirmNewPassword)) {
         if (empty($this->newPassword)) {
             throw new UserInputException('newPassword');
         }
         if (empty($this->confirmNewPassword)) {
             throw new UserInputException('confirmNewPassword');
         }
         if (!UserRegistrationUtil::isSecurePassword($this->newPassword)) {
             throw new UserInputException('newPassword', 'notSecure');
         }
         if ($this->newPassword != $this->confirmNewPassword) {
             throw new UserInputException('confirmNewPassword', 'notEqual');
         }
     }
     // email
     if (WCF::getUser()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) {
         if (empty($this->email)) {
             throw new UserInputException('email');
         }
         // check if only letter case is changed
         if (StringUtil::toLowerCase($this->email) != StringUtil::toLowerCase(WCF::getUser()->email)) {
             // check for valid email (one @ etc.)
             if (!UserRegistrationUtil::isValidEmail($this->email)) {
                 throw new UserInputException('email', 'notValid');
             }
             // Check if email exists already.
             if (!UserUtil::isAvailableEmail($this->email)) {
                 throw new UserInputException('email', 'notUnique');
             }
         }
         // check confirm input
         if (StringUtil::toLowerCase($this->email) != StringUtil::toLowerCase($this->confirmEmail)) {
             throw new UserInputException('confirmEmail', 'notEqual');
         }
     }
 }