/** * Extract and validate a plugin (prior to installation) * @param $filePath string Full path to plugin archive * @param $originalFileName string Original filename of plugin archive * @return string|null Extracted plugin path on success; null on error */ function extractPlugin($filePath, $originalFileName, &$errorMsg) { $fileManager = new FileManager(); // tar archive basename (less potential version number) must // equal plugin directory name and plugin files must be in a // directory named after the plug-in (potentially with version) $matches = array(); PKPString::regexp_match_get('/^[a-zA-Z0-9]+/', basename($originalFileName, '.tar.gz'), $matches); $pluginShortName = array_pop($matches); if (!$pluginShortName) { $errorMsg = __('manager.plugins.invalidPluginArchive'); $fileManager->deleteFile($filePath); return null; } // Create random dirname to avoid symlink attacks. $pluginExtractDir = dirname($filePath) . DIRECTORY_SEPARATOR . $pluginShortName . substr(md5(mt_rand()), 0, 10); mkdir($pluginExtractDir); // Test whether the tar binary is available for the export to work $tarBinary = Config::getVar('cli', 'tar'); if (!empty($tarBinary) && file_exists($tarBinary)) { exec($tarBinary . ' -xzf ' . escapeshellarg($filePath) . ' -C ' . escapeshellarg($pluginExtractDir)); } else { $errorMsg = __('manager.plugins.tarCommandNotFound'); } $fileManager->deleteFile($filePath); if (empty($errorMsg)) { // Look for a directory named after the plug-in's short // (alphanumeric) name within the extracted archive. if (is_dir($tryDir = $pluginExtractDir . '/' . $pluginShortName)) { return $tryDir; // Success } // Failing that, look for a directory named after the // archive. (Typically also contains the version number // e.g. with github generated release archives.) PKPString::regexp_match_get('/^[a-zA-Z0-9.-]+/', basename($originalFileName, '.tar.gz'), $matches); if (is_dir($tryDir = $pluginExtractDir . '/' . array_pop($matches))) { // We found a directory named after the archive // within the extracted archive. (Typically also // contains the version number, e.g. github // generated release archives.) return $tryDir; } $errorMsg = __('manager.plugins.invalidPluginArchive'); } $fileManager->rmtree($pluginExtractDir); return null; }
/** * Delete a file by ID. * @param $fileId int * @return int number of files removed */ function deleteFile($fileId) { $libraryFileDao =& DAORegistry::getDAO('LibraryFileDAO'); $libraryFile =& $libraryFileDao->getById($fileId); parent::deleteFile($this->filesDir . $libraryFile->getFileName()); $libraryFileDao->deleteById($fileId); }
/** * Delete a file by ID. * @param $fileId int * @return int number of files removed */ function deleteFile($fileId) { $minutesFileDao =& DAORegistry::getDAO('MinutesFileDAO'); $file =& $minutesFileDao->getMinutesFile($fileId); parent::deleteFile($this->filesDir . $file->getType() . '/' . $file->getFileName()); return $minutesFileDao->deleteMinutesFileById($fileId); }
/** * Delete a file by ID. * @param $fileId int */ function deleteFile($fileId, $userId) { $temporaryFile =& $this->getFile($fileId, $userId); parent::deleteFile($this->filesDir . $temporaryFile->getFileName()); $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFileDao->deleteTemporaryFileById($fileId, $userId); }
/** * Delete a file by ID. * @param $fileId int */ function deleteAboutFile($fileId) { if ($fileId != 0) { $aboutFile =& $this->getFile($fileId); parent::deleteFile($this->filesDir . $aboutFile->getFileName()); $aboutFileDao =& DAORegistry::getDAO('AboutFileDAO'); $aboutFileDao->deleteAboutFileById($fileId); } }
/** * Delete an issue file by ID. * @param $fileId int * @return boolean if successful */ function deleteFile($fileId) { $issueFileDao = DAORegistry::getDAO('IssueFileDAO'); $issueFile = $issueFileDao->getById($fileId); if (parent::deleteFile($this->getFilesDir() . $this->contentTypeToPath($issueFile->getContentType()) . '/' . $issueFile->getFileName())) { $issueFileDao->deleteById($fileId); return true; } return false; }
function _cacheMiss(&$cache, $id) { $allCodelistItems =& Registry::get('all' . $this->getListName() . 'CodelistItems', true, null); if ($allCodelistItems === null) { // Add a locale load to the debug notes. $notes =& Registry::get('system.debug.notes'); $locale = $cache->cacheId; if ($locale == null) { $locale = AppLocale::getLocale(); } $filename = $this->getFilename($locale); $notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename)); // Reload locale registry file $xmlDao = new XMLDAO(); $listName =& $this->getListName(); // i.e., 'List30' import('lib.pkp.classes.codelist.ONIXParserDOMHandler'); $handler = new ONIXParserDOMHandler($listName); import('lib.pkp.classes.xslt.XSLTransformer'); import('lib.pkp.classes.file.FileManager'); import('classes.file.TemporaryFileManager'); $temporaryFileManager = new TemporaryFileManager(); $fileManager = new FileManager(); $tmpName = tempnam($temporaryFileManager->getBasePath(), 'ONX'); $xslTransformer = new XSLTransformer(); $xslTransformer->setParameters(array('listName' => $listName)); $xslTransformer->setRegisterPHPFunctions(true); $xslFile = 'lib/pkp/xml/onixFilter.xsl'; $filteredXml = $xslTransformer->transform($filename, XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING); if (!$filteredXml) { assert(false); } $data = null; if (is_writeable($tmpName)) { $fp = fopen($tmpName, 'wb'); fwrite($fp, $filteredXml); fclose($fp); $data = $xmlDao->parseWithHandler($tmpName, $handler); $fileManager->deleteFile($tmpName); } else { fatalError('misconfigured directory permissions on: ' . $temporaryFileManager->getBasePath()); } // Build array with ($charKey => array(stuff)) if (isset($data[$listName])) { foreach ($data[$listName] as $code => $codelistData) { $allCodelistItems[$code] = $codelistData; } } if (is_array($allCodelistItems)) { asort($allCodelistItems); } $cache->setEntireCache($allCodelistItems); } return null; }
/** * Delete a submission file from the database. * @param $submissionFile SubmissionFile * @return boolean */ function deleteObject($submissionFile) { if (!$this->update('DELETE FROM submission_files WHERE file_id = ? AND revision = ?', array((int) $submissionFile->getFileId(), (int) $submissionFile->getRevision()))) { return false; } // if we've removed the last revision of this file, clean up // the settings for this file as well. $result = $this->retrieve('SELECT * FROM submission_files WHERE file_id = ?', array((int) $submissionFile->getFileId())); if ($result->RecordCount() == 0) { $this->update('DELETE FROM submission_file_settings WHERE file_id = ?', array((int) $submissionFile->getFileId())); } // Delete all dependent objects. $this->_deleteDependentObjects($submissionFile); // Delete the file on the file system, too. $filePath = $submissionFile->getFilePath(); if (!(is_file($filePath) && is_readable($filePath))) { return false; } assert(is_writable(dirname($filePath))); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $fileManager->deleteFile($filePath); return !file_exists($filePath); }
/** * Constructor. * @param $argv array task arguments */ function UsageStatsLoader($args) { $plugin =& PluginRegistry::getPlugin('generic', 'usagestatsplugin'); /* @var $plugin UsageStatsPlugin */ $this->_plugin =& $plugin; $arg = current($args); switch ($arg) { case 'autoStage': if ($plugin->getSetting(0, 'createLogFiles')) { $this->_autoStage = true; } break; case 'externalLogFiles': $this->_externalLogFiles = true; break; } // Define the base filesystem path. $args[0] = $plugin->getFilesPath(); parent::FileLoader($args); if ($plugin->getEnabled()) { // Load the metric type constant. PluginRegistry::loadCategory('reports'); $geoLocationTool =& StatisticsHelper::getGeoLocationTool(); $this->_geoLocationTool =& $geoLocationTool; $plugin->import('UsageStatsTemporaryRecordDAO'); $statsDao = new UsageStatsTemporaryRecordDAO(); DAORegistry::registerDAO('UsageStatsTemporaryRecordDAO', $statsDao); $this->_counterRobotsListFile = $this->_getCounterRobotListFile(); $journalDao =& DAORegistry::getDAO('JournalDAO'); /* @var $journalDao JournalDAO */ $journalFactory =& $journalDao->getJournals(); /* @var $journalFactory DAOResultFactory */ $journalsByPath = array(); while ($journal =& $journalFactory->next()) { /* @var $journal Journal */ $journalsByPath[$journal->getPath()] =& $journal; } $this->_journalsByPath = $journalsByPath; $this->checkFolderStructure(true); if ($this->_autoStage) { // Copy all log files to stage directory, except the current day one. $fileMgr = new FileManager(); $logFiles = array(); $logsDirFiles = glob($plugin->getUsageEventLogsPath() . DIRECTORY_SEPARATOR . '*'); // It's possible that the processing directory have files that // were being processed but the php process was stopped before // finishing the processing. Just copy them to the stage directory too. $processingDirFiles = glob($this->getProcessingPath() . DIRECTORY_SEPARATOR . '*'); if (is_array($logsDirFiles)) { $logFiles = array_merge($logFiles, $logsDirFiles); } if (is_array($processingDirFiles)) { $logFiles = array_merge($logFiles, $processingDirFiles); } foreach ($logFiles as $filePath) { // Make sure it's a file. if ($fileMgr->fileExists($filePath)) { // Avoid current day file. $filename = pathinfo($filePath, PATHINFO_BASENAME); $currentDayFilename = $plugin->getUsageEventCurrentDayLogName(); if ($filename == $currentDayFilename) { continue; } if ($fileMgr->copyFile($filePath, $this->getStagePath() . DIRECTORY_SEPARATOR . $filename)) { $fileMgr->deleteFile($filePath); } } } } } }
function fileDelete($args) { FilesHandler::parseDirArg($args, $currentDir, $parentDir); $currentPath = FilesHandler::getRealFilesDir($currentDir); import('lib.pkp.classes.file.FileManager'); $fileMgr = new FileManager(); if (@is_file($currentPath)) { $fileMgr->deleteFile($currentPath); } else { // TODO Use recursive delete (rmtree) instead? @$fileMgr->rmdir($currentPath); } Request::redirect(null, null, 'files', explode('/', $parentDir)); }
/** * Copy the passed file, filtering entries * related to this installation. * @param $filePath string */ function _copyFile($filePath) { $usageStatsFiles = $this->_usageStatsFiles; $usageStatsDir = $this->_usageStatsDir; $tmpDir = $this->_tmpDir; $fileName = pathinfo($filePath, PATHINFO_BASENAME); $fileMgr = new FileManager(); $isCompressed = false; $uncompressedFileName = $fileName; if (pathinfo($filePath, PATHINFO_EXTENSION) == 'gz') { $isCompressed = true; $uncompressedFileName = substr($fileName, 0, -3); } if (in_array($uncompressedFileName, $usageStatsFiles)) { printf(__('admin.copyAccessLogFileTool.warning.fileAlreadyExists', array('filePath' => $filePath)) . "\n"); return; } $tmpFilePath = $tmpDir . DIRECTORY_SEPARATOR . $fileName; // Copy the file to a temporary directory. if (!$fileMgr->copyFile($filePath, $tmpFilePath)) { printf(__('admin.copyAccessLogFileTool.error.copyingFile', array('filePath' => $filePath, 'tmpFilePath' => $tmpFilePath)) . "\n"); exit(1); } // Uncompress it, if needed. if ($isCompressed) { $fileMgr = new FileManager(); $errorMsg = null; if (!($tmpFilePath = $fileMgr->decompressFile($tmpFilePath, $errorMsg))) { printf($errorMsg . "\n"); exit(1); } } // Filter only entries that contains context paths. $egrepPath = $this->_egrepPath; $destinationPath = $usageStatsDir . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_STAGING . DIRECTORY_SEPARATOR . pathinfo($tmpFilePath, PATHINFO_BASENAME); // Each context path is already escaped, see the constructor. $output = null; $returnValue = 0; exec($egrepPath . " -i '" . $this->_contextPaths . "' " . escapeshellarg($tmpFilePath) . " > " . escapeshellarg($destinationPath), $output, $returnValue); if ($returnValue > 1) { printf(__('admin.error.executingUtil', array('utilPath' => $egrepPath, 'utilVar' => 'egrep')) . "\n"); exit(1); } if (!$fileMgr->deleteFile($tmpFilePath)) { printf(__('admin.copyAccessLogFileTool.error.deletingFile', array('tmpFilePath' => $tmpFilePath)) . "\n"); exit(1); } printf(__('admin.copyAccessLogFileTool.success', array('filePath' => $filePath, 'destinationPath' => $destinationPath)) . "\n"); }
/** * Copy the passed file, filtering entries * related to this installation. * @param $filePath string */ function _copyFile($filePath) { $usageStatsFiles = $this->_usageStatsFiles; $usageStatsDir = $this->_usageStatsDir; $tmpDir = $this->_tmpDir; $fileName = pathinfo($filePath, PATHINFO_BASENAME); $fileMgr = new FileManager(); $isCompressed = false; $uncompressedFileName = $fileName; if (pathinfo($filePath, PATHINFO_EXTENSION) == 'gz') { $isCompressed = true; $uncompressedFileName = substr($fileName, 0, -3); } if (in_array($uncompressedFileName, $usageStatsFiles)) { printf(__('admin.copyAccessLogFileTool.warning.fileAlreadyExists', array('filePath' => $filePath)) . "\n"); return; } $tmpFilePath = $tmpDir . DIRECTORY_SEPARATOR . $fileName; // Copy the file to a temporary directory. if (!$fileMgr->copyFile($filePath, $tmpFilePath)) { printf(__('admin.copyAccessLogFileTool.error.copyingFile', array('filePath' => $filePath, 'tmpFilePath' => $tmpFilePath)) . "\n"); exit(1); } // Uncompress it, if needed. $gunzipPath = escapeshellarg(Config::getVar('cli', 'gunzip')); if ($isCompressed) { exec($gunzipPath . ' ' . $tmpFilePath); $tmpFilePath = substr($tmpFilePath, 0, -3); } // Filter only entries that contains journal paths. $egrepPath = escapeshellarg(Config::getVar('cli', 'egrep')); $destinationPath = $usageStatsDir . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_STAGING . DIRECTORY_SEPARATOR . pathinfo($tmpFilePath, PATHINFO_BASENAME); // Each journal path is already escaped, see the constructor. exec($egrepPath . " -i '" . $this->_journalPaths . "' " . escapeshellarg($tmpFilePath) . " > " . escapeshellarg($destinationPath)); if (!$fileMgr->deleteFile($tmpFilePath)) { printf(__('admin.copyAccessLogFileTool.error.deletingFile', array('tmpFilePath' => $tmpFilePath)) . "\n"); exit(1); } printf(__('admin.copyAccessLogFileTool.success', array('filePath' => $filePath, 'destinationPath' => $destinationPath)) . "\n"); }
/** * Execute import/export tasks using the command-line interface. * @param $args Parameters to the plugin */ function executeCLI($scriptName, &$args) { AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON); $filename = array_shift($args); $username = array_shift($args); if (!$filename || !$username) { $this->usage($scriptName); exit; } if (!file_exists($filename)) { echo __('plugins.importexport.csv.fileDoesNotExist', array('filename' => $filename)) . "\n"; exit; } $data = file($filename); if (is_array($data) && count($data) > 0) { $userDao = DAORegistry::getDAO('UserDAO'); $user = $userDao->getByUsername($username); if (!$user) { echo __('plugins.importexport.csv.unknownUser', array('username' => $username)) . "\n"; exit; } $submissionDao = Application::getSubmissionDAO(); $authorDao = DAORegistry::getDAO('AuthorDAO'); $pressDao = Application::getContextDAO(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $seriesDao = DAORegistry::getDAO('SeriesDAO'); $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO'); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); import('lib.pkp.classes.submission.SubmissionFile'); // constants. $genreDao = DAORegistry::getDAO('GenreDAO'); $publicationDateDao = DAORegistry::getDAO('PublicationDateDAO'); foreach ($data as $csvLine) { // Format is: // Press Path, Author string, title, series path, year, is_edited_volume, locale, URL to PDF, doi (optional) list($pressPath, $authorString, $title, $seriesPath, $year, $isEditedVolume, $locale, $pdfUrl, $doi) = preg_split('/\\t/', $csvLine); $press = $pressDao->getByPath($pressPath); if ($press) { $supportedLocales = $press->getSupportedSubmissionLocales(); if (!is_array($supportedLocales) || count($supportedLocales) < 1) { $supportedLocales = array($press->getPrimaryLocale()); } $authorGroup = $userGroupDao->getDefaultByRoleId($press->getId(), ROLE_ID_AUTHOR); // we need a Genre for the files. Assume a key of MANUSCRIPT as a default. $genre = $genreDao->getByKey('MANUSCRIPT', $press->getId()); if (!$genre) { echo __('plugins.importexport.csv.noGenre') . "\n"; exit; } if (!$authorGroup) { echo __('plugins.importexport.csv.noAuthorGroup', array('press' => $pressPath)) . "\n"; continue; } if (in_array($locale, $supportedLocales)) { $submission = $submissionDao->newDataObject(); $submission->setContextId($press->getId()); $submission->setUserId($user->getId()); $submission->stampStatusModified(); $submission->setStatus(STATUS_PUBLISHED); $submission->setWorkType($isEditedVolume == 1 ? WORK_TYPE_EDITED_VOLUME : WORK_TYPE_AUTHORED_WORK); $submission->setCopyrightNotice($press->getLocalizedSetting('copyrightNotice'), $locale); $submission->setLocale($locale); $series = $seriesDao->getByPath($seriesPath, $press->getId()); if ($series) { $submission->setSeriesId($series->getId()); } else { echo __('plugins.importexport.csv.noSeries', array('seriesPath' => $seriesPath)) . "\n"; } $submissionId = $submissionDao->insertObject($submission); $contactEmail = $press->getContactEmail(); $authorString = trim($authorString, '"'); // remove double quotes if present. $authors = preg_split('/,\\s*/', $authorString); $firstAuthor = true; foreach ($authors as $authorString) { // Examine the author string. Best case is: First1 Last1 <*****@*****.**>, First2 Last2 <*****@*****.**>, etc // But default to press email address based on press path if not present. $firstName = $lastName = $emailAddress = null; $authorString = trim($authorString); // whitespace. if (preg_match('/^(\\w+)(\\s+\\w+)?\\s*(<([^>]+)>)?$/', $authorString, $matches)) { $firstName = $matches[1]; // Mandatory if (count($matches) > 2) { $lastName = $matches[2]; } if (count($matches) == 5) { $emailAddress = $matches[4]; } else { $emailAddress = $contactEmail; } } $author = $authorDao->newDataObject(); $author->setSubmissionId($submissionId); $author->setUserGroupId($authorGroup->getId()); $author->setFirstName($firstName); $author->setLastName($lastName); $author->setEmail($emailAddress); if ($firstAuthor) { $author->setPrimaryContact(1); $firstAuthor = false; } $authorDao->insertObject($author); } // Authors done. $submission->setTitle($title, $locale); $submissionDao->updateObject($submission); // Submission is done. Create a publication format for it. $publicationFormat = $publicationFormatDao->newDataObject(); $publicationFormat->setPhysicalFormat(false); $publicationFormat->setIsApproved(true); $publicationFormat->setIsAvailable(true); $publicationFormat->setSubmissionId($submissionId); $publicationFormat->setProductAvailabilityCode('20'); // ONIX code for Available. $publicationFormat->setEntryKey('DA'); // ONIX code for Digital $publicationFormat->setData('name', 'PDF', $submission->getLocale()); $publicationFormat->setSequence(REALLY_BIG_NUMBER); $publicationFormatId = $publicationFormatDao->insertObject($publicationFormat); if ($doi) { $publicationFormat->setStoredPubId('doi', $doi); } $publicationFormatDao->updateObject($publicationFormat); // Create a publication format date for this publication format. $publicationDate = $publicationDateDao->newDataObject(); $publicationDate->setDateFormat('05'); // List55, YYYY $publicationDate->setRole('01'); // List163, Publication Date $publicationDate->setDate($year); $publicationDate->setPublicationFormatId($publicationFormatId); $publicationDateDao->insertObject($publicationDate); // Submission File. import('lib.pkp.classes.file.TemporaryFileManager'); import('lib.pkp.classes.file.FileManager'); $temporaryFileManager = new TemporaryFileManager(); $temporaryFilename = tempnam($temporaryFileManager->getBasePath(), 'remote'); $temporaryFileManager->copyFile($pdfUrl, $temporaryFilename); $submissionFile = $submissionFileDao->newDataObjectByGenreId($genre->getId()); $submissionFile->setSubmissionId($submissionId); $submissionFile->setGenreId($genre->getId()); $submissionFile->setFileStage(SUBMISSION_FILE_PROOF); $submissionFile->setDateUploaded(Core::getCurrentDate()); $submissionFile->setDateModified(Core::getCurrentDate()); $submissionFile->setAssocType(ASSOC_TYPE_REPRESENTATION); $submissionFile->setAssocId($publicationFormatId); $submissionFile->setFileType('application/pdf'); // Assume open access, no price. $submissionFile->setDirectSalesPrice(0); $submissionFile->setSalesType('openAccess'); $submissionFileDao->insertObject($submissionFile, $temporaryFilename); $fileManager = new FileManager(); $fileManager->deleteFile($temporaryFilename); echo __('plugins.importexport.csv.import.submission', array('title' => $title)) . "\n"; } else { echo __('plugins.importexport.csv.unknownLocale', array('locale' => $locale)) . "\n"; } } else { echo __('plugins.importexport.csv.unknownPress', array('pressPath' => $pressPath)) . "\n"; } } } }
/** * Internal function to write the pdf of a published researt. * @param $sectionEditorSubmission SectionEditorSubmission * @return bool */ function _publishResearch($sectionEditorSubmission) { $completionReport = $sectionEditorSubmission->getLastReportFile(); if ($completionReport->getFileType() == "application/pdf") { $coverPath = SectionEditorAction::_generateCover($sectionEditorSubmission); if ($coverPath && $coverPath != '') { import('classes.lib.TCPDFMerger'); $file2merge = array($coverPath . 'tempCover.pdf', $completionReport->getFilePath()); $pdf = new TCPDFMerger(); $pdf->setFiles($file2merge); $pdf->concat(); $fileName = $sectionEditorSubmission->getProposalId() . '-Final_Technical_Report.pdf'; $pdf->Output($coverPath . $fileName, "F"); FileManager::deleteFile($coverPath . 'tempCover.pdf'); if (file_exists($coverPath . $fileName)) { //import('classes.article.ArticleFile'); $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO'); $technicalReport = new ArticleFile(); $technicalReport->setArticleId($sectionEditorSubmission->getArticleId()); $technicalReport->setFileName($fileName); $technicalReport->setFileType('application/pdf'); $technicalReport->setFileSize(filesize($coverPath . $fileName)); $technicalReport->setOriginalFileName($fileName); $technicalReport->setType('public'); $technicalReport->setDateUploaded(Core::getCurrentDate()); $technicalReport->setDateModified(Core::getCurrentDate()); $fileId = $articleFileDao->insertArticleFile($technicalReport); return $fileId; } } } return false; }
/** * Protected method to retrieve submission file revisions * according to the given filters. * @param $submissionId int * @param $fileStage int * @param $fileId int * @param $revision int * @param $assocType integer * @param $assocId integer * @param $latestOnly boolean * @return boolean */ function _deleteInternally($submissionId = null, $fileStage = null, $fileId = null, $revision = null, $assocType = null, $assocId = null, $latestOnly = false) { // Identify all matched files. $deletedFiles =& $this->_getInternally($submissionId, $fileStage, $fileId, $revision, $assocType, $assocId, $latestOnly); if (empty($deletedFiles)) { return 0; } $filterClause = ''; $conjunction = ''; $params = array(); foreach ($deletedFiles as $deletedFile) { /* @var $deletedFile SubmissionFile */ // Delete the the matched files on the file system. FileManager::deleteFile($deletedFile->getFilePath()); // Delete file in the database. // NB: We cannot safely bulk-delete because MySQL 3.23 // does not support multi-column IN-clauses. Same is true // for multi-table access or subselects in the DELETE // statement. And having a long (... AND ...) OR (...) // clause could hit length limitations. $daoDelegate =& $this->_getDaoDelegateForObject($deletedFile); $daoDelegate->deleteObject($deletedFile); } // Return the number of deleted files. return count($deletedFiles); }
/** * For 3.0.0 upgrade. Migrates submission files to new paths. */ function migrateSubmissionFilePaths() { $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); import('lib.pkp.classes.submission.SubmissionFile'); $genreDao = DAORegistry::getDAO('GenreDAO'); $journalDao = DAORegistry::getDAO('JournalDAO'); $submissionFile = new SubmissionFile(); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $articleFilesResult = $submissionFileDao->retrieve('SELECT af.*, s.submission_id, s.context_id FROM article_files_migration af, submissions s WHERE af.article_id = s.submission_id'); $filesDir = Config::getVar('files', 'files_dir') . '/journals/'; while (!$articleFilesResult->EOF) { $row = $articleFilesResult->GetRowAssoc(false); // Assemble the old file path. $oldFilePath = $filesDir . $row['context_id'] . '/articles/' . $row['submission_id'] . '/'; if (isset($row['type'])) { // pre 2.4 upgrade. $oldFilePath .= $row['type']; } else { // post 2.4, we have file_stage instead. switch ($row['file_stage']) { case 1: $oldFilePath .= 'submission/original'; break; case 2: $oldFilePath .= 'submission/review'; break; case 3: $oldFilePath .= 'submission/editor'; break; case 4: $oldFilePath .= 'submission/copyedit'; break; case 5: $oldFilePath .= 'submission/layout'; break; case 6: $oldFilePath .= 'supp'; break; case 7: $oldFilePath .= 'public'; break; case 8: $oldFilePath .= 'note'; break; case 9: $oldFilePath .= 'attachment'; break; } } $oldFilePath .= '/' . $row['file_name']; if (file_exists($oldFilePath)) { // sanity check. $newFilePath = $filesDir . $row['context_id'] . '/articles/' . $row['submission_id'] . '/'; // Since we cannot be sure that we had a file_stage column before, query the new submission_files table. $submissionFileResult = $submissionFileDao->retrieve('SELECT genre_id, file_stage, date_uploaded, original_file_name FROM submission_files WHERE file_id = ? and revision = ?', array($row['file_id'], $row['revision'])); $submissionFileRow = $submissionFileResult->GetRowAssoc(false); $newFilePath .= $submissionFile->_fileStageToPath($submissionFileRow['file_stage']); $genre = $genreDao->getById($submissionFileRow['genre_id']); // pull in the primary locale for this journal without loading the whole object. $localeResult = $journalDao->retrieve('SELECT primary_locale FROM journals WHERE journal_id = ?', array($row['context_id'])); $localeRow = $localeResult->GetRowAssoc(false); $newFilePath .= '/' . $row['submission_id'] . '-' . $genre->getDesignation() . '_' . $genre->getName($localeRow['primary_locale']) . '-' . $row['file_id'] . '-' . $row['revision'] . '-' . $submissionFileRow['file_stage'] . '-' . date('Ymd', strtotime($submissionFileRow['date_uploaded'])) . '.' . strtolower_codesafe($fileManager->parseFileExtension($submissionFileRow['original_file_name'])); $fileManager->copyFile($oldFilePath, $newFilePath); if (file_exists($newFilePath)) { $fileManager->deleteFile($oldFilePath); } } $articleFilesResult->MoveNext(); unset($localeResult); unset($submissionFileResult); unset($localeRow); unset($submissionFileRow); } return true; }
/** * Delete a file by ID. * If no revision is specified, all revisions of the file are deleted. * @param $fileId int * @param $revision int (optional) * @return int number of files removed */ function deleteFile($fileId, $revision = null) { $paperFileDao =& DAORegistry::getDAO('PaperFileDAO'); $files = array(); if (isset($revision)) { $file =& $paperFileDao->getPaperFile($fileId, $revision); if (isset($file)) { $files[] = $file; } } else { $files =& $paperFileDao->getPaperFileRevisions($fileId); } foreach ($files as $f) { parent::deleteFile($this->filesDir . $f->getType() . '/' . $f->getFileName()); } $paperFileDao->deletePaperFileById($fileId, $revision); return count($files); }
/** * Resize cover thumnails for all given press objects (categories, series and published monographs). * @param $context Context * @param $objectDao CategoriesDAO, SeriesDAO or PublishedMonographsDAO * @param $coverThumbnailsMaxWidth int * @param $coverThumbnailsMaxHeight int * @param $basePath string Base path for the given object */ function _resizeCoverThumbnails($context, $objectDao, $coverThumbnailsMaxWidth, $coverThumbnailsMaxHeight, $basePath) { import('classes.file.SimpleMonographFileManager'); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $objects = $objectDao->getByPressId($context->getId()); while ($object = $objects->next()) { if (is_a($object, 'PublishedMonograph')) { $cover = $object->getCoverImage(); $simpleMonographFileManager = new SimpleMonographFileManager($context->getId(), $object->getId()); $basePath = $simpleMonographFileManager->getBasePath(); } else { $cover = $object->getImage(); } if ($cover) { // delete old cover thumbnail $fileManager->deleteFile($basePath . $cover['thumbnailName']); // get settings necessary for the new thumbnail $coverExtension = $fileManager->getExtension($cover['name']); $xRatio = min(1, $coverThumbnailsMaxWidth / $cover['width']); $yRatio = min(1, $coverThumbnailsMaxHeight / $cover['height']); $ratio = min($xRatio, $yRatio); $thumbnailWidth = round($ratio * $cover['width']); $thumbnailHeight = round($ratio * $cover['height']); // create a thumbnail image of the defined size $thumbnail = imagecreatetruecolor($thumbnailWidth, $thumbnailHeight); // generate the image of the original cover switch ($coverExtension) { case 'jpg': $coverImage = imagecreatefromjpeg($basePath . $cover['name']); break; case 'png': $coverImage = imagecreatefrompng($basePath . $cover['name']); break; case 'gif': $coverImage = imagecreatefromgif($basePath . $cover['name']); break; default: $coverImage = null; // Suppress warn } assert($coverImage); // copy the cover image to the thumbnail imagecopyresampled($thumbnail, $coverImage, 0, 0, 0, 0, $thumbnailWidth, $thumbnailHeight, $cover['width'], $cover['height']); // create the thumbnail file switch ($coverExtension) { case 'jpg': imagejpeg($thumbnail, $basePath . $cover['thumbnailName']); break; case 'png': imagepng($thumbnail, $basePath . $cover['thumbnailName']); break; case 'gif': imagegif($thumbnail, $basePath . $cover['thumbnailName']); break; } imagedestroy($thumbnail); if (is_a($object, 'PublishedMonograph')) { $object->setCoverImage(array('name' => $cover['name'], 'width' => $cover['width'], 'height' => $cover['height'], 'thumbnailName' => $cover['thumbnailName'], 'thumbnailWidth' => $thumbnailWidth, 'thumbnailHeight' => $thumbnailHeight, 'catalogName' => $cover['catalogName'], 'catalogWidth' => $cover['v'], 'catalogHeight' => $cover['catalogHeight'], 'uploadName' => $cover['uploadName'], 'dateUploaded' => $cover['dateUploaded'])); } else { $object->setImage(array('name' => $cover['name'], 'width' => $cover['width'], 'height' => $cover['height'], 'thumbnailName' => $cover['thumbnailName'], 'thumbnailWidth' => $thumbnailWidth, 'thumbnailHeight' => $thumbnailHeight, 'uploadName' => $cover['uploadName'], 'dateUploaded' => $cover['dateUploaded'])); } // Update category object to store new thumbnail information. $objectDao->updateObject($object); } unset($object); } }
/** * @copydoc PubObjectsExportPlugin::executeExportAction() */ function executeExportAction($request, $objects, $filter, $tab, $objectsFileNamePart) { $context = $request->getContext(); $path = array('plugin', $this->getName()); if ($request->getUserVar(EXPORT_ACTION_DEPOSIT)) { assert($filter != null); // Get the XML $exportXml = $this->exportXML($objects, $filter, $context); // Write the XML to a file. // export file name example: crossref-20160723-160036-articles-1.xml import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $exportFileName = $this->getExportFileName($this->getExportPath(), $objectsFileNamePart, $context, '.xml'); $fileManager->writeFile($exportFileName, $exportXml); // Deposit the XML file. $result = $this->depositXML($objects, $context, $exportFileName); // send notifications if ($result === true) { $this->_sendNotification($request->getUser(), $this->getDepositSuccessNotificationMessageKey(), NOTIFICATION_TYPE_SUCCESS); } else { if (is_array($result)) { foreach ($result as $error) { assert(is_array($error) && count($error) >= 1); $this->_sendNotification($request->getUser(), $error[0], NOTIFICATION_TYPE_ERROR, isset($error[1]) ? $error[1] : null); } } } // Remove all temporary files. $fileManager->deleteFile($exportFileName); // redirect back to the right tab $request->redirect(null, null, null, $path, null, $tab); } parent::executeExportAction($request, $objects, $filter, $tab, $objectsFileNamePart); }
/** * Display the plugin. * @param $args array * @param $request PKPRequest */ function display($args, $request) { $templateMgr = TemplateManager::getManager($request); $press = $request->getPress(); parent::display($args, $request); $templateMgr->assign('plugin', $this); switch (array_shift($args)) { case 'index': case '': $templateMgr->display($this->getTemplatePath() . 'index.tpl'); break; case 'export': $exportXml = $this->exportSubmissions((array) $request->getUserVar('selectedSubmissions'), $request->getContext(), $request->getUser()); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $exportFileName = $this->getExportFileName($this->getExportPath(), 'monographs', $press, '.xml'); $fileManager->writeFile($exportFileName, $exportXml); $fileManager->downloadFile($exportFileName); $fileManager->deleteFile($exportFileName); break; default: $dispatcher = $request->getDispatcher(); $dispatcher->handle404(); } }
/** * Register objects * @param $objects array * @param $filter string * @param $journal Journal * @param $objectsFileNamePart string */ function _registerObjects($objects, $filter, $journal, $objectsFileNamePart) { $plugin = $this->_plugin; import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); // export XML $exportXml = $plugin->exportXML($objects, $filter, $journal); // Write the XML to a file. $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectFileNamePart, $journal, '.xml'); $fileManager->writeFile($exportFileName, $exportXml); // Deposit the XML file. $result = $plugin->depositXML($objects, $journal, $exportFileName); if ($result !== true) { $this->_addLogEntry($result); } // Remove all temporary files. $fileManager->deleteFile($exportFileName); }
/** * Output PDF generated from the XML/XSL/FO source to browser * This function performs any necessary filtering, like image URL replacement. * @return string */ function viewFileContents() { import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $pdfFileName = CacheManager::getFileCachePath() . DIRECTORY_SEPARATOR . 'fc-xsltGalley-' . str_replace($fileManager->parseFileExtension($this->getFileName()), 'pdf', $this->getFileName()); // if file does not exist or is outdated, regenerate it from FO if (!$fileManager->fileExists($pdfFileName) || filemtime($pdfFileName) < filemtime($this->getFilePath())) { // render XML into XSL-FO $cache =& $this->_getXSLTCache($this->getFileName() . '-' . $this->getId()); $contents = $cache->getContents(); if ($contents == "") { return false; } // if for some reason the XSLT failed, show original file // Replace image references $images =& $this->getImageFiles(); if ($images !== null) { // TODO: this should "smart replace" the file path ($this->getFilePath()) in the XSL-FO // in lieu of requiring XSL parameters, and transparently for FO that are hardcoded foreach ($images as $image) { $contents = preg_replace('/src\\s*=\\s*"([^"]*)' . preg_quote($image->getOriginalFileName()) . '([^"]*)"/i', 'src="${1}' . dirname($this->getFilePath()) . DIRECTORY_SEPARATOR . $image->getFileName() . '$2"', $contents); } } // Replace supplementary file references $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $suppFiles = $this->suppFileDao->getSuppFilesByArticle($this->getArticleId()); if ($suppFiles) { $journal =& Request::getJournal(); foreach ($suppFiles as $supp) { $suppUrl = Request::url(null, 'article', 'downloadSuppFile', array($this->getArticleId(), $supp->getBestSuppFileId($journal))); $contents = preg_replace('/external-destination\\s*=\\s*"([^"]*)' . preg_quote($supp->getOriginalFileName()) . '([^"]*)"/i', 'external-destination="' . $suppUrl . '"', $contents); } } // create temporary FO file and write the contents import('classes.file.TemporaryFileManager'); $temporaryFileManager = new TemporaryFileManager(); $tempFoName = $temporaryFileManager->filesDir . $this->getFileName() . '-' . $this->getId() . '.fo'; $temporaryFileManager->writeFile($tempFoName, $contents); // perform %fo and %pdf replacements for fully-qualified shell command $journal =& Request::getJournal(); $xmlGalleyPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName); $fopCommand = str_replace(array('%fo', '%pdf'), array($tempFoName, $pdfFileName), $xmlGalleyPlugin->getSetting($journal->getId(), 'externalFOP')); // check for safe mode and escape the shell command if (!ini_get('safe_mode')) { $fopCommand = escapeshellcmd($fopCommand); } // run the shell command and get the results exec($fopCommand . ' 2>&1', $contents, $status); // if there is an error, spit out the shell results to aid debugging if ($status != false) { if ($contents != '') { echo implode("\n", $contents); $cache->flush(); // clear the XSL cache in case it's a FO error return true; } else { return false; } } // clear the temporary FO file $fileManager->deleteFile($tempFoName); } // use FileManager to send file to browser $fileManager->downloadFile($pdfFileName, $this->getFileType(), true); return true; }
/** * Delete a file. * @param $args array * @param $request PKPRequest */ function fileDelete($args, &$request) { $this->validate(); $this->_parseDirArg($args, $currentDir, $parentDir); $currentPath = $this->_getRealFilesDir($request, $currentDir); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); if (@is_file($currentPath)) { $fileManager->deleteFile($currentPath); } else { // TODO Use recursive delete (rmtree) instead? @$fileManager->rmdir($currentPath); } $request->redirect(null, null, null, 'files', explode('/', $parentDir)); }
/** * Display the plugin. * @param $args array * @param $request PKPRequest */ function display($args, $request) { $templateMgr = TemplateManager::getManager($request); $press = $request->getPress(); parent::display($args, $request); $templateMgr->assign('plugin', $this); switch (array_shift($args)) { case 'index': case '': $templateMgr->display($this->getTemplatePath() . 'index.tpl'); break; case 'uploadImportXML': $user = $request->getUser(); import('lib.pkp.classes.file.TemporaryFileManager'); $temporaryFileManager = new TemporaryFileManager(); $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId()); if ($temporaryFile) { $json = new JSONMessage(true); $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId())); } else { $json = new JSONMessage(false, __('common.uploadFailed')); } return $json->getString(); case 'importBounce': $json = new JSONMessage(true); $json->setEvent('addTab', array('title' => __('plugins.importexport.native.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId'))))); return $json->getString(); case 'import': AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION); $temporaryFileId = $request->getUserVar('temporaryFileId'); $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $user = $request->getUser(); $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId()); if (!$temporaryFile) { $json = new JSONMessage(true, __('plugins.inportexport.native.uploadFile')); return $json->getString(); } $temporaryFilePath = $temporaryFile->getFilePath(); $deployment = new NativeImportExportDeployment($press, $user); libxml_use_internal_errors(true); $submissions = $this->importSubmissions(file_get_contents($temporaryFilePath), $deployment); $templateMgr->assign('submissions', $submissions); $validationErrors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR || $a->level == LIBXML_ERR_FATAL;')); $templateMgr->assign('validationErrors', $validationErrors); libxml_clear_errors(); // Are there any submissions import errors $processedSubmissionsIds = $deployment->getProcessedObjectsIds(ASSOC_TYPE_SUBMISSION); if (!empty($processedSubmissionsIds)) { $submissionsErrors = array_filter($processedSubmissionsIds, create_function('$a', 'return !empty($a);')); if (!empty($submissionsErrors)) { $templateMgr->assign('submissionsErrors', $processedSubmissionsIds); } } // If there are any submissions or validataion errors // delete imported submissions. if (!empty($submissionsErrors) || !empty($validationErrors)) { // remove all imported sumissions $deployment->removeImportedObjects(ASSOC_TYPE_SUBMISSION); } // Display the results $json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl')); return $json->getString(); case 'export': $exportXml = $this->exportSubmissions((array) $request->getUserVar('selectedSubmissions'), $request->getContext(), $request->getUser()); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $exportFileName = $this->getExportFileName($this->getExportPath(), 'monographs', $press, '.xml'); $fileManager->writeFile($exportFileName, $exportXml); $fileManager->downloadFile($exportFileName); $fileManager->deleteFile($exportFileName); break; default: $dispatcher = $request->getDispatcher(); $dispatcher->handle404(); } }
/** * Handle a revision element * @param $node DOMElement * @param $stageId int SUBMISSION_FILE_... */ function handleRevisionElement($node, $stageId) { static $genresByContextId = array(); $deployment = $this->getDeployment(); $submission = $deployment->getSubmission(); $context = $deployment->getContext(); $genreName = $node->getAttribute('genre'); // Build a cached list of genres by context ID by name if (!isset($genresByContextId[$context->getId()])) { $genreDao = DAORegistry::getDAO('GenreDAO'); $genres = $genreDao->getByContextId($context->getId()); while ($genre = $genres->next()) { foreach ($genre->getName(null) as $locale => $name) { $genresByContextId[$context->getId()][$name] = $genre; } } } if (!isset($genresByContextId[$context->getId()][$genreName])) { fatalError('Unknown genre "' . $genreName . '"!'); } $genre = $genresByContextId[$context->getId()][$genreName]; $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFile = $submissionFileDao->newDataObjectByGenreId($genre->getId()); $submissionFile->setSubmissionId($submission->getId()); $submissionFile->setGenreId($genre->getId()); $submissionFile->setFileStage($stageId); $submissionFile->setDateUploaded(Core::getCurrentDate()); $submissionFile->setDateModified(Core::getCurrentDate()); $submissionFile->setOriginalFileName($filename = $node->getAttribute('filename')); for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) { if (is_a($n, 'DOMElement')) { $filename = $this->handleRevisionChildElement($n, $submission, $submissionFile); } } $uploaderUsername = $node->getAttribute('uploader'); $uploaderUserGroup = $node->getAttribute('user_group_ref'); // Determine the user group based on the user_group_ref element. $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $userGroups = $userGroupDao->getByContextId($context->getId()); while ($userGroup = $userGroups->next()) { if (in_array($uploaderUserGroup, $userGroup->getName(null))) { $submissionFile->setUserGroupId($userGroup->getId()); } } // Do the same for the user. $userDao = DAORegistry::getDAO('UserDAO'); $user = $userDao->getByUsername($uploaderUsername); if ($user) { $submissionFile->setUploaderUserId($user->getId()); } $fileSize = $node->getAttribute('filesize'); $submissionFile->setFileSize($fileSize); $fileType = $node->getAttribute('filetype'); $submissionFile->setFileType($fileType); $submissionFileDao->insertObject($submissionFile, $filename, false); $fileManager = new FileManager(); $fileManager->deleteFile($filename); return $submissionFile; }
/** * Delete a file by ID. * @param $fileId int * @return int number of files removed */ function deleteFile($fileId) { $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO'); $files = array(); $file =& $articleFileDao->getArticleFile($fileId); if (isset($file)) { $files[] = $file; } foreach ($files as $f) { parent::deleteFile($this->filesDir . $f->getType() . '/' . $f->getFileName()); } $articleFileDao->deleteArticleFileById($fileId); return count($files); }
/** * Download all passed files. * @param $args array * @param $request Request */ function downloadAllFiles($args, $request) { // Retrieve the authorized objects. $submissionFiles = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILES); $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); // Find out the paths of all files in this grid. $context = $request->getContext(); $filePaths = array(); $fileManager = $this->_getFileManager($context->getId(), $submission->getId()); $filesDir = $fileManager->getBasePath(); foreach ($submissionFiles as $submissionFile) { // Remove absolute path so the archive doesn't include it (otherwise all files are organized by absolute path) $filePaths[str_replace($filesDir, '', $submissionFile->getFilePath())] = $submissionFile->getClientFileName(); } import('lib.pkp.classes.file.FileArchive'); $fileArchive = new FileArchive(); $archivePath = $fileArchive->create($filePaths, $filesDir); if (file_exists($archivePath)) { $fileManager = new FileManager(); if ($fileArchive->zipFunctional()) { $fileManager->downloadFile($archivePath, 'application/x-zip', false, 'files.zip'); } else { $fileManager->downloadFile($archivePath, 'application/x-gtar', false, 'files.tar.gz'); } $fileManager->deleteFile($archivePath); } else { fatalError('Creating archive with submission files failed!'); } }
/** * Delete a file by ID. * If no revision is specified, all revisions of the file are deleted. * @param $fileId int * @param $revision int (optional) * @return int number of files removed */ function deleteFile($fileId, $revision = null) { $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO'); $files = array(); if (isset($revision)) { $file =& $articleFileDao->getArticleFile($fileId, $revision); if (isset($file)) { $files[] = $file; } } else { $files =& $articleFileDao->getArticleFileRevisions($fileId); } if ($files) { foreach ($files as $f) { parent::deleteFile($this->filesDir . $this->fileStageToPath($f->getFileStage()) . '/' . $f->getFileName()); } } $articleFileDao->deleteArticleFileById($fileId, $revision); return count($files); }
function deleteFile($fileName) { return parent::deleteFile($this->filesDir . $fileName); }
/** * Register objects * @param $objects array * @param $filter string * @param $journal Journal * @param $objectsFileNamePart string */ function _registerObjects($objects, $filter, $journal, $objectsFileNamePart) { $plugin = $this->_plugin; import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); foreach ($objects as $object) { // export XML $exportXml = $plugin->exportXML($object, $filter, $journal); // Write the XML to a file. // export file name example: datacite-20160723-160036-articles-1-1.xml $objectFileNamePart = $objectsFileNamePart . '-' . $object->getId(); $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectFileNamePart, $journal, '.xml'); $fileManager->writeFile($exportFileName, $exportXml); // Deposit the XML file. $result = $plugin->depositXML($object, $journal, $exportFileName); if ($result !== true) { $this->_addLogEntry($result); } // Remove all temporary files. $fileManager->deleteFile($exportFileName); } }