classes/file/TemporaryFileManager.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 import('file.PKPTemporaryFileManager');
00020 
00021 class TemporaryFileManager extends PKPTemporaryFileManager {
00026    function TemporaryFileManager() {
00027       parent::PKPTemporaryFileManager();
00028    }
00029 
00036    function paperToTemporaryFile($paperFile, $userId) {
00037       // Get the file extension, then rename the file.
00038       $fileExtension = $this->parseFileExtension($paperFile->getFileName());        
00039 
00040       if (!$this->fileExists($this->filesDir, 'dir')) {
00041          // Try to create destination directory
00042          $this->mkdirtree($this->filesDir);
00043       }
00044 
00045       $newFileName = basename(tempnam($this->filesDir, $fileExtension));
00046       if (!$newFileName) return false;
00047 
00048       if (copy($paperFile->getFilePath(), $this->filesDir . $newFileName)) {
00049          $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
00050          $temporaryFile = new TemporaryFile();
00051 
00052          $temporaryFile->setUserId($userId);
00053          $temporaryFile->setFileName($newFileName);
00054          $temporaryFile->setFileType($paperFile->getFileType());
00055          $temporaryFile->setFileSize($paperFile->getFileSize());
00056          $temporaryFile->setOriginalFileName(TemporaryFileManager::truncateFileName($paperFile->getOriginalFileName(), 127));
00057          $temporaryFile->setDateUploaded(Core::getCurrentDate());
00058 
00059          $temporaryFileDao->insertTemporaryFile($temporaryFile);
00060 
00061          return $temporaryFile;
00062 
00063       } else {
00064          return false;
00065       }
00066    }
00067 }
00068 
00069 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7