本文整理汇总了PHP中ArticleFileManager::uploadedFileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleFileManager::uploadedFileExists方法的具体用法?PHP ArticleFileManager::uploadedFileExists怎么用?PHP ArticleFileManager::uploadedFileExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleFileManager
的用法示例。
在下文中一共展示了ArticleFileManager::uploadedFileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadSubmissionFile
/**
* Upload the submission file.
* @param $fileName string
* @return boolean
*/
function uploadSubmissionFile($fileName)
{
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($this->articleId);
$articleDao =& DAORegistry::getDAO('ArticleDAO');
if ($articleFileManager->uploadedFileExists($fileName)) {
// upload new submission file, overwriting previous if necessary
$submissionFileId = $articleFileManager->uploadSubmissionFile($fileName, $this->article->getSubmissionFileId(), true);
}
if (isset($submissionFileId)) {
$this->article->setSubmissionFileId($submissionFileId);
return $articleDao->updateArticle($this->article);
} else {
return false;
}
}
示例2: uploadImage
/**
* Upload an image to an HTML galley.
* @param $imageName string file input key
*/
function uploadImage()
{
import('classes.file.ArticleFileManager');
$fileManager = new ArticleFileManager($this->articleId);
$galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
$fileName = 'imageFile';
if (isset($this->galley) && $fileManager->uploadedFileExists($fileName)) {
$type = $fileManager->getUploadedFileType($fileName);
$extension = $fileManager->getImageExtension($type);
if (!$extension) {
$this->addError('imageFile', __('submission.layout.imageInvalid'));
return false;
}
if ($fileId = $fileManager->uploadPublicFile($fileName)) {
$galleyDao->insertGalleyImage($this->galleyId, $fileId);
// Update galley image files
$this->galley->setImageFiles($galleyDao->getGalleyImages($this->galleyId));
}
}
}
示例3: uploadReviewerVersion
/**
* Upload the annotated version of an article.
* @param $reviewId int
*/
function uploadReviewerVersion($reviewId)
{
import('classes.file.ArticleFileManager');
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO');
$reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
$sectionDecision =& $sectionDecisionDao->getSectionDecision($reviewAssignment->getDecisionId());
$articleFileManager = new ArticleFileManager($sectionDecision->getArticleId());
// Only upload the file if the reviewer has yet to submit a recommendation
// and if review forms are not used
if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
$fileName = 'upload';
if ($articleFileManager->uploadedFileExists($fileName)) {
// Check if file already uploaded
$reviewFile =& $reviewAssignment->getReviewerFile();
if ($reviewFile != null) {
$articleFileManager->deleteFile($reviewFile->getFileId());
}
HookRegistry::call('ReviewerAction::uploadReviewFile', array(&$reviewAssignment));
if ($reviewAssignment->getReviewerFileId() != null) {
$fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getDecisionId(), $reviewAssignment->getReviewerFileId());
} else {
$fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getDecisionId());
}
}
}
if (isset($fileId) && $fileId != 0) {
$reviewAssignment->setReviewerFileId($fileId);
$reviewAssignment->stampModified();
$reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
// Add log
import('classes.article.log.ArticleLog');
import('classes.article.log.ArticleEventLogEntry');
$userDao =& DAORegistry::getDAO('UserDAO');
$reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
$entry = new ArticleEventLogEntry();
$entry->setArticleId($sectionDecision->getArticleId());
$entry->setUserId($reviewer->getId());
$entry->setDateLogged(Core::getCurrentDate());
$entry->setEventType(ARTICLE_LOG_REVIEW_FILE);
$entry->setLogLevel('N');
$entry->setLogMessage('log.review.reviewerFile');
$entry->setAssocType(ARTICLE_LOG_TYPE_REVIEW);
$entry->setAssocId($reviewAssignment->getId());
ArticleLog::logEventEntry($sectionDecision->getArticleId(), $entry);
//Send a notification to section editors
import('lib.pkp.classes.notification.NotificationManager');
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$article =& $articleDao->getArticle($sectionDecision->getArticleId());
$notificationManager = new NotificationManager();
$notificationUsers = $article->getAssociatedUserIds(false, false);
$user =& Request::getUser();
$message = $article->getProposalId() . ':<br/>' . $user->getUsername();
foreach ($notificationUsers as $userRole) {
$url = Request::url(null, $userRole['role'], 'submission', array($article->getId(), 'submissionReview'), null, 'peerReview');
$notificationManager->createNotification($userRole['id'], 'notification.type.reviewerFile', $message, $url, 1, NOTIFICATION_TYPE_REVIEWER_COMMENT);
}
}
}
示例4: uploadCopyeditVersion
/**
* Upload the revised version of a copyedit file.
* @param $authorSubmission object
* @param $copyeditStage string
*/
function uploadCopyeditVersion($authorSubmission, $copyeditStage)
{
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($authorSubmission->getId());
$authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
$articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
// Authors cannot upload if the assignment is not active, i.e.
// they haven't been notified or the assignment is already complete.
$authorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $authorSubmission->getId());
if (!$authorSignoff->getDateNotified() || $authorSignoff->getDateCompleted()) {
return;
}
$fileName = 'upload';
if ($articleFileManager->uploadedFileExists($fileName)) {
HookRegistry::call('AuthorAction::uploadCopyeditVersion', array(&$authorSubmission, &$copyeditStage));
if ($authorSignoff->getFileId() != null) {
$fileId = $articleFileManager->uploadCopyeditFile($fileName, $authorSignoff->getFileId());
} else {
$fileId = $articleFileManager->uploadCopyeditFile($fileName);
}
}
$authorSignoff->setFileId($fileId);
if ($copyeditStage == 'author') {
$authorSignoff->setFileRevision($articleFileDao->getRevisionNumber($fileId));
}
$signoffDao->updateObject($authorSignoff);
}
示例5: execute
/**
* Save changes to the supplementary file.
* @return int the supplementary file ID
*/
function execute($fileName = null)
{
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($this->article->getArticleId());
$suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
$fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
if (isset($this->suppFile)) {
parent::execute();
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $this->suppFile->getFileId();
if ($fileId != 0) {
$articleFileManager->uploadSuppFile($fileName, $fileId);
} else {
$fileId = $articleFileManager->uploadSuppFile($fileName);
$this->suppFile->setFileId($fileId);
}
import('classes.search.ArticleSearchIndex');
ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
}
// Index metadata
ArticleSearchIndex::indexSuppFileMetadata($this->suppFile);
// Update existing supplementary file
$this->setSuppFileData($this->suppFile);
$suppFileDao->updateSuppFile($this->suppFile);
} else {
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $articleFileManager->uploadSuppFile($fileName);
import('classes.search.ArticleSearchIndex');
ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
} else {
$fileId = 0;
}
// Insert new supplementary file
$this->suppFile = new SuppFile();
$this->suppFile->setArticleId($this->article->getArticleId());
$this->suppFile->setFileId($fileId);
parent::execute();
$this->setSuppFileData($this->suppFile);
$suppFileDao->insertSuppFile($this->suppFile);
$this->suppFileId = $this->suppFile->getId();
}
return $this->suppFileId;
}
示例6: execute
/**
* Save changes to the report file.
* @return int the report file ID
*/
function execute($fileName = null)
{
$sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO');
$articleDao =& DAORegistry::getDAO('ArticleDAO');
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($this->article->getArticleId());
$fileName = isset($fileName) ? $fileName : 'uploadReportFile';
$lastDecision = $this->article->getLastSectionDecision();
$lastDecisionDecision = $lastDecision->getDecision();
$lastDecisionType = $lastDecision->getReviewType();
// Ensure to start a new round of review when needed, and if the file to upload is correct
if (($lastDecisionDecision == SUBMISSION_SECTION_DECISION_APPROVED || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_EXEMPTED || $lastDecisionType == REVIEW_TYPE_SAE && ($lastDecisionDecision == SUBMISSION_SECTION_DECISION_INCOMPLETE || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_RESUBMIT)) && $articleFileManager->uploadedFileExists($fileName)) {
$this->fileId = $articleFileManager->uploadSAEFile($fileName);
} else {
$this->fileId = 0;
}
if ($this->fileId && $this->fileId > 0) {
$sectionDecision =& new SectionDecision();
$sectionDecision->setSectionId($lastDecision->getSectionId());
$sectionDecision->setDecision(0);
$sectionDecision->setDateDecided(date(Core::getCurrentDate()));
$sectionDecision->setArticleId($this->article->getArticleId());
$sectionDecision->setReviewType(REVIEW_TYPE_SAE);
if ($lastDecisionType == $sectionDecision->getReviewType()) {
$lastRound = (int) $lastDecision->getRound();
$sectionDecision->setRound($lastRound + 1);
} else {
$sectionDecision->setRound(1);
}
$sectionDecisionDao->insertSectionDecision($sectionDecision);
$articleDao->changeArticleStatus($this->article->getArticleId(), STATUS_QUEUED);
}
// Notifications
import('lib.pkp.classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$journal =& Request::getJournal();
$url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($this->article->getArticleId(), 'submissionReview'));
$sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
$sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $lastDecision->getSectionId());
foreach ($sectionEditors as $sectionEditor) {
$notificationSectionEditors[] = array('id' => $sectionEditor->getId());
}
foreach ($notificationSectionEditors as $userRole) {
$notificationManager->createNotification($userRole['id'], 'notification.type.sae', $this->article->getProposalId(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED);
}
return $this->fileId;
}
示例7: execute
/**
* Save changes to the supplementary file.
* @return int the supplementary file ID
*/
function execute($fileName = null)
{
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($this->article->getArticleId());
$suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
$fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
if (isset($this->suppFile)) {
$suppFile =& $this->suppFile;
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$articleFileManager->uploadSuppFile($fileName, $suppFile->getFileId());
import('classes.search.ArticleSearchIndex');
ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
}
// Index metadata
ArticleSearchIndex::indexSuppFileMetadata($suppFile);
// Update existing supplementary file
$this->setSuppFileData($suppFile);
$suppFileDao->updateSuppFile($suppFile);
} else {
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $articleFileManager->uploadSuppFile($fileName);
import('classes.search.ArticleSearchIndex');
ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
// Insert new supplementary file
$suppFile = new SuppFile();
$suppFile->setArticleId($this->article->getArticleId());
$suppFile->setFileId($fileId);
$this->setSuppFileData($suppFile);
$suppFileDao->insertSuppFile($suppFile);
$this->suppFileId = $suppFile->getId();
} else {
$fileId = 0;
}
}
// Notifications
import('lib.pkp.classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$journal =& Request::getJournal();
$url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($this->article->getArticleId(), 'submissionReview'));
$sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
$sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $this->article->getSectionId());
foreach ($sectionEditors as $sectionEditor) {
$notificationSectionEditors[] = array('id' => $sectionEditor->getId());
}
if ($suppFile->getData('type') == 'Raw Data File') {
$message = 'notification.type.rawDataSubmitted';
}
if ($suppFile->getData('type') == 'Other Supplementary Research Output') {
$message = 'notification.type.otherSuppResearchOutput';
}
if ($suppFile->getData('type') == 'Progress Report') {
$message = 'notification.type.progressReport';
}
if ($suppFile->getData('type') == 'Completion Report') {
$message = 'notification.type.completionReport';
}
if ($suppFile->getData('type') == 'Extension Request') {
$message = 'notification.type.extensionRequest';
}
if ($this->getData('type') == "Supp File") {
$message = 'notification.type.suppFile';
}
if (isset($message)) {
foreach ($notificationSectionEditors as $userRole) {
$notificationManager->createNotification($userRole['id'], $message, $this->article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUPP_FILE_MODIFIED);
}
}
return $this->suppFileId;
}
示例8: uploadReviewForReviewer
/**
* Upload a review on behalf of its reviewer.
* @param $reviewId int
*/
function uploadReviewForReviewer($reviewId, $article, $request)
{
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$user =& $request->getUser();
$reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
$reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true);
if (HookRegistry::call('SectionEditorAction::uploadReviewForReviewer', array(&$reviewAssignment, &$reviewer))) {
return;
}
// Upload the review file.
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($reviewAssignment->getSubmissionId());
// Only upload the file if the reviewer has yet to submit a recommendation
if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
$fileName = 'upload';
if ($articleFileManager->uploadedFileExists($fileName)) {
if ($reviewAssignment->getReviewerFileId() != null) {
$fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
} else {
$fileId = $articleFileManager->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('classes.article.log.ArticleLog');
ArticleLog::logEvent($request, $article, ARTICLE_LOG_REVIEW_FILE_BY_PROXY, 'log.review.reviewFileByProxy', array('reviewerName' => $reviewer->getFullName(), 'round' => $reviewAssignment->getRound(), 'userName' => $user->getFullName(), 'reviewId' => $reviewAssignment->getId()));
}
}
示例9: uploadDecisionFile
function uploadDecisionFile($articleId, $fileName, $decisionId)
{
$journal =& Request::getJournal();
$this->validate($articleId);
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($articleId);
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $articleFileManager->uploadDecisionFile($fileName, $decisionId);
return $fileId;
} else {
$fileId = 0;
return $fileId;
}
}
示例10: execute
/**
* Save changes to the supplementary file.
* @return int the supplementary file ID
*/
function execute($fileName = null, $createRemote = false)
{
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($this->article->getId());
$suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
$fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
import('classes.search.ArticleSearchIndex');
$articleSearchIndex = new ArticleSearchIndex();
if (isset($this->suppFile)) {
parent::execute();
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $this->suppFile->getFileId();
if ($fileId != 0) {
$articleFileManager->uploadSuppFile($fileName, $fileId);
} else {
$fileId = $articleFileManager->uploadSuppFile($fileName);
$this->suppFile->setFileId($fileId);
}
$articleSearchIndex->articleFileChanged($this->article->getId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
}
// Update existing supplementary file
$this->setSuppFileData($this->suppFile);
if ($this->getData('remoteURL')) {
$this->suppFile->setRemoteURL($this->getData('remoteURL'));
}
$suppFileDao->updateSuppFile($this->suppFile);
} else {
// Upload file, if file selected.
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $articleFileManager->uploadSuppFile($fileName);
$articleSearchIndex->articleFileChanged($this->article->getId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
} else {
$fileId = 0;
}
// Insert new supplementary file
$this->suppFile = new SuppFile();
$this->suppFile->setArticleId($this->article->getId());
$this->suppFile->setFileId($fileId);
if ($createRemote) {
$this->suppFile->setRemoteURL(__('common.remoteURL'));
}
parent::execute();
$this->setSuppFileData($this->suppFile);
$suppFileDao->insertSuppFile($this->suppFile);
$this->suppFileId = $this->suppFile->getId();
}
// Index updated metadata.
$articleSearchIndex->suppFileMetadataChanged($this->suppFile);
$articleSearchIndex->articleChangesFinished();
return $this->suppFileId;
}
示例11: suppFileFormExecute
/**
* Hook callback: handle suppfile form execution for completed submissions
* @see Form::execute()
*/
function suppFileFormExecute($hookName, $args)
{
$form =& $args[0];
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$article =& $form->article;
// Notify on successful study updates or errors
import('classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$user =& Request::getUser();
// Dataset metadata: fields stored with article metadata, but provided in suppfile
// form, at point of data deposit, to support data publishing
$article->setData('studyDescription', $form->getData('studyDescription'), $form->getFormLocale());
$article->setData('externalDataCitation', $form->getData('externalDataCitation'), $form->getFormLocale());
$articleDao->updateArticle($article);
// Form executed for completed submissions. Draft studies are created on
// submission completion. A study may or may not exist for this submission.
switch ($form->getData('publishData')) {
case 'none':
// Supplementary file: do not deposit.
if ($form->suppFile->getId()) {
// Suppfile exists & may previously have been flagged for deposit /
// deposited in Dataverse
$dvFileDao =& DAORegistry::getDAO('DataverseFileDAO');
$dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFile->getId(), $article->getId());
if (isset($dvFile)) {
// Remove file from pending deposit (if submission is incomplete) or
// dataset previously deposited
$fileDeleted = $this->deleteFile($dvFile);
if ($fileDeleted) {
$dvFileDao->deleteDataverseFile($dvFile);
}
// Deleting a file may affect study cataloguing information
$dvStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
$study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
if (isset($study)) {
$this->replaceStudyMetadata($article, $study);
}
// Notify
$notificationManager->createTrivialNotification($user->getId(), $fileDeleted ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
}
}
break;
case 'dataverse':
// Deposit file. Create a study, if submission doesn't have one already.
$dvStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
$study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
if (!$study) {
$study = $this->createStudy($article);
}
if (!$study) {
// If study is not created, warn & exit
$notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR);
return false;
}
if (!$form->suppFile->getId()) {
// Suppfile is new, but inserted in db after hook is called. Handle
// insertion here & prevent duplicates in handleSuppFileInsertion() callback
$suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
$form->setSuppFileData($form->suppFile);
$suppFileDao->insertSuppFile($form->suppFile);
$form->suppFileId = $form->suppFile->getId();
$form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
// Add suppfile to study.
$deposited = $this->depositFiles($study, array($form->suppFile));
// File-level metadata may need to be added to study.
$this->replaceStudyMetadata($article, $study);
// & notify:
$notificationManager->createTrivialNotification($user->getId(), $deposited ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
} else {
// Suppfile exists, and uploaded file may be new or a replacement
// (form validator requires file upload if Dataverse option selected).
// Hook is called before suppfile object is updated with details of
// uploaded file, so refresh suppfile object here.
import('classes.file.ArticleFileManager');
$fileName = 'uploadSuppFile';
$articleFileManager = new ArticleFileManager($article->getId());
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $form->suppFile->getFileId();
if ($fileId != 0) {
$articleFileManager->uploadSuppFile($fileName, $fileId);
} else {
$fileId = $articleFileManager->uploadSuppFile($fileName);
$form->suppFile->setFileId($fileId);
}
}
// Store form metadata. It may be used to update study cataloguing information.
$suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
$form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
$form->setSuppFileData($form->suppFile);
$suppFileDao->updateSuppFile($form->suppFile);
// The uploaded file may be new, or it may replace a previously-deposited
// file. If it's a replacement, delete the existing file from Dataverse:
// this prevents orphaned files on the Dataverse side, and filename collisions
// described in https://redmine.hmdc.harvard.edu/issues/3301
$dvFileDao =& DAORegistry::getDAO('DataverseFileDAO');
$dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFileId, $article->getId());
//.........这里部分代码省略.........
示例12: uploadCopyeditVersion
/**
* Upload the copyedited version of an article.
* @param $copyeditorSubmission object
*/
function uploadCopyeditVersion($copyeditorSubmission, $copyeditStage)
{
import("file.ArticleFileManager");
$articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
$copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
if ($copyeditStage == 'initial') {
$signoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getArticleId());
} else {
if ($copyeditStage == 'final') {
$signoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getArticleId());
}
}
// Only allow an upload if they're in the initial or final copyediting
// stages.
if ($copyeditStage == 'initial' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) {
return;
} else {
if ($copyeditStage == 'final' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) {
return;
} else {
if ($copyeditStage != 'initial' && $copyeditStage != 'final') {
return;
}
}
}
$articleFileManager = new ArticleFileManager($copyeditorSubmission->getArticleId());
$user =& Request::getUser();
$fileName = 'upload';
if ($articleFileManager->uploadedFileExists($fileName)) {
HookRegistry::call('CopyeditorAction::uploadCopyeditVersion', array(&$copyeditorSubmission));
if ($signoff->getFileId() != null) {
$fileId = $articleFileManager->uploadCopyeditFile($fileName, $copyeditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL', true));
} else {
$fileId = $articleFileManager->uploadCopyeditFile($fileName);
}
}
if (isset($fileId) && $fileId != 0) {
$signoff->setFileId($fileId);
$signoff->setFileRevision($articleFileDao->getRevisionNumber($fileId));
$signoffDao->updateObject($signoff);
// Add log
import('article.log.ArticleLog');
import('article.log.ArticleEventLogEntry');
$entry = new ArticleEventLogEntry();
$entry->setArticleId($copyeditorSubmission->getArticleId());
$entry->setUserId($user->getId());
$entry->setDateLogged(Core::getCurrentDate());
$entry->setEventType(ARTICLE_LOG_COPYEDIT_COPYEDITOR_FILE);
$entry->setLogMessage('log.copyedit.copyeditorFile');
$entry->setAssocType(ARTICLE_LOG_TYPE_COPYEDIT);
$entry->setAssocId($fileId);
ArticleLog::logEventEntry($copyeditorSubmission->getArticleId(), $entry);
}
}
示例13: suppFileFormExecute
/**
* Hook callback: handle suppfile form execution for completed submissions
* @see Form::execute()
*/
function suppFileFormExecute($hookName, $args)
{
$form =& $args[0];
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$article =& $form->article;
// External data citation: field is article metadata, but provided in
// suppfile form as well, at point of data file deposit, to help support
// data publishing decisions
$article->setData('externalDataCitation', $form->getData('externalDataCitation'), $form->getFormLocale());
$articleDao->updateArticle($article);
// Form executed for completed submissions. Draft studies are created on
// submission completion. A study may or may not exist for this submission.
$dvStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
$dvFileDao =& DAORegistry::getDAO('DataverseFileDAO');
switch ($form->getData('publishData')) {
case 'none':
// Supplementary file: do not deposit.
if (!$form->suppFile->getId()) {
return false;
}
// New suppfile: not in Dataverse
$dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFile->getId(), $article->getId());
if (!isset($dvFile)) {
return false;
}
// Edited suppfile, but not in Dataverse
// Remove the file from Dataverse
$this->deleteFile($dvFile);
// Deleting a file may affect study cataloguing information
$study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
$this->updateStudy($article, $study);
break;
case 'dataverse':
// Deposit file. If needed, insert/update suppfile on behalf of form
$suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
if (!$form->suppFile->getId()) {
// Suppfile is new, but inserted in db after hook is called. Handle
// insertion here & prevent duplicates in handleSuppFileInsertion() callback
$form->setSuppFileData($form->suppFile);
$suppFileDao->insertSuppFile($form->suppFile);
$form->suppFileId = $form->suppFile->getId();
$form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
} else {
// Suppfile exists, but uploaded file may be new, replaced, or non-existent.
// Hook called before suppfile object updated with details of uploaded file,
// so refresh suppfile object here.
import('classes.file.ArticleFileManager');
$fileName = 'uploadSuppFile';
$articleFileManager = new ArticleFileManager($article->getId());
if ($articleFileManager->uploadedFileExists($fileName)) {
$fileId = $form->suppFile->getFileId();
if ($fileId != 0) {
$articleFileManager->uploadSuppFile($fileName, $fileId);
} else {
$fileId = $articleFileManager->uploadSuppFile($fileName);
$form->suppFile->setFileId($fileId);
}
}
// Store form metadata. It may be used to update study cataloguing information.
$form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
$form->setSuppFileData($form->suppFile);
$suppFileDao->updateSuppFile($form->suppFile);
}
// If, at this point, there is no file id, there is nothing to deposit
if (!$form->suppFile->getFileId()) {
return false;
}
$user =& Request::getUser();
import('classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
// Study may not exist, if this is the first file deposited
$study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
if (!isset($study)) {
$study =& $this->createStudy($article);
$notificationManager->createTrivialNotification($user->getId(), isset($study) ? NOTIFICATION_TYPE_DATAVERSE_STUDY_CREATED : NOTIFICATION_TYPE_ERROR);
}
if (!isset($study)) {
return false;
}
// File already in Dataverse?
$dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFile->getId(), $article->getId());
if (isset($dvFile)) {
// File is already in Dataverse. Update study with suppfile metadata.
$studyUpdated = $this->updateStudy($article, $study);
$notificationManager->createTrivialNotification($user->getId(), $studyUpdated ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
} else {
// Add file to study
$fileAdded = $this->addFileToStudy($study, $form->suppFile);
$notificationManager->createTrivialNotification($user->getId(), $fileAdded ? NOTIFICATION_TYPE_DATAVERSE_FILE_ADDED : NOTIFICATION_TYPE_ERROR);
}
break;
}
return false;
}
示例14: uploadReviewerVersion
/**
* Upload the annotated version of an article.
* @param $reviewId int
*/
function uploadReviewerVersion($reviewId)
{
import("file.ArticleFileManager");
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
$articleFileManager = new ArticleFileManager($reviewAssignment->getArticleId());
// Only upload the file if the reviewer has yet to submit a recommendation
// and if review forms are not used
if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
$fileName = 'upload';
if ($articleFileManager->uploadedFileExists($fileName)) {
HookRegistry::call('ReviewerAction::uploadReviewFile', array(&$reviewAssignment));
if ($reviewAssignment->getReviewerFileId() != null) {
$fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
} else {
$fileId = $articleFileManager->uploadReviewFile($fileName);
}
}
}
if (isset($fileId) && $fileId != 0) {
$reviewAssignment->setReviewerFileId($fileId);
$reviewAssignment->stampModified();
$reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
// Add log
import('article.log.ArticleLog');
import('article.log.ArticleEventLogEntry');
$userDao =& DAORegistry::getDAO('UserDAO');
$reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
$entry = new ArticleEventLogEntry();
$entry->setArticleId($reviewAssignment->getArticleId());
$entry->setUserId($reviewer->getId());
$entry->setDateLogged(Core::getCurrentDate());
$entry->setEventType(ARTICLE_LOG_REVIEW_FILE);
$entry->setLogMessage('log.review.reviewerFile');
$entry->setAssocType(ARTICLE_LOG_TYPE_REVIEW);
$entry->setAssocId($reviewAssignment->getId());
ArticleLog::logEventEntry($reviewAssignment->getArticleId(), $entry);
}
}
示例15: uploadCopyeditVersion
/**
* Upload the copyedited version of an article.
* @param $copyeditorSubmission object
* @param $copyeditStage string
* @param $request object
*/
function uploadCopyeditVersion($copyeditorSubmission, $copyeditStage, $request)
{
import('classes.file.ArticleFileManager');
$articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
$copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
if ($copyeditStage == 'initial') {
$signoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId());
} else {
if ($copyeditStage == 'final') {
$signoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId());
}
}
// Only allow an upload if they're in the initial or final copyediting
// stages.
if ($copyeditStage == 'initial' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) {
return;
} else {
if ($copyeditStage == 'final' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) {
return;
} else {
if ($copyeditStage != 'initial' && $copyeditStage != 'final') {
return;
}
}
}
$articleFileManager = new ArticleFileManager($copyeditorSubmission->getId());
$user =& $request->getUser();
$fileName = 'upload';
if ($articleFileManager->uploadedFileExists($fileName)) {
HookRegistry::call('CopyeditorAction::uploadCopyeditVersion', array(&$copyeditorSubmission));
if ($signoff->getFileId() != null) {
$fileId = $articleFileManager->uploadCopyeditFile($fileName, $copyeditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL', true));
} else {
$fileId = $articleFileManager->uploadCopyeditFile($fileName);
}
}
if (isset($fileId) && $fileId != 0) {
$signoff->setFileId($fileId);
$signoff->setFileRevision($articleFileDao->getRevisionNumber($fileId));
$signoffDao->updateObject($signoff);
// Add log
import('classes.article.log.ArticleLog');
ArticleLog::logEvent($request, $copyeditorSubmission, ARTICLE_LOG_COPYEDITOR_FILE, 'log.copyedit.copyeditorFile', array('copyeditorName' => $user->getFullName(), 'fileId' => $fileId));
}
}