/**
  * Save name for library file
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, &$request)
 {
     import('classes.file.MonographFileManager');
     if (MonographFileManager::uploadedFileExists('attachment')) {
         $fileId = MonographFileManager::uploadReviewFile($this->monographId, 'attachment');
     }
     return $fileId;
 }
Пример #2
0
 /**
  * Upload a copyediting file
  * @param $args array
  * @param $request PKPRequest
  */
 function uploadFile($args, &$request)
 {
     // Get the copyediting signoff
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     /* @var $signoffDao SignoffDAO */
     $signoff =& $signoffDao->getById($this->getSignoffId());
     assert(is_a($signoff, 'Signoff'));
     // Get the file that is being copyedited
     $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $copyeditingFile =& $submissionFileDao->getLatestRevision($signoff->getAssocId());
     // Get the copyedited file if it exists
     if ($signoff->getFileId()) {
         $copyeditedFile =& $submissionFileDao->getLatestRevision($signoff->getFileId());
     }
     // If we're updating a file, get its ID for the file manager
     $copyeditedFileId = isset($copyeditedFile) ? $copyeditedFile->getFileId() : null;
     $monograph =& $this->getMonograph();
     import('classes.file.MonographFileManager');
     if (MonographFileManager::uploadedFileExists('copyeditingFile')) {
         $copyeditedFileId = MonographFileManager::uploadCopyeditResponseFile($monograph->getId(), 'copyeditingFile', $copyeditedFileId);
         if (isset($copyeditedFileId)) {
             // Amend the copyediting signoff with the new file
             $signoff->setFileId($copyeditedFileId);
             $signoff->setDateCompleted(Core::getCurrentDate());
             $signoffDao->updateObject($signoff);
             $copyeditedFile =& $submissionFileDao->getLatestRevision($copyeditedFileId);
             // Transfer some of the original file's metadata over to the new file
             $copyeditedFile->setName($copyeditingFile->getLocalizedName(), Locale::getLocale());
             $copyeditedFile->setGenreId($copyeditingFile->getGenreId());
             $submissionFileDao->updateObject($copyeditedFile);
         }
     }
     return $copyeditedFileId;
 }
Пример #3
0
 /**
  * Upload the file and add it to the database.
  * @param $monographId integer
  * @param $fileName string index into the $_FILES array
  * @param $fileStage int monograph file stage (one of the MONOGRAPH_FILE_* constants)
  * @param $uploaderUserId int The id of the user that uploaded the file.
  * @param $uploaderUserGroupId int The id of the user group that the uploader acted in
  *  when uploading the file.
  * @param $revisedFileId int ID of an existing file to revise
  * @param $genreId int foreign key into genres table (e.g. manuscript, etc.)
  * @param $assocType int
  * @param $assocId int
  * @return MonographFile the uploaded monograph file or null if an error occured.
  */
 function &_handleUpload($monographId, $fileName, $fileStage, $uploaderUserId, $uploaderUserGroupId, $revisedFileId = null, $genreId = null, $assocId = null, $assocType = null)
 {
     $nullVar = null;
     // Ensure that the file has been correctly uploaded to the server.
     if (!MonographFileManager::uploadedFileExists($fileName)) {
         return $nullVar;
     }
     // Retrieve the location of the uploaded file.
     $sourceFile = MonographFileManager::getUploadedFilePath($fileName);
     // Instantiate and pre-populate a new monograph file object.
     $monographFile = MonographFileManager::_instantiateMonographFile($sourceFile, $monographId, $fileStage, $revisedFileId, $genreId, $assocId, $assocType);
     if (is_null($monographFile)) {
         return $nullVar;
     }
     // Retrieve and copy the file type of the uploaded file.
     $fileType = MonographFileManager::getUploadedFileType($fileName);
     assert($fileType !== false);
     $monographFile->setFileType($fileType);
     // Retrieve and copy the file name of the uploaded file.
     $originalFileName = MonographFileManager::getUploadedFileName($fileName);
     assert($originalFileName !== false);
     $monographFile->setOriginalFileName(MonographFileManager::truncateFileName($originalFileName));
     // Set the uploader's user and user group id.
     $monographFile->setUploaderUserId($uploaderUserId);
     $monographFile->setUserGroupId($uploaderUserGroupId);
     // Copy the uploaded file to its final destination and
     // persist its meta-data to the database.
     $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     return $submissionFileDao->insertObject($monographFile, $fileName, true);
 }
Пример #4
0
 /**
  * Upload the file and add it to the database.
  * @param $monographId integer
  * @param $fileName string index into the $_FILES array
  * @param $fileStage int monograph file stage (one of the MONOGRAPH_FILE_* constants)
  * @param $revisedFileId int ID of an existing file to revise
  * @param $genreId int foreign key into genres table (e.g. manuscript, etc.)
  * @param $assocType int
  * @param $assocId int
  * @return MonographFile the uploaded monograph file or null if an error occured.
  */
 function &_handleUpload($monographId, $fileName, $fileStage, $revisedFileId = null, $genreId = null, $assocId = null, $assocType = null)
 {
     $nullVar = null;
     // Ensure that the file has been correctly uploaded to the server.
     if (!MonographFileManager::uploadedFileExists($fileName)) {
         return $nullVar;
     }
     // Instantiate and pre-populate a new monograph file object.
     $monographFile = MonographFileManager::_instantiateMonographFile($monographId, $fileStage, $revisedFileId, $genreId, $assocId, $assocType);
     if (is_null($monographFile)) {
         return $nullVar;
     }
     // Retrieve file information from the uploaded file.
     assert(isset($_FILES[$fileName]));
     $monographFile->setFileType($_FILES[$fileName]['type']);
     $monographFile->setOriginalFileName(MonographFileManager::truncateFileName($_FILES[$fileName]['name']));
     // Set the uploader's userGroupId
     // FIXME: Setting a temporary user group here until #6231 is fixed.
     // This is necessary so that we can already remove the user-group
     // attribute from the session.
     $monographFile->setUserGroupId(1);
     // Copy the uploaded file to its final destination and
     // persist its meta-data to the database.
     return MonographFileManager::_persistFile($fileName, $monographFile);
 }
 /**
  * Save name for library file
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, &$request)
 {
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getById($this->reviewId);
     $fileId = null;
     $monographId = $reviewAssignment->getSubmissionId();
     import('classes.file.MonographFileManager');
     if (MonographFileManager::uploadedFileExists('attachment')) {
         if ($reviewAssignment->getReviewerFileId() != null) {
             $fileId = MonographFileManager::uploadReviewFile($monographId, 'attachment', $reviewAssignment->getReviewerFileId(), $this->reviewId);
         } else {
             $fileId = MonographFileManager::uploadReviewFile($monographId, 'attachment', null, $this->reviewId);
         }
     }
     return $fileId;
 }