/** * Returns an instance of class. * * @return BOL_FileDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Get path to file in file system * * @param int $id * * @return string */ public function getFilePath($id) { $userfilesDir = OW::getPluginManager()->getPlugin('base')->getUserFilesDir(); $file = $this->fileDao->findById($id); return $userfilesDir . $id . $file->filename; }
public function moveTemporaryFile($tmpId, $desc) { $tmp = $this->fileTemporaryDao->findById($tmpId); if (!$tmp) { return false; } $tmpFilePath = $this->getTemporaryFilePath($tmp->id); $fileService = BOL_FileService::getInstance(); $file = new BOL_File(); $file->description = htmlspecialchars(trim($desc)); $file->addDatetime = time(); $file->filename = $tmp->filename; $file->userId = $tmp->userId; BOL_FileDao::getInstance()->save($file); try { copy($tmpFilePath, $fileService->getFilePath($file->id)); } catch (Exception $e) { $photo = null; } return $file; }