コード例 #1
0
 /**
  * @see Form::validate()
  */
 function validate(&$request)
 {
     // Is this a revision?
     $revisedFileId = $this->getRevisedFileId();
     if ($this->getData('revisionOnly')) {
         assert($revisedFileId > 0);
     }
     if (!$revisedFileId) {
         // Add an additional check for the genre to the form.
         $router =& $request->getRouter();
         $context =& $router->getContext($request);
         $this->addCheck(new FormValidatorCustom($this, 'genreId', FORM_VALIDATOR_REQUIRED_VALUE, 'submission.upload.noFileType', create_function('$genreId,$genreDao,$context', 'return is_a($genreDao->getById($genreId, $context->getId()), "Genre");'), array(DAORegistry::getDAO('GenreDAO'), $context)));
     }
     return parent::validate();
 }
コード例 #2
0
 /**
  * @copydoc Form::validate()
  */
 function validate($request)
 {
     // Is this a revision?
     $revisedFileId = $this->getRevisedFileId();
     if ($this->getData('revisionOnly')) {
         assert($revisedFileId > 0);
     }
     // Retrieve the request context.
     $router = $request->getRouter();
     $context = $router->getContext($request);
     if ($this->getData('fileStage') != SUBMISSION_FILE_REVIEW_ATTACHMENT and !$revisedFileId) {
         // Add an additional check for the genre to the form.
         $this->addCheck(new FormValidatorCustom($this, 'genreId', FORM_VALIDATOR_REQUIRED_VALUE, 'submission.upload.noGenre', create_function('$genreId,$genreDao,$context', 'return is_a($genreDao->getById($genreId, $context->getId()), "Genre");'), array(DAORegistry::getDAO('GenreDAO'), $context)));
     }
     // Validate the uploader's user group.
     $uploaderUserGroupId = $this->getData('uploaderUserGroupId');
     if ($uploaderUserGroupId) {
         $user = $request->getUser();
         $this->addCheck(new FormValidatorCustom($this, 'uploaderUserGroupId', FORM_VALIDATOR_REQUIRED_VALUE, 'submission.upload.invalidUserGroup', create_function('$userGroupId,$userGroupDao,$userId', 'return $userGroupDao->userInGroup($userId, $userGroupId);'), array(DAORegistry::getDAO('UserGroupDAO'), $user->getId(), $context)));
     }
     return parent::validate();
 }