/**
  * Upload the review version of a paper.
  * @param $trackDirectorSubmission object
  */
 function uploadReviewVersion($trackDirectorSubmission)
 {
     import('file.PaperFileManager');
     $paperFileManager = new PaperFileManager($trackDirectorSubmission->getPaperId());
     $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
     $fileName = 'upload';
     if ($paperFileManager->uploadError($fileName)) {
         return false;
     }
     if (!$paperFileManager->uploadedFileExists($fileName)) {
         return false;
     }
     if (HookRegistry::call('TrackDirectorAction::uploadReviewVersion', array(&$trackDirectorSubmission))) {
         return true;
     }
     if ($trackDirectorSubmission->getReviewFileId() != null) {
         $reviewFileId = $paperFileManager->uploadReviewFile($fileName, $trackDirectorSubmission->getReviewFileId());
         // Increment the review revision.
         $trackDirectorSubmission->setReviewRevision($trackDirectorSubmission->getReviewRevision() + 1);
     } else {
         $reviewFileId = $paperFileManager->uploadReviewFile($fileName);
         $trackDirectorSubmission->setReviewRevision(1);
     }
     $directorFileId = $paperFileManager->copyToDirectorFile($reviewFileId, $trackDirectorSubmission->getReviewRevision(), $trackDirectorSubmission->getDirectorFileId());
     if ($reviewFileId != 0 && isset($directorFileId) && $directorFileId != 0) {
         $trackDirectorSubmission->setReviewFileId($reviewFileId);
         $trackDirectorSubmission->setDirectorFileId($directorFileId);
         $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
     }
     return true;
 }