/** * Return absolute path to the file on the host filesystem. * @return string */ function getFilePath() { $paperDao = DAORegistry::getDAO('PaperDAO'); $paper =& $paperDao->getPaper($this->getPaperId()); $paperId = $paper->getSchedConfId(); $schedConfDao = DAORegistry::getDAO('SchedConfDAO'); $schedConf = $schedConfDao->getById($paperId); import('classes.file.PaperFIleManager'); $paperFileManager = new PaperFileManager($this->getPaperId()); return Config::getVar('files', 'files_dir') . '/conferences/' . $schedConf->getConferenceId() . '/schedConfs/' . $paperId . '/papers/' . $this->getPaperId() . '/' . $paperFileManager->fileStageToPath($this->getFileStage()) . '/' . $this->getFileName(); }
/** * Delete a submission. */ function deleteSubmission($args, $request) { $paperId = (int) array_shift($args); $this->validate($request, $paperId, null, true); $authorSubmission =& $this->submission; $this->setupTemplate($request, true); // If the submission is incomplete, allow the author to delete it. if ($authorSubmission->getSubmissionProgress() != 0) { import('classes.file.PaperFileManager'); $paperFileManager = new PaperFileManager($paperId); $paperFileManager->deletePaperTree(); $paperDao =& DAORegistry::getDAO('PaperDAO'); $paperDao->deletePaperById($paperId); } $request->redirect(null, null, null, 'index'); }
/** * Delete a submission. */ function deleteSubmission($args) { $paperId = isset($args[0]) ? (int) $args[0] : 0; $this->validate($paperId, null, true); $authorSubmission =& $this->submission; $this->setupTemplate(true); // If the submission is incomplete, allow the author to delete it. if ($authorSubmission->getSubmissionProgress() != 0) { import('file.PaperFileManager'); $paperFileManager = new PaperFileManager($paperId); $paperFileManager->deletePaperTree(); $paperDao =& DAORegistry::getDAO('PaperDAO'); $paperDao->deletePaperById($args[0]); } Request::redirect(null, null, null, 'index'); }
function appendRecord($record) { $paper = $record['paper']; if (array_key_exists('galley', $record)) { $galley = $record['galley']; import('file.PaperFileManager'); $paperFileManager = new PaperFileManager($paper->getId()); $file =& $paperFileManager->getFile($galley->getFileId()); //set the filename $filename = $file->getFileName(); //set the filepath $schedConfId = $paper->getSchedConfId(); $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); $schedConf =& $schedConfDao->getSchedConf($schedConfId); $filesDir = Config::getVar('files', 'files_dir') . '/conferences/' . $schedConf->getConferenceId() . '/schedConfs/' . $schedConfId . '/papers/' . $paper->getId() . '/'; $filepath = $filesDir . $file->getType() . '/' . $filename; //add file to the zip if ($this->res) { if (file_exists($filepath)) { $Humanfilename = $this->setPdfFilename($paper->getTitle()); $this->zip->addFile($filepath, $Humanfilename); //put the pdf file with a human readable name } } } }
/** * Upload the submission file. * @param $fileName string * @return boolean */ function uploadSubmissionFile($fileName) { import("file.PaperFileManager"); $paperFileManager = new PaperFileManager($this->paperId); $paperDao =& DAORegistry::getDAO('PaperDAO'); if ($paperFileManager->uploadError($fileName)) { return false; } if ($paperFileManager->uploadedFileExists($fileName)) { // upload new submission file, overwriting previous if necessary $submissionFileId = $paperFileManager->uploadSubmissionFile($fileName, $this->paper->getSubmissionFileId(), true); } if (isset($submissionFileId)) { $this->paper->setSubmissionFileId($submissionFileId); $paperDao->updatePaper($this->paper); return true; } else { return false; } }
/** * Add a file to the search index. * @param $paperId int * @param $type int * @param $fileId int */ function updateFileIndex($paperId, $type, $fileId) { import('classes.file.PaperFileManager'); $fileMgr = new PaperFileManager($paperId); $file =& $fileMgr->getFile($fileId); if (isset($file)) { $parser =& SearchFileParser::fromFile($file); } if (isset($parser)) { if ($parser->open()) { $searchDao =& DAORegistry::getDAO('PaperSearchDAO'); $objectId = $searchDao->insertObject($paperId, $type, $fileId); $position = 0; while (($text = $parser->read()) !== false) { PaperSearchIndex::indexObjectKeywords($objectId, $text, $position); } $parser->close(); } } }
/** * Return string containing the contents of the HTML file. * This function performs any necessary filtering, like image URL replacement. * @param $baseImageUrl string base URL for image references * @return string */ function getHTMLContents() { import('file.PaperFileManager'); $fileManager = new PaperFileManager($this->getPaperId()); $contents = $fileManager->readFile($this->getFileId()); // Replace image references $images =& $this->getImageFiles(); foreach ($images as $image) { $imageUrl = Request::url(null, 'paper', 'viewFile', array($this->getPaperId(), $this->getGalleyId(), $image->getFileId())); $pattern = preg_quote(rawurlencode($image->getOriginalFileName())); $contents = preg_replace('/[Ss][Rr][Cc]\\s*=\\s*"([^"]*' . $pattern . ')"/', 'src="' . $imageUrl . '"', $contents); $contents = preg_replace('/[Hh][Rr][Ee][Ff]\\s*=\\s*"([^"]*' . $pattern . ')"/', 'href="' . $imageUrl . '"', $contents); } // Perform replacement for ocs://... URLs $contents = preg_replace_callback('/(<[^<>]*")[Oo][Jj][Ss]:\\/\\/([^"]+)("[^<>]*>)/', array(&$this, '_handleOcsUrl'), $contents); // Perform variable replacement for site info etc. $schedConf =& Request::getSchedConf(); $site =& Request::getSite(); $paramArray = array('confTitle' => $schedConf->getSchedConfTitle(), 'siteTitle' => $site->getLocalizedTitle(), 'currentUrl' => Request::getRequestUrl()); foreach ($paramArray as $key => $value) { $contents = str_replace('{$' . $key . '}', $value, $contents); } return $contents; }
/** * Delete an annotated version of a paper. * @param $reviewId int * @param $fileId int * @param $revision int If null, then all revisions are deleted. */ function deleteReviewerVersion($reviewId, $fileId, $revision = null) { import("file.PaperFileManager"); $paperId = Request::getUserVar('paperId'); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId); if (!HookRegistry::call('ReviewerAction::deleteReviewerVersion', array(&$reviewAssignment, &$fileId, &$revision))) { $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId()); $paperFileManager->deleteFile($fileId, $revision); } }
/** * Delete a supplementary file. * @param $args array, the first parameter is the supplementary file to delete */ function deleteSubmitSuppFile($args, $request) { import('classes.file.PaperFileManager'); $paperId = (int) $request->getUserVar('paperId'); $suppFileId = (int) array_shift($args); $this->validate($request, $paperId, 4); $this->setupTemplate($request, true); $schedConf =& $request->getSchedConf(); $paper =& $this->paper; if (!$schedConf->getSetting('acceptSupplementaryReviewMaterials')) { $request->redirect(null, null, 'index'); } $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $suppFile = $suppFileDao->getSuppFile($suppFileId, $paperId); $suppFileDao->deleteSuppFileById($suppFileId, $paperId); if ($suppFile->getFileId()) { $paperFileManager = new PaperFileManager($paperId); $paperFileManager->deleteFile($suppFile->getFileId()); } $request->redirect(null, null, null, 'submit', '4', array('paperId' => $paperId)); }
/** * Import papers (including metadata and files). */ function importPapers() { if ($this->hasOption('verbose')) { printf("Importing papers\n"); } import('classes.file.PaperFileManager'); import('classes.search.PaperSearchIndex'); $userDao =& DAORegistry::getDAO('UserDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $trackDao =& DAORegistry::getDAO('TrackDAO'); $paperDao =& DAORegistry::getDAO('PaperDAO'); $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO'); $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO'); $unassignedTrackId = null; $result =& $this->importDao->retrieve('SELECT * FROM papers ORDER by id'); while (!$result->EOF) { $row =& $result->fields; $schedConf =& $this->schedConfMap[$row['cf']]; $schedConfId = $schedConf->getId(); // Bring in the primary user for this paper. $user = $userDao->getUserByUsername(Core::cleanVar($row['login'])); if (!$user) { unset($user); $user = new User(); $user->setUsername(Core::cleanVar($row['login'])); $user->setFirstName(Core::cleanVar($row['first_name'])); $user->setLastName(Core::cleanVar($row['surname'])); $user->setAffiliation(Core::cleanVar($row['affiliation']), Locale::getLocale()); $user->setEmail(Core::cleanVar($row['email'])); $user->setUrl(Core::cleanVar($row['url'])); $user->setBiography(Core::cleanVar($row['bio']), Locale::getLocale()); $user->setLocales(array()); $user->setDateRegistered($row['created']); $user->setDateLastLogin($row['created']); $user->setMustChangePassword(1); $password = Validation::generatePassword(); $user->setPassword(Validation::encryptCredentials($user->getUsername(), $password)); if ($this->hasOption('emailUsers')) { import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('username' => $user->getUsername(), 'password' => $password, 'conferenceName' => $schedConf->getFullTitle())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } $user->setDisabled(0); $otherUser =& $userDao->getUserByEmail(Core::cleanVar($row['email'])); if ($otherUser !== null) { // User exists with this email -- munge it to make unique $user->setEmail('ocs-' . Core::cleanVar($row['login']) . '+' . Core::cleanVar($row['email'])); $this->conflicts[] = array(&$otherUser, &$user); } unset($otherUser); $userDao->insertUser($user); // Make this user a author $role = new Role(); $role->setSchedConfId($schedConf->getId()); $role->setConferenceId($schedConf->getConferenceId()); $role->setUserId($user->getId()); $role->setRoleId(ROLE_ID_AUTHOR); $roleDao->insertRole($role); unset($role); } $userId = $user->getId(); // Bring in the basic entry for the paper $paper = new Paper(); $paper->setUserId($userId); $paper->setLocale(Locale::getPrimaryLocale()); $paper->setSchedConfId($schedConfId); $oldTrackId = $row['primary_track_id']; if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) { $oldTrackId = $row['secondary_track_id']; } if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) { if (!$unassignedTrackId) { // Create an "Unassigned" track to use for submissions // that didn't have a track in OCS 1.x. $track = new Track(); $track->setSchedConfId($schedConf->getId()); $track->setTitle('UNASSIGNED', Locale::getLocale()); $track->setSequence(REALLY_BIG_NUMBER); $track->setDirectorRestricted(1); $track->setMetaReviewed(1); $unassignedTrackId = $trackDao->insertTrack($track); } $newTrackId = $unassignedTrackId; } else { $newTrackId = $this->trackMap[$oldTrackId]; } $paper->setTrackId($newTrackId); $paper->setTitle(Core::cleanVar($row['title']), Locale::getLocale()); $paper->setAbstract(Core::cleanVar($row['abstract']), Locale::getLocale()); $paper->setDiscipline(Core::cleanVar($row['discipline']), Locale::getLocale()); $paper->setSponsor(Core::cleanVar($row['sponsor']), Locale::getLocale()); $paper->setSubject(Core::cleanVar($row['topic']), Locale::getLocale()); $paper->setLanguage(Core::cleanVar($row['language'])); $paper->setDateSubmitted($row['created']); $paper->setDateStatusModified($row['timestamp']); // $paper->setTypeConst($row['present_format'] == 'multiple' ? SUBMISSION_TYPE_PANEL : SUBMISSION_TYPE_SINGLE); FIXME $paper->setCurrentRound(REVIEW_ROUND_ABSTRACT); $paper->setSubmissionProgress(0); $paper->setPages(''); // Bring in authors $firstNames = split("\n", Core::cleanVar($row['first_name'] . "\n" . $row['add_first_names'])); $lastNames = split("\n", Core::cleanVar($row['surname'] . "\n" . $row['add_surnames'])); $emails = split("\n", Core::cleanVar($row['email'] . "\n" . $row['add_emails'])); $affiliations = split("\n", Core::cleanVar($row['affiliation'] . "\n" . $row['add_affiliations'])); $urls = split("\n", Core::cleanVar($row['url'] . "\n" . $row['add_urls'])); foreach ($emails as $key => $email) { if (empty($email)) { continue; } $author = new Author(); $author->setEmail($email); $author->setFirstName($firstNames[$key]); $author->setLastName($lastNames[$key]); $author->setAffiliation($affiliations[$key], Locale::getLocale()); @$author->setUrl($urls[$key]); // Suppress warnings from inconsistent OCS 1.x data $author->setPrimaryContact($key == 0 ? 1 : 0); $paper->addAuthor($author); unset($author); } switch ($row['accepted']) { case 'true': $paper->setStatus(STATUS_PUBLISHED); $paperId = $paperDao->insertPaper($paper); $publishedPaper = new PublishedPaper(); $publishedPaper->setPaperId($paperId); $publishedPaper->setSchedConfId($schedConfId); $publishedPaper->setDatePublished(Core::getCurrentDate()); $publishedPaper->setSeq(REALLY_BIG_NUMBER); $publishedPaper->setViews(0); $publishedPaperDao->insertPublishedPaper($publishedPaper); $publishedPaperDao->resequencePublishedPapers($paper->getTrackId(), $schedConfId); break; case 'reject': $paper->setStatus(STATUS_DECLINED); $paperId = $paperDao->insertPaper($paper); break; default: $paper->setStatus(STATUS_QUEUED); $paperId = $paperDao->insertPaper($paper); } $this->paperMap[$row['id']] =& $paper; $paperFileManager = new PaperFileManager($paperId); if (!empty($row['paper']) && $row['paper'] != 'PDF') { $format = 'text/html'; $extension = $paperFileManager->getDocumentExtension($format); $fileId = $paperFileManager->writeSubmissionFile('migratedFile' . $extension, $row['paper'], $format); $paper->setSubmissionFileId($fileId); $paperDao->updatePaper($paper); $fileId = $paperFileManager->writePublicFile('migratedGalley' . $extension, $row['paper'], $format); PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId); if (strstr($format, 'html')) { $galley = new PaperHTMLGalley(); $galley->setLabel('HTML'); } else { $galley = new PaperGalley(); switch ($format) { case 'application/pdf': $galley->setLabel('PDF'); break; case 'application/postscript': $galley->setLabel('PostScript'); break; case 'application/msword': $galley->setLabel('Word'); break; case 'text/xml': $galley->setLabel('XML'); break; case 'application/powerpoint': $galley->setLabel('Slideshow'); break; default: $galley->setLabel('Untitled'); break; } } $galley->setLocale(Locale::getLocale()); $galley->setPaperId($paperId); $galley->setFileId($fileId); $galleyDao->insertGalley($galley); unset($galley); } elseif ($row['paper'] == 'PDF') { $fileId = $paperFileManager->copySubmissionFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf'); $paper->setSubmissionFileId($fileId); $paperDao->updatePaper($paper); $fileId = $paperFileManager->copyPublicFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf'); PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId); $galley = new PaperGalley(); $galley->setLabel('PDF'); $galley->setLocale(Locale::getLocale()); $galley->setPaperId($paperId); $galley->setFileId($fileId); $galleyDao->insertGalley($galley); unset($galley); } // FIXME: The following fields from OCS 1.x are UNUSED: // program_insert approach coverage format relation appendix_names appendix_dates // appendix appendix_pdf secondary_track_id multiple_* restrict_access paper_email // delete_paper comment_email unset($user); unset($paper); unset($schedConf); unset($paperFileManager); $result->MoveNext(); } $result->Close(); }
/** * Delete an image from an HTML galley. * @param $imageId int the file ID of the image */ function deleteImage($imageId) { import('classes.file.PaperFileManager'); $fileManager = new PaperFileManager($this->paperId); $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO'); if (isset($this->galley)) { $images =& $this->galley->getImageFiles(); if (isset($images)) { for ($i = 0, $count = count($images); $i < $count; $i++) { if ($images[$i]->getFileId() == $imageId) { $fileManager->deleteFile($images[$i]->getFileId()); $galleyDao->deleteGalleyImage($this->galleyId, $imageId); unset($images[$i]); break; } } } } }
/** * Upload the revised version of a paper. * @param $authorSubmission object */ function uploadRevisedVersion($authorSubmission) { import('file.PaperFileManager'); $paperFileManager = new PaperFileManager($authorSubmission->getPaperId()); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $fileName = 'upload'; if ($paperFileManager->uploadError($fileName)) { return false; } if (!$paperFileManager->uploadedFileExists($fileName)) { return false; } HookRegistry::call('AuthorAction::uploadRevisedVersion', array(&$authorSubmission)); if ($authorSubmission->getRevisedFileId() != null) { $fileId = $paperFileManager->uploadDirectorDecisionFile($fileName, $authorSubmission->getRevisedFileId()); } else { $fileId = $paperFileManager->uploadDirectorDecisionFile($fileName); } if (!$fileId) { return false; } $authorSubmission->setRevisedFileId($fileId); $authorSubmissionDao->updateAuthorSubmission($authorSubmission); // Add log entry $user =& Request::getUser(); import('paper.log.PaperLog'); import('paper.log.PaperEventLogEntry'); PaperLog::logEvent($authorSubmission->getPaperId(), PAPER_LOG_AUTHOR_REVISION, LOG_TYPE_AUTHOR, $user->getId(), 'log.author.documentRevised', array('authorName' => $user->getFullName(), 'fileId' => $fileId, 'paperId' => $authorSubmission->getPaperId())); }
/** * PRIVATE routine to copy a paper file and add it to the database. * @param $url original filename/url of the file * @param $mimeType string the mime type of the file * @param $type string identifying type * @param $fileId int ID of an existing file to update * @param $overwrite boolean overwrite all previous revisions of the file (revision number is still incremented) * @return int the file ID (false if upload failed) */ function handleCopy($url, $mimeType, $type, $fileId = null, $overwrite = false) { $paperFileDao =& DAORegistry::getDAO('PaperFileDAO'); $typePath = $this->typeToPath($type); $dir = $this->filesDir . $typePath . '/'; if (!$fileId) { // Insert dummy file to generate file id FIXME? $dummyFile = true; $paperFile =& $this->generateDummyFile($this->paper); } else { $dummyFile = false; $paperFile = new PaperFile(); $paperFile->setRevision($paperFileDao->getRevisionNumber($fileId) + 1); $paperFile->setPaperId($this->paperId); $paperFile->setFileId($fileId); $paperFile->setDateUploaded(Core::getCurrentDate()); $paperFile->setDateModified(Core::getCurrentDate()); } $paperFile->setFileType($mimeType); $paperFile->setOriginalFileName(PaperFileManager::truncateFileName(basename($url), 127)); $paperFile->setType($typePath); $paperFile->setStage($this->paper->getCurrentStage()); $newFileName = $this->generateFilename($paperFile, $type, $paperFile->getOriginalFileName()); if (!$this->copyFile($url, $dir . $newFileName)) { // Delete the dummy file we inserted $paperFileDao->deletePaperFileById($paperFile->getFileId()); return false; } $paperFile->setFileSize(filesize($dir . $newFileName)); if ($dummyFile) { $paperFileDao->updatePaperFile($paperFile); } else { $paperFileDao->insertPaperFile($paperFile); } if ($overwrite) { $this->removePriorRevisions($paperFile->getFileId(), $paperFile->getRevision()); } return $paperFile->getFileId(); }
/** * Delete a supplementary file. * @param $args array, the first parameter is the supplementary file to delete */ function deleteSubmitSuppFile($args) { import("file.PaperFileManager"); $paperId = Request::getUserVar('paperId'); $suppFileId = isset($args[0]) ? (int) $args[0] : 0; $this->validate($paperId, 4); $this->setupTemplate(true); $schedConf =& Request::getSchedConf(); $paper =& $this->paper; if (!$schedConf->getSetting('acceptSupplementaryReviewMaterials')) { Request::redirect(null, null, 'index'); } $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $suppFile = $suppFileDao->getSuppFile($suppFileId, $paperId); $suppFileDao->deleteSuppFileById($suppFileId, $paperId); if ($suppFile->getFileId()) { $paperFileManager = new PaperFileManager($paperId); $paperFileManager->deleteFile($suppFile->getFileId()); } Request::redirect(null, null, null, 'submit', '4', array('paperId' => $paperId)); }
/** * Downloads a supplementary file * @param $args array * @param $request Request */ function downloadSuppFile($args, &$request) { $router =& $request->getRouter(); $paperId = isset($args[0]) ? $args[0] : 0; $suppId = isset($args[1]) ? $args[1] : 0; $schedConf =& $router->getContext($request, CONTEXT_SCHED_CONF); $this->validate($request, $paperId); $paper =& $this->paper; $suppFileDao = DAORegistry::getDAO('SuppFileDAO'); if ($schedConf->getSetting('enablePublicSuppFileId')) { $suppFile =& $suppFileDao->getSuppFileByBestSuppFileId($paper->getId(), $suppId); } else { $suppFile =& $suppFileDao->getSuppFile((int) $suppId, $paper->getId()); } if ($paper && $suppFile) { import('classes.file.PaperFileManager'); $paperFileManager = new PaperFileManager($paper->getId()); $paperFileManager->downloadFile($suppFile->getFileId(), null, $suppFile->isInlineable()); } }
/** * Delete a submission. */ function deleteSubmission($args, $request) { $paperId = isset($args[0]) ? (int) $args[0] : 0; $this->validate($request); $schedConf =& $request->getSchedConf(); $paperDao =& DAORegistry::getDAO('PaperDAO'); $paper =& $paperDao->getPaper($paperId); $status = $paper->getStatus(); $progress = $paper->getSubmissionProgress(); $round = $paper->getCurrentRound(); if ($paper->getSchedConfId() == $schedConf->getId() && ($status == STATUS_DECLINED || $status == STATUS_ARCHIVED || $progress != 0 && ($round == REVIEW_ROUND_ABSTRACT || $round == REVIEW_ROUND_PRESENTATION && $progress < 3))) { // Delete paper files import('classes.file.PaperFileManager'); $paperFileManager = new PaperFileManager($paperId); $paperFileManager->deletePaperTree(); // Delete paper database entries $paperDao->deletePaperById($paperId); } $request->redirect(null, null, null, 'submissions', 'submissionsArchives'); }
/** * Upload a review on behalf of its reviewer. * @param $reviewId int */ function uploadReviewForReviewer($reviewId) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $user =& Request::getUser(); $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId); $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true); if (HookRegistry::call('TrackDirectorAction::uploadReviewForReviewer', array(&$reviewAssignment, &$reviewer))) { return; } // Upload the review file. import('file.PaperFileManager'); $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId()); // Only upload the file if the reviewer has yet to submit a recommendation if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) { $fileName = 'upload'; if ($paperFileManager->uploadError($fileName)) { return false; } if ($paperFileManager->uploadedFileExists($fileName)) { if ($reviewAssignment->getReviewerFileId() != null) { $fileId = $paperFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId()); } else { $fileId = $paperFileManager->uploadReviewFile($fileName); } } } if (isset($fileId) && $fileId != 0) { // Only confirm the review for the reviewer if // he has not previously done so. if ($reviewAssignment->getDateConfirmed() == null) { $reviewAssignment->setDeclined(0); $reviewAssignment->setDateConfirmed(Core::getCurrentDate()); } $reviewAssignment->setReviewerFileId($fileId); $reviewAssignment->stampModified(); $reviewAssignmentDao->updateReviewAssignment($reviewAssignment); // Add log import('paper.log.PaperLog'); import('paper.log.PaperEventLogEntry'); $entry = new PaperEventLogEntry(); $entry->setPaperId($reviewAssignment->getPaperId()); $entry->setUserId($user->getId()); $entry->setDateLogged(Core::getCurrentDate()); $entry->setEventType(PAPER_LOG_REVIEW_FILE_BY_PROXY); $entry->setLogMessage('log.review.reviewFileByProxy', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $reviewAssignment->getPaperId(), 'stage' => $reviewAssignment->getStage(), 'userName' => $user->getFullName())); $entry->setAssocType(LOG_TYPE_REVIEW); $entry->setAssocId($reviewAssignment->getId()); PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry); } }
/** * Delete a paper by ID. * @param $paperId int */ function deletePaperById($paperId) { $this->authorDao->deleteAuthorsByPaper($paperId); $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO'); $publishedPaperDao->deletePublishedPaperByPaperId($paperId); $commentDao =& DAORegistry::getDAO('CommentDAO'); $commentDao->deleteCommentsByPaper($paperId); $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO'); $paperNoteDao->clearAllPaperNotes($paperId); $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO'); $trackDirectorSubmissionDao->deleteDecisionsByPaper($paperId); $trackDirectorSubmissionDao->deleteReviewStagesByPaper($paperId); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignmentDao->deleteReviewAssignmentsByPaper($paperId); $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); $editAssignmentDao->deleteEditAssignmentsByPaper($paperId); $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO'); $paperCommentDao->deletePaperComments($paperId); $paperGalleyDao =& DAORegistry::getDAO('PaperGalleyDAO'); $paperGalleyDao->deleteGalleysByPaper($paperId); $paperSearchDao =& DAORegistry::getDAO('PaperSearchDAO'); $paperSearchDao->deletePaperKeywords($paperId); $paperEventLogDao =& DAORegistry::getDAO('PaperEventLogDAO'); $paperEventLogDao->deletePaperLogEntries($paperId); $paperEmailLogDao =& DAORegistry::getDAO('PaperEmailLogDAO'); $paperEmailLogDao->deletePaperLogEntries($paperId); $paperEventLogDao =& DAORegistry::getDAO('PaperEventLogDAO'); $paperEventLogDao->deletePaperLogEntries($paperId); $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $suppFileDao->deleteSuppFilesByPaper($paperId); // Delete paper files -- first from the filesystem, then from the database import('file.PaperFileManager'); $paperFileDao =& DAORegistry::getDAO('PaperFileDAO'); $paperFiles =& $paperFileDao->getPaperFilesByPaper($paperId); $paperFileManager = new PaperFileManager($paperId); foreach ($paperFiles as $paperFile) { $paperFileManager->deleteFile($paperFile->getFileId()); } $paperFileDao->deletePaperFiles($paperId); $this->update('DELETE FROM paper_settings WHERE paper_id = ?', $paperId); $this->update('DELETE FROM papers WHERE paper_id = ?', $paperId); }
/** * Save changes to the supplementary file. * @return int the supplementary file ID */ function execute() { import("file.PaperFileManager"); $paperFileManager = new PaperFileManager($this->paperId); $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $fileName = 'uploadSuppFile'; // edit an existing supp file, otherwise create new supp file entry if (isset($this->suppFile)) { $suppFile =& $this->suppFile; // Remove old file and upload new, if file is selected. if ($paperFileManager->uploadedFileExists($fileName)) { $paperFileDao =& DAORegistry::getDAO('PaperFileDAO'); $suppFileId = $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId(), true); $suppFile->setFileId($suppFileId); } // Update existing supplementary file $this->setSuppFileData($suppFile); $suppFileDao->updateSuppFile($suppFile); } else { // Upload file, if file selected. if ($paperFileManager->uploadedFileExists($fileName)) { $fileId = $paperFileManager->uploadSuppFile($fileName); } else { $fileId = 0; } // Insert new supplementary file $suppFile = new SuppFile(); $suppFile->setPaperId($this->paperId); $suppFile->setFileId($fileId); $this->setSuppFileData($suppFile); $suppFileDao->insertSuppFile($suppFile); $this->suppFileId = $suppFile->getId(); } return $this->suppFileId; }
/** * View file. * @param $paperId int * @param $fileId int * @param $revision int */ function viewFile($paperId, $fileId, $revision = null) { import('classes.file.PaperFileManager'); $paperFileManager = new PaperFileManager($paperId); return $paperFileManager->viewFile($fileId, $revision); }
/** * Save changes to the supplementary file. * @return int the supplementary file ID */ function execute($fileName = null) { import("file.PaperFileManager"); $paperFileManager = new PaperFileManager($this->paper->getPaperId()); $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $fileName = isset($fileName) ? $fileName : 'uploadSuppFile'; if (isset($this->suppFile)) { $suppFile =& $this->suppFile; // Upload file, if file selected. if ($paperFileManager->uploadedFileExists($fileName)) { $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId()); import('search.PaperSearchIndex'); PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId()); } // Index metadata PaperSearchIndex::indexSuppFileMetadata($suppFile); // Update existing supplementary file $this->setSuppFileData($suppFile); $suppFileDao->updateSuppFile($suppFile); } else { // Upload file, if file selected. if ($paperFileManager->uploadedFileExists($fileName)) { $fileId = $paperFileManager->uploadSuppFile($fileName); import('search.PaperSearchIndex'); PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $fileId); } else { $fileId = 0; } // Insert new supplementary file $suppFile = new SuppFile(); $suppFile->setPaperId($this->paper->getPaperId()); $suppFile->setFileId($fileId); $this->setSuppFileData($suppFile); $suppFileDao->insertSuppFile($suppFile); $this->suppFileId = $suppFile->getId(); } return $this->suppFileId; }
function &generateSuppFileDom(&$doc, &$schedConf, &$paper, &$suppFile) { $root =& XMLCustomWriter::createElement($doc, 'supplemental_file'); // FIXME: These should be constants! switch ($suppFile->getType()) { case __('author.submit.suppFile.researchInstrument'): $suppFileType = 'research_instrument'; break; case __('author.submit.suppFile.researchMaterials'): $suppFileType = 'research_materials'; break; case __('author.submit.suppFile.researchResults'): $suppFileType = 'research_results'; break; case __('author.submit.suppFile.transcripts'): $suppFileType = 'transcripts'; break; case __('author.submit.suppFile.dataAnalysis'): $suppFileType = 'data_analysis'; break; case __('author.submit.suppFile.dataSet'): $suppFileType = 'data_set'; break; case __('author.submit.suppFile.sourceText'): $suppFileType = 'source_text'; break; default: $suppFileType = 'other'; break; } XMLCustomWriter::setAttribute($root, 'type', $suppFileType); XMLCustomWriter::setAttribute($root, 'public_id', $suppFile->getPublicSuppFileId(), false); XMLCustomWriter::setAttribute($root, 'language', $suppFile->getLanguage(), false); if (is_array($suppFile->getTitle(null))) { foreach ($suppFile->getTitle(null) as $locale => $title) { $titleNode =& XMLCustomWriter::createChildWithText($doc, $root, 'title', $title, false); if ($titleNode) { XMLCustomWriter::setAttribute($titleNode, 'locale', $locale); } unset($titleNode); } } if (is_array($suppFile->getCreator(null))) { foreach ($suppFile->getCreator(null) as $locale => $creator) { $creatorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'creator', $creator, false); if ($creatorNode) { XMLCustomWriter::setAttribute($creatorNode, 'locale', $locale); } unset($creatorNode); } } if (is_array($suppFile->getSubject(null))) { foreach ($suppFile->getSubject(null) as $locale => $subject) { $subjectNode =& XMLCustomWriter::createChildWithText($doc, $root, 'subject', $subject, false); if ($subjectNode) { XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale); } unset($subjectNode); } } if ($suppFileType == 'other') { if (is_array($suppFile->getTypeOther(null))) { foreach ($suppFile->getTypeOther(null) as $locale => $typeOther) { $typeOtherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'type_other', $typeOther, false); if ($typeOtherNode) { XMLCustomWriter::setAttribute($typeOtherNode, 'locale', $locale); } unset($typeOtherNode); } } } if (is_array($suppFile->getDescription(null))) { foreach ($suppFile->getDescription(null) as $locale => $description) { $descriptionNode =& XMLCustomWriter::createChildWithText($doc, $root, 'description', $description, false); if ($descriptionNode) { XMLCustomWriter::setAttribute($descriptionNode, 'locale', $locale); } unset($descriptionNode); } } if (is_array($suppFile->getPublisher(null))) { foreach ($suppFile->getPublisher(null) as $locale => $publisher) { $publisherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'publisher', $publisher, false); if ($publisherNode) { XMLCustomWriter::setAttribute($publisherNode, 'locale', $locale); } unset($publisherNode); } } if (is_array($suppFile->getSponsor(null))) { foreach ($suppFile->getSponsor(null) as $locale => $sponsor) { $sponsorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'sponsor', $sponsor, false); if ($sponsorNode) { XMLCustomWriter::setAttribute($sponsorNode, 'locale', $locale); } unset($sponsorNode); } } XMLCustomWriter::createChildWithText($doc, $root, 'date_created', NativeExportDom::formatDate($suppFile->getDateCreated()), false); if (is_array($suppFile->getSource(null))) { foreach ($suppFile->getSource(null) as $locale => $source) { $sourceNode =& XMLCustomWriter::createChildWithText($doc, $root, 'source', $source, false); if ($sourceNode) { XMLCustomWriter::setAttribute($sourceNode, 'locale', $locale); } unset($sourceNode); } } import('classes.file.PaperFileManager'); $paperFileManager = new PaperFileManager($paper->getId()); $fileNode =& XMLCustomWriter::createElement($doc, 'file'); XMLCustomWriter::appendChild($root, $fileNode); $embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($paperFileManager->readFile($suppFile->getFileId()))); XMLCustomWriter::setAttribute($embedNode, 'filename', $suppFile->getOriginalFileName()); XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64'); XMLCustomWriter::setAttribute($embedNode, 'mime_type', $suppFile->getFileType()); return $root; }