argv)) { $this->usage(); exit(1); } $this->parameters = $this->argv; } /** * Print command usage information. */ function usage() { echo "Permanently removes submission(s) and associated information. USE WITH CARE.\n" . "Usage: {$this->scriptName} submssion_id [...]\n"; } /** * Delete submission data and associated files */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); foreach($this->parameters as $articleId) { $article =& $articleDao->getArticle($articleId); if(isset($article)) { // remove files first, to prevent orphans $articleFileManager = new ArticleFileManager($articleId); if (! file_exists($articleFileManager->filesDir)) { printf("Warning: no files found for submission $articleId.\n"); } else { if (! is_writable($articleFileManager->filesDir)) { printf("Error: Skipping submission $articleId. Can't delete files in " . $articleFileManager->filesDir . "\n"); continue; } else { $articleFileManager->deleteArticleTree(); } } $articleDao->deleteArticleById($articleId); continue; } printf("Error: Skipping $articleId. Unknown submission.\n"); } } } $tool = new SubmissionDeletionTool(isset($argv) ? $argv : array()); $tool->execute(); ?>