Skip to content

Commit

Permalink
Merge branch 'portTo34' into 'main'
Browse files Browse the repository at this point in the history
Adapt plugin code to OJS 3.4

See merge request softwares-pkp/plugins_ojs/deleteIncompleteSubmissions!1
  • Loading branch information
iudizm committed Jun 20, 2024
2 parents d0068b5 + 8f0ae0a commit 9a3b4f8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<?php

import('lib.pkp.classes.plugins.GenericPlugin');
/**
* @file plugins/generic/deleteIncompleteSubmissions/deleteIncompleteSubmissions.php
*
* Copyright (c) 2024 Lepidus Tecnologia
* Distributed under the GNU GPL v3. For full terms see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt
*
* @class DeleteIncompleteSubmissionsPlugin
* @ingroup plugins_generic_deleteIncompleteSubmissions
*
*/

namespace APP\plugins\generic\deleteIncompleteSubmissions;

use PKP\plugins\GenericPlugin;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use APP\core\Application;
use PKP\core\JSONMessage;
use APP\plugins\generic\deleteIncompleteSubmissions\settings\DeleteIncompleteSubmissionsSettingsForm;

class DeleteIncompleteSubmissionsPlugin extends GenericPlugin
{
Expand Down Expand Up @@ -33,7 +51,6 @@ public function getCanDisable()
public function getActions($request, $actionArgs)
{
$router = $request->getRouter();
import('lib.pkp.classes.linkAction.request.AjaxModal');
return array_merge(
$this->getEnabled() ? [
new LinkAction(
Expand All @@ -51,7 +68,6 @@ public function manage($args, $request)
switch ($request->getUserVar('verb')) {
case 'deletion':
$context = $request->getContext();
$this->import('form.DeleteIncompleteSubmissionsSettingsForm');
$form = new DeleteIncompleteSubmissionsSettingsForm($this, $context->getId());

if ($request->getUserVar('save')) {
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

This plugin allows editors to delete incomplete submissions from the journal.

It allows the editor to set a threshold, in days, to safeguard the deletion of submissions that are not meant to be deleted at the moment.

# Compatibility

This plugin is compatible with OJS 3.3.0
This plugin is compatible with **OJS 3.4.0**

For compatibility with other versions of OJS, please refer to this repository branches.

# Installation

Expand All @@ -14,7 +18,7 @@ Upload the package in the `Website > Plugins` section of the Dashboard.

# Usage

After installing the plugin, it will appear in the plugins list, from there, activate the plugin, then expand the options in the arrow, and click on the `Delete submissions...` option:
After installing the plugin, it will appear in the plugins list, from there, activate the plugin, then expand the options in the arrow, and click on the ***`Delete submissions...`*** action:

![](screenshots/plugin-options.png)

Expand Down
20 changes: 0 additions & 20 deletions index.php

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?php

import('lib.pkp.classes.form.Form');
namespace APP\plugins\generic\deleteIncompleteSubmissions\settings;

use APP\template\TemplateManager;
use PKP\form\Form;
use PKP\form\validation\FormValidatorCSRF;
use PKP\form\validation\FormValidatorPost;
use APP\core\Application;
use APP\facades\Repo;

class DeleteIncompleteSubmissionsSettingsForm extends Form
{
Expand Down Expand Up @@ -47,17 +54,19 @@ public function execute(...$functionArgs)

private function deleteIncompleteSubmissions(int $deletionThreshold): void
{
$submissionService = Services::get('submission');
$submissions = $submissionService->getMany([
'contextId' => $this->contextId, 'isIncomplete' => true, 'daysInactive' => $deletionThreshold
]);

foreach ($submissions as $submission) {
try {
$submissionService->delete($submission);
} catch (\Throwable $th) {
error_log('The submission ' . $submission->getId() . ' was not deleted. Reason:' . $th->getMessage());
$submissions = Repo::submission()
->getCollector()
->filterByContextIds([$this->contextId])
->filterByIncomplete(true)
->filterByDaysInactive($deletionThreshold)
->getMany();

try {
foreach ($submissions as $submission) {
Repo::submission()->delete($submission);
}
} catch (\Throwable $th) {
error_log('The submission ' . $submission->getId() . ' was not deleted. Reason:' . $th->getMessage());
}
}
}
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<version>
<application>deleteIncompleteSubmissions</application>
<type>plugins.generic</type>
<release>0.1.3.0</release>
<date>2024-02-14</date>
<release>0.2.0.0</release>
<date>2024-06-20</date>
</version>

0 comments on commit 9a3b4f8

Please sign in to comment.