%PDF-1.7 GIF89;
| Server IP : 104.20.45.2 / Your IP : 172.16.20.3 Web Server : Apache/2.4.25 (Debian) System : Linux f64a392e70de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : application ( 1000) PHP Version : 5.6.40 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /app/tools/ |
Upload File : |
<?php
/**
* @file tools/deleteSubmissions.php
*
* Copyright (c) 2013-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class deleteSubmissions
* @ingroup tools
*
* @brief CLI tool to delete submissions
*/
require(dirname(__FILE__) . '/bootstrap.inc.php');
import('classes.file.ArticleFileManager');
class SubmissionDeletionTool extends CommandLineTool {
var $articleIds;
/**
* Constructor.
* @param $argv array command-line arguments
*/
function SubmissionDeletionTool($argv = array()) {
parent::CommandLineTool($argv);
if (!sizeof($this->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} submission_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();
?>