-
Notifications
You must be signed in to change notification settings - Fork 8
/
SwordSubmissionFileManager.inc.php
49 lines (43 loc) · 1.61 KB
/
SwordSubmissionFileManager.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @file SwordSubmissionFileManager.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class SwordSubmissionFileManager
* @ingroup file
*
* @brief Extends SubmissionFileManager to support submission
* files arriving in the POST body (i.e., not in $_FILES)
*
*/
import('lib.pkp.classes.submission.SubmissionFile');
import('lib.pkp.classes.file.SubmissionFileManager');
class SwordSubmissionFileManager extends SubmissionFileManager {
/**
* @copydoc FileManager::getUploadedFileType()
*/
function getUploadedFileType($fileName) {
$type = PKPString::mime_content_type($fileName);
if (!empty($type)) return $type;
return false;
}
/**
* @copydoc SubmissionFileManager::_handleUpload()
*/
function _handleUpload($fileName, $fileStage, $uploaderUserId,
$revisedFileId = null, $genreId = null, $assocType = null, $assocId = null) {
$sourceFile = ini_get('upload_tmp_dir') . '/' . $fileName;
$submissionFile = $this->_instantiateSubmissionFile($sourceFile, $fileStage, $revisedFileId, $genreId, $assocType, $assocId);
if (is_null($submissionFile)) return null;
$fileType = $this->getUploadedFileType($sourceFile);
assert($fileType !== false);
$submissionFile->setFileType($fileType);
$submissionFile->setOriginalFileName($this->truncateFileName($fileName));
$submissionFile->setUploaderUserId($uploaderUserId);
$submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
return $submissionFileDao->insertObject($submissionFile, $sourceFile, false);
}
}