Пример #1
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     // validate static user options
     try {
         $this->validateUsername($this->username);
     } catch (UserInputException $e) {
         $this->errorType[$e->getField()] = $e->getType();
     }
     try {
         $this->validateEmail($this->email, $this->confirmEmail);
     } catch (UserInputException $e) {
         $this->errorType[$e->getField()] = $e->getType();
     }
     try {
         $this->validatePassword($this->password, $this->confirmPassword);
     } catch (UserInputException $e) {
         $this->errorType[$e->getField()] = $e->getType();
     }
     // validate user groups
     if (count($this->groupIDs) > 0) {
         require_once WCF_DIR . 'lib/data/user/group/Group.class.php';
         $sql = "SELECT\tgroupID\n\t\t\t\tFROM\twcf" . WCF_N . "_group\n\t\t\t\tWHERE\tgroupID IN (" . implode(',', $this->groupIDs) . ")\n\t\t\t\t\tAND groupType NOT IN (" . Group::GUESTS . ", " . Group::EVERYONE . ", " . Group::USERS . ")";
         $result = WCF::getDB()->sendQuery($sql);
         $this->groupIDs = array();
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (Group::isAccessibleGroup($row['groupID'])) {
                 $this->groupIDs[] = $row['groupID'];
             }
         }
     }
     // validate user language
     require_once WCF_DIR . 'lib/system/language/Language.class.php';
     if (!Language::getLanguage($this->languageID)) {
         // use default language
         $this->languageID = Language::getDefaultLanguageID();
     }
     // validate visible languages
     foreach ($this->visibleLanguages as $key => $visibleLanguage) {
         if (!($language = Language::getLanguage($visibleLanguage)) || !$language['hasContent']) {
             unset($this->visibleLanguages[$key]);
         }
     }
     if (!count($this->visibleLanguages) && ($language = Language::getLanguage($this->languageID)) && $language['hasContent']) {
         $this->visibleLanguages[] = $this->languageID;
     }
     // validate dynamic options
     parent::validate();
 }