/**
  * @copydoc Form::execute()
  */
 function execute($args, $request)
 {
     //
     // FIXME: Should caption, credit, or any other fields be
     // localized?
     // FIXME: How to upload a permissions file?
     // FIXME: How to select a contact author from the submission
     // author list?
     //
     // Update the sumbission file by reference.
     $submissionFile = $this->getSubmissionFile();
     $submissionFile->setCaption($this->getData('artworkCaption'));
     $submissionFile->setCredit($this->getData('artworkCredit'));
     $submissionFile->setCopyrightOwner($this->getData('artworkCopyrightOwner'));
     $submissionFile->setCopyrightOwnerContactDetails($this->getData('artworkCopyrightOwnerContact'));
     $submissionFile->setPermissionTerms($this->getData('artworkPermissionTerms'));
     // Persist the submission file.
     parent::execute($args, $request);
 }
 /**
  * @copydoc Form::execute()
  */
 function execute($args, $request)
 {
     // Update the submission file from form data.
     $submissionFile = $this->getSubmissionFile();
     $submissionFile->setSubject($this->getData('subject'), null);
     // Localized
     $submissionFile->setCreator($this->getData('creator'), null);
     // Localized
     $submissionFile->setDescription($this->getData('description'), null);
     // Localized
     $submissionFile->setPublisher($this->getData('publisher'), null);
     // Localized
     $submissionFile->setSponsor($this->getData('sponsor'), null);
     // Localized
     $submissionFile->setSource($this->getData('source'), null);
     // Localized
     $submissionFile->setLanguage($this->getData('language'));
     $submissionFile->setDateCreated($this->getData('dateCreated'));
     // Persist the submission file.
     parent::execute($args, $request);
 }
 /**
  * Fetch the form.
  * @see Form::fetch()
  */
 function fetch(&$request)
 {
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('fileId', $this->_fileId);
     $templateMgr->assign('signoffId', $this->_signoffId);
     //$templateMgr->assign('monographId', $this->_monographId);
     $artworkFileDao =& DAORegistry::getDAO('ArtworkFileDAO');
     $artworkFile =& $artworkFileDao->getByFileId($this->_fileId);
     $templateMgr->assign_by_ref('artworkFile', $artworkFile);
     $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $monographFile =& $submissionFileDao->getLatestRevision($this->_fileId);
     $templateMgr->assign_by_ref('monographFile', $monographFile);
     $templateMgr->assign_by_ref('monographId', $monographFile->getMonographId());
     // artwork can be grouped by monograph chapter
     if ($artworkFile) {
         $chapterDao =& DAORegistry::getDAO('ChapterDAO');
         $chapters =& $chapterDao->getChapters($artworkFile->getMonographId());
         $chapterOptions = array();
         if ($chapters) {
             while ($chapter =& $chapters->next()) {
                 $chapterId = $chapter->getId();
                 $chapterOptions[$chapterId] = $chapter->getLocalizedTitle();
                 unset($chapter);
             }
         }
         $templateMgr->assign_by_ref('selectedChapter', $artworkFile->getChapterId());
     } else {
         $chapters = null;
     }
     $noteDao =& DAORegistry::getDAO('NoteDAO');
     $notes =& $noteDao->getByAssoc(ASSOC_TYPE_MONOGRAPH_FILE, $this->_fileId);
     $templateMgr->assign('note', $notes->next());
     $templateMgr->assign_by_ref('chapterOptions', $chapterOptions);
     return parent::fetch($request);
 }
 /**
  * Save the metadata of a submission file
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function saveMetadata($args, &$request)
 {
     $fileId = $request->getUserVar('fileId');
     $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $monographFile =& $submissionFileDao->getLatestRevision($fileId);
     $genreDao =& DAORegistry::getDAO('GenreDAO');
     $genre = $genreDao->getById($monographFile->getGenreId());
     $monographId = $monographFile->getMonographId();
     switch ($genre->getCategory()) {
         // FIXME: Need a way to determine artwork file type from user-specified artwork file types
         case GENRE_CATEGORY_ARTWORK:
             import('controllers.grid.files.form.SubmissionFilesArtworkMetadataForm');
             $metadataForm = new SubmissionFilesArtworkMetadataForm($monographFile, WORKFLOW_STAGE_ID_EDITING);
             break;
         default:
             import('controllers.grid.files.form.SubmissionFilesMetadataForm');
             $metadataForm = new SubmissionFilesMetadataForm($monographFile, WORKFLOW_STAGE_ID_EDITING);
             break;
     }
     $metadataForm->readInputData();
     if ($metadataForm->validate()) {
         $metadataForm->execute($args, $request);
         $router =& $request->getRouter();
         $additionalAttributes = array('isEditing' => true, 'finishingUpUrl' => $router->url($request, null, null, 'finishFileSubmission', null, array('gridId' => $this->getId(), 'fileId' => $fileId, 'monographId' => $monographId)));
         $json = new JSON(true, '', false, $fileId, $additionalAttributes);
     } else {
         $json = new JSON(false, Locale::translate('submission.submit.fileNameRequired'));
     }
     return $json->getString();
 }