예제 #1
0
 public function validate()
 {
     parent::validate();
     // categories
     if (empty($this->categoryIDs)) {
         throw new UserInputException('categoryIDs');
     }
     foreach ($this->categoryIDs as $categoryID) {
         $category = CategoryHandler::getInstance()->getCategory($categoryID);
         if ($category === null) {
             throw new UserInputException('categoryIDs');
         }
         $category = new NewsCategory($category);
         if (!$category->isAccessible() || !$category->getPermission('canAddNews')) {
             throw new UserInputException('categoryIDs');
         }
     }
     if (MODULE_POLL && WCF::getSession()->getPermission('user.cms.news.canStartPoll')) {
         PollManager::getInstance()->validate();
     }
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate upload
     $this->validateFileUpload();
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate the news category ids
     if (empty($this->categoryIDs)) {
         throw new UserInputException('categoryIDs', 'empty');
     }
     foreach ($this->categoryIDs as $categoryID) {
         $category = CategoryHandler::getInstance()->getCategory($categoryID);
         if ($category === null) {
             throw new UserInputException('categoryIDs');
         }
         // get category
         $category = new NewsCategory($category);
         // check, if the current user can use this category
         if (!$category->canUseCategory()) {
             throw new UserInputException('categoryIDs');
         }
     }
     // validate publication date
     if ($this->enableDelayedPublication) {
         $publicationDateTimestamp = @strtotime($this->publicationDate);
         if ($publicationDateTimestamp === false || $publicationDateTimestamp > 2147483647) {
             throw new UserInputException('publicationDate', 'invalid');
         }
     }
     // validate archiving date
     if ($this->enableAutomaticArchiving) {
         $archivingDateTimestamp = @strtotime($this->archivingDate);
         if ($archivingDateTimestamp === false || $archivingDateTimestamp <= TIME_NOW) {
             throw new UserInputException('archivingDate', 'invalid');
         }
         // date exceeds max integer
         if ($archivingDateTimestamp > 2147483647) {
             throw new UserInputException('archivingDate', 'invalid');
         }
         // archive news before publishing it at all
         if ($this->enableDelayedPublication && $publicationDateTimestamp >= $archivingDateTimestamp) {
             throw new UserInputException('archivingDate', 'beforePublication');
         }
     }
     // validate tags
     $this->validateTags();
     // validate source
     if (NEWS_ENTRY_ENABLE_SOURCES) {
         $this->validateSources();
     }
     // validate news picture
     if (NEWS_ENABLE_NEWSPICTURE) {
         if (NEWS_ENABLE_NEWSPICTURE_REQUIRED && !$this->pictureID) {
             throw new UserInputException('pictureID', 'empty');
         }
         if ($this->pictureID && !$this->picture->pictureID) {
             throw new UserInputException('pictureID', 'notValid');
         }
     }
     // validate poll
     if ($this->canCreatePoll()) {
         PollManager::getInstance()->validate();
     }
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     if ($this->isFirstMessage && $this->conversation->isDraft) {
         parent::validate();
     } else {
         MessageForm::validate();
     }
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     $this->validateFileSubject();
     // validate category ids
     if (empty($this->categoryIDs)) {
         throw new UserInputException('categoryIDs');
     }
     foreach ($this->categoryIDs as $categoryID) {
         $category = CategoryHandler::getInstance()->getCategory($categoryID);
         if ($category === null) {
             throw new UserInputException('categoryIDs');
         }
         $category = new FilebaseCategory($category);
         if (!$category->isAccessible() || !$category->getPermission('canUseCategory')) {
             throw new UserInputException('categoryIDs');
         }
     }
     // validate teaser
     if (empty($this->teaser)) {
         throw new UserInputException('teaser');
     }
     if (mb_strlen($this->teaser) > FILEBASE_MAX_TEASER_LENGTH) {
         throw new UserInputException('teaser', 'tooLong');
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($this->teaser);
         if ($result) {
             WCF::getTPL()->assign('censoredWords', $result);
             throw new UserInputException('teaser', 'censoredWordsFound');
         }
     }
     // validate upload
     $this->validateFileUpload();
     // validate website
     if (!empty($this->website)) {
         if (!preg_match('~^(https?|ftps?)://~', $this->website)) {
             $this->website = 'http://' . $this->website;
         }
         if (filter_var($this->website, FILTER_VALIDATE_URL) === false) {
             throw new UserInputException('website', 'invalid');
         }
     }
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     if (empty($this->participants) && empty($this->invisibleParticipants) && !$this->draft) {
         throw new UserInputException('participants');
     }
     // check, if user is allowed to set invisible participants
     if (!WCF::getSession()->getPermission('user.conversation.canAddInvisibleParticipants') && !empty($this->invisibleParticipants)) {
         throw new UserInputException('participants', 'invisibleParticipantsNoPermission');
     }
     // check, if user is allowed to set participantCanInvite
     if (!WCF::getSession()->getPermission('user.conversation.canSetCanInvite') && $this->participantCanInvite) {
         throw new UserInputException('participantCanInvite', 'participantCanInviteNoPermission');
     }
     $this->participantIDs = Conversation::validateParticipants($this->participants);
     $this->invisibleParticipantIDs = Conversation::validateParticipants($this->invisibleParticipants, 'invisibleParticipants');
     // remove duplicates
     $intersection = array_intersect($this->participantIDs, $this->invisibleParticipantIDs);
     if (!empty($intersection)) {
         $this->invisibleParticipantIDs = array_diff($this->invisibleParticipantIDs, $intersection);
     }
     if (empty($this->participantIDs) && empty($this->invisibleParticipantIDs) && !$this->draft) {
         throw new UserInputException('participants');
     }
     // check number of participants
     if (count($this->participantIDs) + count($this->invisibleParticipantIDs) > WCF::getSession()->getPermission('user.conversation.maxParticipants')) {
         throw new UserInputException('participants', 'tooManyParticipants');
     }
     parent::validate();
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate the news category ids
     if (empty($this->categoryIDs)) {
         throw new UserInputException('categoryIDs', 'empty');
     }
     foreach ($this->categoryIDs as $categoryID) {
         $category = CategoryHandler::getInstance()->getCategory($categoryID);
         if ($category === null) {
             throw new UserInputException('categoryIDs');
         }
         // get category
         $category = new NewsCategory($category);
         // check, if the current user can use this category
         if (!$category->canUseCategory()) {
             throw new UserInputException('categoryIDs');
         }
     }
     // validate publication date
     if ($this->enableDelayedPublication) {
         $publicationDateTimestamp = @strtotime($this->publicationDate);
         if ($publicationDateTimestamp === false || $publicationDateTimestamp > 2147483647) {
             throw new UserInputException('publicationDate', 'invalid');
         }
     }
     // validate poll
     if ($this->canCreatePoll()) {
         PollManager::getInstance()->validate();
     }
 }