00001 <?php
00002
00017 import('lib.pkp.classes.file.PKPTemporaryFileManager');
00018
00019 class TemporaryFileManager extends PKPTemporaryFileManager {
00024 function TemporaryFileManager() {
00025 parent::PKPTemporaryFileManager();
00026 }
00027
00034 function monographToTemporaryFile($monographFile, $userId) {
00035
00036 $fileExtension = $this->parseFileExtension($monographFile->getFileName());
00037
00038 if (!$this->fileExists($this->filesDir, 'dir')) {
00039
00040 $this->mkdirtree($this->filesDir);
00041 }
00042
00043 $newFileName = basename(tempnam($this->filesDir, $fileExtension));
00044 if (!$newFileName) return false;
00045
00046 if (copy($monographFile->getFilePath(), $this->filesDir . $newFileName)) {
00047 $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
00048 $temporaryFile = $temporaryFileDao->newDataObject();
00049
00050 $temporaryFile->setUserId($userId);
00051 $temporaryFile->setFileName($newFileName);
00052 $temporaryFile->setFileType($monographFile->getFileType());
00053 $temporaryFile->setFileSize($monographFile->getFileSize());
00054 $temporaryFile->setOriginalFileName($monographFile->getOriginalFileName());
00055 $temporaryFile->setDateUploaded(Core::getCurrentDate());
00056
00057 $temporaryFileDao->insertTemporaryFile($temporaryFile);
00058
00059 return $temporaryFile;
00060
00061 } else {
00062 return false;
00063 }
00064 }
00065 }
00066
00067 ?>