| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/Topogeo/ojs/tools/ |
Upload File : |
<?php
/**
* @file tools/deleteSubmissions.php
*
* Copyright (c) 2003-2012 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
*/
// $Id$
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} 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();
?>