• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/file/TemporaryFileManager.inc.php

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       // Get the file extension, then rename the file.
00036       $fileExtension = $this->parseFileExtension($monographFile->getFileName());
00037 
00038       if (!$this->fileExists($this->filesDir, 'dir')) {
00039          // Try to create destination directory
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 ?>

Generated on Mon Sep 17 2012 13:00:00 for Open Monograph Press by  doxygen 1.7.1