/** * Clean up after a deposit, i.e. removing all created files. */ function cleanup() { import('file.FileManager'); $fileManager = new FileManager(); $fileManager->rmtree($this->outPath); }
/** * Delete a scheduled conference. * @param $args array first parameter is the ID of the scheduled conference to delete */ function deleteSchedConf($args) { $this->validate(); $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); if (isset($args) && !empty($args) && !empty($args[0])) { $schedConfId = $args[0]; $schedConf =& $schedConfDao->getSchedConf($schedConfId); // Look up the scheduled conference path before we delete the scheduled conference. import('file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $schedConfFilesPath = $publicFileManager->getSchedConfFilesPath($schedConfId); if ($schedConfDao->deleteSchedConfById($schedConfId)) { // Delete scheduled conference file tree // FIXME move this somewhere better. import('file.FileManager'); $fileManager = new FileManager(); $schedConfPath = Config::getVar('files', 'files_dir') . '/conferences/' . $schedConf->getConferenceId() . '/schedConfs/' . $schedConfId; $fileManager->rmtree($schedConfPath); $publicFileManager->rmtree($schedConfFilesPath); } } Request::redirect(null, null, null, 'schedConfs'); }
/** * Upgrade a plugin to a newer version from the user's filesystem * @param $category string * @param $plugin string * @param $path string path to plugin Directory * @param $category string * @param $plugin string * @return Version|null The upgraded version, on success; null on fail */ function upgradePlugin($category, $plugin, $path, &$errorMsg) { $versionFile = $path . '/' . PLUGIN_VERSION_FILE; $pluginVersion = VersionCheck::getValidPluginVersionInfo($versionFile, $errorMsg); if (!$pluginVersion) { return null; } // Check whether the uploaded plug-in fits the original plug-in. if ('plugins.' . $category != $pluginVersion->getProductType()) { $errorMsg = __('manager.plugins.wrongCategory'); return null; } if ($plugin != $pluginVersion->getProduct()) { $errorMsg = __('manager.plugins.wrongName'); return null; } $versionDao = DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true); if (!$installedPlugin) { $errorMsg = __('manager.plugins.pleaseInstall'); return null; } if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) { $errorMsg = __('manager.plugins.installedVersionNewer'); return null; } else { $pluginDest = Core::getBaseDir() . '/plugins/' . $category . '/' . $plugin; $pluginLibDest = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/plugins/' . $category . '/' . $plugin; // Delete existing files. $fileManager = new FileManager(); if (is_dir($pluginDest)) { $fileManager->rmtree($pluginDest); } if (is_dir($pluginLibDest)) { $fileManager->rmtree($pluginLibDest); } // Check whether deleting has worked. if (is_dir($pluginDest) || is_dir($pluginLibDest)) { $errorMsg = __('message', 'manager.plugins.deleteError'); return null; } // Copy the plug-in from the temporary folder to the // target folder. // Start with the library part (if any). $libPath = $path . '/lib'; if (is_dir($libPath)) { if (!$fileManager->copyDir($libPath, $pluginLibDest)) { $errorMsg = __('manager.plugins.copyError'); return null; } // Remove the library part of the temporary folder. $fileManager->rmtree($libPath); } // Continue with the application-specific part (mandatory). if (!$fileManager->copyDir($path, $pluginDest)) { $errorMsg = __('manager.plugins.copyError'); return null; } // Remove the temporary folder. $fileManager->rmtree(dirname($path)); $upgradeFile = $pluginDest . '/' . PLUGIN_UPGRADE_FILE; if ($fileManager->fileExists($upgradeFile)) { $params = $this->_getConnectionParams(); $installer = new Upgrade($params, $upgradeFile, true); if (!$installer->execute()) { $errorMsg = __('manager.plugins.upgradeFailed', array('errorString' => $installer->getErrorString())); return null; } } $installedPlugin->setCurrent(0); $pluginVersion->setCurrent(1); $versionDao->insertVersion($pluginVersion, true); return $pluginVersion; } }
/** * Delete a conference. * @param $args array first parameter is the ID of the conference to delete */ function deleteConference($args, &$request) { $this->validate(); $conferenceDao =& DAORegistry::getDAO('ConferenceDAO'); if (isset($args) && !empty($args) && !empty($args[0])) { $conferenceId = $args[0]; if ($conferenceDao->deleteConferenceById($conferenceId)) { // Delete conference file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $conferencePath = Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId; $fileManager->rmtree($conferencePath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getConferenceFilesPath($conferenceId)); } } $request->redirect(null, null, null, 'conferences'); }
/** * Delete the entire tree of files belonging to a paper. */ function deletePaperTree() { parent::rmtree($this->filesDir); }
/** * Delete a plugin from the system * @param $category string * @param $plugin string */ function deletePlugin($category, $plugin) { $this->validate(); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(true); $templateMgr->assign('path', 'delete'); $templateMgr->assign('deleted', false); $templateMgr->assign('error', false); $versionDao =& DAORegistry::getDAO('VersionDAO'); /* @var $versionDao VersionDAO */ $installedPlugin = $versionDao->getCurrentVersion('plugins.' . $category, $plugin, true); if ($installedPlugin) { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin; $pluginLibDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin; //make sure plugin type is valid and then delete the files if (in_array($category, PluginRegistry::getCategories())) { // Delete the plugin from the file system. FileManager::rmtree($pluginDest); FileManager::rmtree($pluginLibDest); } if (is_dir($pluginDest) || is_dir($pluginLibDest)) { $templateMgr->assign('error', true); $templateMgr->assign('message', 'manager.plugins.deleteError'); } else { $versionDao->disableVersion('plugins.' . $category, $plugin); $templateMgr->assign('deleted', true); } } else { $templateMgr->assign('error', true); $templateMgr->assign('message', 'manager.plugins.doesNotExist'); } $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category)); $templateMgr->display('manager/plugins/managePlugins.tpl'); }
/** * Process apache log files, copying and filtering them * to the usage stats stage directory. Can work with both * a specific file or a directory. */ function execute() { $fileMgr = new FileManager(); $filesDir = Config::getVar('files', 'files_dir'); $filePath = current($this->argv); $usageStatsDir = $this->_usageStatsDir; $tmpDir = $this->_tmpDir; if ($fileMgr->fileExists($tmpDir, 'dir')) { $fileMgr->rmtree($tmpDir); } if (!$fileMgr->mkdir($tmpDir)) { printf(__('admin.copyAccessLogFileTool.error.creatingFolder', array('tmpDir' => $tmpDir)) . "\n"); exit(1); } if ($fileMgr->fileExists($filePath, 'dir')) { // Directory. $filesToCopy = glob($filePath . DIRECTORY_SEPARATOR . '*'); foreach ($filesToCopy as $file) { $this->_copyFile($file); } } else { if ($fileMgr->fileExists($filePath)) { // File. $this->_copyFile($filePath); } else { // Can't access. printf(__('admin.copyAccessLogFileTool.error.acessingFile', array('filePath' => $filePath)) . "\n"); } } $fileMgr->rmtree($tmpDir); }
/** * Delete a journal. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function deleteContext($args, $request) { // Identify the journal Id. $journalId = $request->getUserVar('rowId'); $journalDao = DAORegistry::getDAO('JournalDAO'); $journal = $journalDao->getById($journalId); if ($journal) { $journalDao->deleteById($journalId); // Delete journal file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager($journalId); $journalPath = Config::getVar('files', 'files_dir') . '/journals/' . $journalId; $fileManager->rmtree($journalPath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getJournalFilesPath($journalId)); return DAO::getDataChangedEvent($journalId); } return new JSONMessage(false); }
/** * Delete the entire tree of files belonging to an issue. */ function deleteIssueTree() { parent::rmtree($this->getFilesDir()); }
/** * Delete plugin. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function deletePlugin($args, $request) { $plugin = $this->getAuthorizedContextObject(ASSOC_TYPE_PLUGIN); $category = $plugin->getCategory(); $productName = basename($plugin->getPluginPath()); $versionDao = DAORegistry::getDAO('VersionDAO'); /* @var $versionDao VersionDAO */ $installedPlugin = $versionDao->getCurrentVersion('plugins.' . $category, $productName, true); $notificationMgr = new NotificationManager(); $user = $request->getUser(); if ($installedPlugin) { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $productName; $pluginLibDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . PKP_LIB_PATH . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $productName; // make sure plugin type is valid and then delete the files if (in_array($category, PluginRegistry::getCategories())) { // Delete the plugin from the file system. $fileManager = new FileManager(); $fileManager->rmtree($pluginDest); $fileManager->rmtree($pluginLibDest); } if (is_dir($pluginDest) || is_dir($pluginLibDest)) { $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('manager.plugins.deleteError', array('pluginName' => $plugin->getDisplayName())))); } else { $versionDao->disableVersion('plugins.' . $category, $productName); $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('manager.plugins.deleteSuccess', array('pluginName' => $plugin->getDisplayName())))); } } else { $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('manager.plugins.doesNotExist', array('pluginName' => $plugin->getDisplayName())))); } return DAO::getDataChangedEvent($plugin->getName()); }
/** * Delete the entire tree of files belonging to an article. */ function deleteArticleTree() { parent::rmtree($this->filesDir); }
/** * Delete a press. * @param $args array first parameter is the ID of the press to delete */ function deletePress($args) { $this->validate(); $pressDao =& DAORegistry::getDAO('PressDAO'); if (isset($args) && !empty($args) && !empty($args[0])) { $pressId = $args[0]; if ($pressDao->deletePressById($pressId)) { // Delete press file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $pressPath = Config::getVar('files', 'files_dir') . '/presses/' . $pressId; $fileManager->rmtree($pressPath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getPressFilesPath($pressId)); } } Request::redirect(null, null, 'presses'); }
/** * Delete a plugin from the system * @param plugin string */ function deletePlugin($plugin) { $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(true); $templateMgr->assign('path', 'delete'); $templateMgr->assign('deleted', false); $templateMgr->assign('error', false); $templateMgr->assign('pageHierarchy', PluginManagementHandler::setBreadcrumbs(true)); $versionDao =& DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($plugin); $category = $this->getPluginCategory($plugin); if ($installedPlugin) { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin; //make sure plugin type is valid and then delete the files if (in_array($category, PluginRegistry::getCategories())) { FileManager::rmtree($pluginDest); } if (FileManager::fileExists($pluginDest, 'dir')) { $templateMgr->assign('error', true); $templateMgr->assign('message', 'manager.plugins.deleteError'); } else { $versionDao->disableVersion($plugin); $templateMgr->assign('deleted', true); } } else { $templateMgr->assign('error', true); $templateMgr->assign('message', 'manager.plugins.doesNotExist'); } $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category)); $templateMgr->display('manager/plugins/managePlugins.tpl'); }
/** * Delete the entire tree of files belonging to a meeting. */ function deleteMeetingTree() { parent::rmtree($this->filesDir); }
/** * Process apache log files, copying and filtering them * to the usage stats stage directory. Can work with both * a specific file or a directory. */ function execute() { $fileMgr = new FileManager(); $filesDir = Config::getVar('files', 'files_dir'); $filePath = current($this->argv); $usageStatsDir = $this->_usageStatsDir; $tmpDir = $this->_tmpDir; if ($fileMgr->fileExists($tmpDir, 'dir')) { $fileMgr->rmtree($tmpDir); } if (!$fileMgr->mkdir($tmpDir)) { printf(__('admin.copyAccessLogFileTool.error.creatingFolder', array('tmpDir' => $tmpDir)) . "\n"); exit(1); } if ($fileMgr->fileExists($filePath, 'dir')) { // Directory. $filesToCopy = glob($filePath . DIRECTORY_SEPARATOR . '*.*'); foreach ($filesToCopy as $file) { // If a base filename is given as a parameter, check it. if (count($this->argv) == 2) { $baseFilename = $this->argv[1]; if (strpos(pathinfo($file, PATHINFO_BASENAME), $baseFilename) !== 0) { continue; } } $this->_copyFile($file); } } else { if ($fileMgr->fileExists($filePath)) { // File. $this->_copyFile($filePath); } else { // Can't access. printf(__('admin.copyAccessLogFileTool.error.acessingFile', array('filePath' => $filePath)) . "\n"); } } $fileMgr->rmtree($tmpDir); }
/** * Delete an monograph by ID. * @param $monographId int */ function deleteMonographById($monographId) { $this->authorDao->deleteAuthorsByMonograph($monographId); // Delete monograph files. $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ $submissionFileDao->deleteAllRevisionsBySubmissionId($monographId); // Delete monograph file directory. $monograph =& $this->getMonograph($monographId); assert(is_a($monograph, 'Monograph')); if (is_a($monograph, 'Monograph')) { FileManager::rmtree($monograph->getFilePath()); } $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO'); $seriesEditorSubmissionDao->deleteDecisionsByMonograph($monographId); $seriesEditorSubmissionDao->deleteReviewRoundsByMonograph($monographId); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignmentDao->deleteByMonographId($monographId); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $signoffs =& $signoffDao->getBySymbolic('SIGNOFF_STAGE', ASSOC_TYPE_MONOGRAPH, $monographId); foreach ($signoffs as $signoff) { $signoffDao->deleteObject($signoff); } $monographCommentDao =& DAORegistry::getDAO('MonographCommentDAO'); $monographCommentDao->deleteMonographComments($monographId); $this->update('DELETE FROM monograph_settings WHERE monograph_id = ?', $monographId); $this->update('DELETE FROM monographs WHERE monograph_id = ?', $monographId); }
/** * Clean up after a deposit, i.e. removing all created files. */ function cleanup() { import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $fileManager->rmtree($this->outPath); }
/** * Delete all contents including directory (equivalent to "rm -r") * @param $file string the full path of the directory to be removed */ function rmtree($file) { if (file_exists($file)) { if (is_dir($file)) { $handle = opendir($file); while (($filename = readdir($handle)) !== false) { if ($filename != '.' && $filename != '..') { FileManager::rmtree($file . '/' . $filename); } } closedir($handle); rmdir($file); } else { unlink($file); } } }
/** * Delete a journal. * @param $args array first parameter is the ID of the journal to delete * @param $request object */ function deleteJournal($args, &$request) { $this->validate(); $journalDao =& DAORegistry::getDAO('JournalDAO'); if (isset($args) && !empty($args) && !empty($args[0])) { $journalId = $args[0]; if ($journalDao->deleteJournalById($journalId)) { // Delete journal file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $journalPath = Config::getVar('files', 'files_dir') . '/journals/' . $journalId; $fileManager->rmtree($journalPath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getJournalFilesPath($journalId)); } } $request->redirect(null, null, 'journals'); }
/** * Delete a conference. * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function deleteContext($args, &$request) { // Identify the current context. $context =& $request->getContext(); // Identify the conference Id. $conferenceId = $request->getUserVar('rowId'); $conferenceDao = DAORegistry::getDAO('ConferenceDAO'); $conference =& $conferenceDao->getById($conferenceId); if ($conference) { $conferenceDao->deleteById($conferenceId); // Delete conference file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager($conferenceId); $conferencePath = Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId; $fileManager->rmtree($conferencePath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getConferenceFilesPath($conferenceId)); return DAO::getDataChangedEvent($conferenceId); } $json = new JSONMessage(false); return $json->getString(); }