public function testIsValidMethodWithMissingRightsCheckbox() { $config = Zend_Registry::get('Zend_Config'); $config->form->first->require_upload = 0; $config->form->first->show_rights_checkbox = 1; $config->form->first->bibliographie = 0; $form = new Publish_Form_PublishingFirst(new Zend_View()); $data = array('documentType' => 'preprint', 'rights' => '0'); $valid = $form->isValid($data); $this->assertFalse($valid); }
public function uploadAction() { $this->view->languageSelectorDisabled = true; $this->view->title = 'publish_controller_index'; $this->view->requiredHint = $this->view->translate('publish_controller_required_hint'); $this->view->subtitle = $this->view->translate('publish_controller_index_sub'); if ($this->getRequest()->isPost() !== true) { return $this->_redirectTo('index', '', 'index'); } //initializing $indexForm = new Publish_Form_PublishingFirst($this->view); $postData = $this->getRequest()->getPost(); $this->view->showBib = $indexForm->bibliographie; $this->view->showRights = $indexForm->showRights; $this->view->enableUpload = $indexForm->enableUpload; if (!$indexForm->enableUpload) { $this->view->subtitle = $this->view->translate('publish_controller_index_sub_without_file'); } if (is_array($postData) && count($postData) === 0) { $this->getLogger()->err('FormController: EXCEPTION during uploading. Possibly the upload_max_filesize in php.ini is lower than' . ' the expected value in OPUS4 config.ini. Further information can be read in our documentation.'); return $this->_redirectTo('index', $this->view->translate('error_empty_post_array'), 'index'); } //don't allow MAX_FILE_SIZE to get overridden $config = $this->getConfig(); $postData['MAX_FILE_SIZE'] = $config->publish->maxfilesize; $indexForm->populate($postData); $this->_initializeDocument($postData); $files = $this->document->getFile(); if (!empty($files)) { $this->view->subtitle = $this->view->translate('publish_controller_index_anotherFile'); } $config = Zend_Registry::get('Zend_Config'); if (isset($config->publish->filetypes->allowed)) { $this->view->extensions = $config->publish->filetypes->allowed; } // validate fileupload (if the current form contains a file upload field and file upload is enabled in // application config) if ($indexForm->enableUpload) { if ($indexForm->getElement('fileupload') != null && !$indexForm->getElement('fileupload')->isValid($postData)) { $indexForm->setViewValues(); $this->view->errorCaseMessage = $this->view->translate('publish_controller_form_errorcase'); } else { //file valid-> store file $this->view->uploadSuccess = $this->_storeUploadedFiles($postData); if ($this->view->uploadSuccess) { $this->view->subtitle = $this->view->translate('publish_controller_index_anotherFile'); } // TODO warum wird hier nochmal eine Form instanziiert und nicht das bereits erzeugte verwendet? $indexForm = new Publish_Form_PublishingFirst($this->view); $indexForm->populate($postData); $indexForm->setViewValues(); if (array_key_exists('addAnotherFile', $postData)) { $postData['uploadComment'] = ""; return $this->renderScript('index/index.phtml'); } } } //validate whole form if (!$indexForm->isValid($postData)) { $indexForm->setViewValues(); $this->view->errorCaseMessage = $this->view->translate('publish_controller_form_errorcase'); return $this->renderScript('index/index.phtml'); } //form entries are valid: store data $this->_storeBibliography($postData, $config); try { $publishForm = $this->createPublishingSecondForm(); } catch (Publish_Model_FormSessionTimeoutException $e) { // Session timed out. return $this->_redirectTo('index', '', 'index'); } $this->showTemplate($publishForm); $this->renderDocumenttypeForm(); }