Skip to content

Commit

Permalink
pkp/pkp-lib#5717 Refactor editorial decisions and introduce email com…
Browse files Browse the repository at this point in the history
…poser UI component
  • Loading branch information
NateWr committed Jan 13, 2022
1 parent 7ee6f86 commit ce45de3
Show file tree
Hide file tree
Showing 69 changed files with 566 additions and 713 deletions.
17 changes: 17 additions & 0 deletions api/v1/_library/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* @defgroup api_v1_library Email templates API requests
*/

/**
* @file api/v1/library/index.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_library
* @brief Handle API requests for the publisher and submission library files.
*/
import('lib.pkp.api.v1._library.PKPLibraryHandler');
return new PKPLibraryHandler();
3 changes: 2 additions & 1 deletion classes/core/Request.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace APP\core;

use APP\journal\Journal;
use PKP\core\PKPRequest;
use PKP\plugins\HookRegistry;

Expand Down Expand Up @@ -71,7 +72,7 @@ public function getRequestedContextPath($contextLevel = null)
*
* @see PKPPageRouter::getContext()
*/
public function &getContext($level = 1)
public function &getContext($level = 1): ?Journal
{
$returner = $this->_delegateToRouter('getContext', $level);
return $returner;
Expand Down
43 changes: 43 additions & 0 deletions classes/decision/Decision.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* @defgroup decision Decision
*/

/**
* @file classes/decision/Decision.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Decision
* @ingroup decision
*
* @see DAO
*
* @brief An editorial decision taken on a submission, such as to accept, decline or request revisions.
*/

namespace APP\decision;

use PKP\decision\Decision as BaseDecision;

class Decision extends BaseDecision
{
public const EXTERNAL_REVIEW = 8;
public const ACCEPT = 1;
public const DECLINE = 4;
public const PENDING_REVISIONS = 2;
public const RESUBMIT = 3;
public const NEW_ROUND = 16;
}

if (!PKP_STRICT_MODE) {
define('EXTERNAL_REVIEW', Decision::EXTERNAL_REVIEW);
define('ACCEPT', Decision::ACCEPT);
define('DECLINE', Decision::DECLINE);
define('PENDING_REVISIONS', Decision::PENDING_REVISIONS);
define('RESUBMIT', Decision::RESUBMIT);
define('NEW_ROUND', Decision::NEW_ROUND);
}
78 changes: 78 additions & 0 deletions classes/decision/Repository.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* @file classes/decision/Repository.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class decision
*
* @brief A repository to find and manage editorial decisions.
*/

namespace APP\decision;

use APP\notification\Notification;
use Illuminate\Database\Eloquent\Collection;
use PKP\decision\types\Accept;
use PKP\decision\types\BackToCopyediting;
use PKP\decision\types\BackToReview;
use PKP\decision\types\BackToSubmissionFromCopyediting;
use PKP\decision\types\Decline;
use PKP\decision\types\InitialDecline;
use PKP\decision\types\NewExternalReviewRound;
use PKP\decision\types\RecommendAccept;
use PKP\decision\types\RecommendDecline;
use PKP\decision\types\RecommendResubmit;
use PKP\decision\types\RecommendRevisions;
use PKP\decision\types\RequestRevisions;
use PKP\decision\types\Resubmit;
use PKP\decision\types\RevertDecline;
use PKP\decision\types\RevertInitialDecline;
use PKP\decision\types\SendExternalReview;
use PKP\decision\types\SendToProduction;
use PKP\decision\types\SkipReview;
use PKP\plugins\HookRegistry;

class Repository extends \PKP\decision\Repository
{
/** The valid decision types */
protected ?Collection $types;

/** @copydoc \PKP\decision\Repository::getTypes */
public function getTypes(): Collection
{
if (!isset($this->types)) {
$types = new Collection([
new Accept(),
new BackToCopyediting(),
new BackToReview(),
new BackToSubmissionFromCopyediting(),
new Decline(),
new InitialDecline(),
new NewExternalReviewRound(),
new RecommendAccept(),
new RecommendDecline(),
new RecommendResubmit(),
new RecommendRevisions(),
new Resubmit(),
new RequestRevisions(),
new RevertDecline(),
new RevertInitialDecline(),
new SendExternalReview(),
new SendToProduction(),
new SkipReview(),
]);
HookRegistry::call('Decision::types', [$types]);
$this->types = $types;
}

return $this->types;
}

protected function getReviewNotificationTypes(): array
{
return [Notification::NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS];
}
}
14 changes: 10 additions & 4 deletions classes/facades/Repo.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace APP\facades;

use APP\decision\Repository as DecisionRepository;
use APP\issue\Repository as IssueRepository;
use APP\publication\Repository as PublicationRepository;
use APP\submission\Repository as SubmissionRepository;
Expand All @@ -24,6 +25,11 @@

class Repo extends BaseRepo
{
public static function decision(): DecisionRepository
{
return app()->make(DecisionRepository::class);
}

public static function issue(): IssueRepository
{
return app(IssueRepository::class);
Expand All @@ -39,13 +45,13 @@ public static function submission(): SubmissionRepository
return app(SubmissionRepository::class);
}

public static function user(): UserRepository
public static function submissionFile(): SubmissionFileRepository
{
return app(UserRepository::class);
return app(SubmissionFileRepository::class);
}

public static function submissionFile(): SubmissionFileRepository
public static function user(): UserRepository
{
return app(SubmissionFileRepository::class);
return app(UserRepository::class);
}
}
6 changes: 3 additions & 3 deletions classes/mail/variables/ContextEmailVariable.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class ContextEmailVariable extends PKPContextEmailVariable
public const CONTEXT_URL = 'journalUrl';

/**
* @copydoc Variable::description()
* @copydoc Variable::descriptions()
*/
protected static function description(): array
public static function descriptions(): array
{
return array_merge(
parent::description(),
parent::descriptions(),
[
self::CONTEXT_NAME => __('emailTemplate.variable.context.contextName'),
self::CONTEXT_URL => __('emailTemplate.variable.context.contextUrl'),
Expand Down
1 change: 0 additions & 1 deletion classes/notification/NotificationManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
namespace APP\notification;

use APP\core\Application;

use APP\facades\Repo;
use APP\notification\managerDelegate\ApproveSubmissionNotificationManager;
use PKP\notification\PKPNotificationManager;
Expand Down
19 changes: 10 additions & 9 deletions classes/payment/ojs/OJSPaymentManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@

namespace APP\payment\ojs;

use APP\core\Application;
use APP\facades\Repo;

use APP\subscription\Subscription;
use APP\subscription\SubscriptionAction;
use PKP\payment\CompletedPayment;
use PKP\payment\PaymentManager;

use PKP\payment\QueuedPayment;
use PKP\plugins\PluginRegistry;

use APP\subscription\SubscriptionAction;
use APP\subscription\Subscription;

class OJSPaymentManager extends PaymentManager
{
public const PAYMENT_TYPE_MEMBERSHIP = 1;
Expand Down Expand Up @@ -75,23 +76,23 @@ public function createQueuedPayment($request, $type, $userId, $assocId, $amount,

switch ($type) {
case self::PAYMENT_TYPE_PURCHASE_ARTICLE:
$payment->setRequestUrl($dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'article', 'view', $assocId));
$payment->setRequestUrl($dispatcher->url($request, Application::ROUTE_PAGE, null, 'article', 'view', $assocId));
break;
case self::PAYMENT_TYPE_PURCHASE_ISSUE:
$payment->setRequestUrl($dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'issue', 'view', $assocId));
$payment->setRequestUrl($dispatcher->url($request, Application::ROUTE_PAGE, null, 'issue', 'view', $assocId));
break;
case self::PAYMENT_TYPE_PURCHASE_SUBSCRIPTION:
$payment->setRequestUrl($dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'issue', 'current'));
$payment->setRequestUrl($dispatcher->url($request, Application::ROUTE_PAGE, null, 'issue', 'current'));
break;
case self::PAYMENT_TYPE_RENEW_SUBSCRIPTION:
$payment->setRequestUrl($dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'user', 'subscriptions'));
$payment->setRequestUrl($dispatcher->url($request, Application::ROUTE_PAGE, null, 'user', 'subscriptions'));
break;
case self::PAYMENT_TYPE_PUBLICATION:
$submission = Repo::submission()->get($assocId);
if ($submission->getSubmissionProgress() != 0) {
$payment->setRequestUrl($dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'submission', 'wizard', $submission->getSubmissionProgress(), ['submissionId' => $assocId]));
$payment->setRequestUrl($dispatcher->url($request, Application::ROUTE_PAGE, null, 'submission', 'wizard', $submission->getSubmissionProgress(), ['submissionId' => $assocId]));
} else {
$payment->setRequestUrl($dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'authorDashboard', 'submission', $submission->getId()));
$payment->setRequestUrl($dispatcher->url($request, Application::ROUTE_PAGE, null, 'authorDashboard', 'submission', $submission->getId()));
}
break;
case self::PAYMENT_TYPE_MEMBERSHIP: // Deprecated
Expand Down
2 changes: 1 addition & 1 deletion classes/publication/maps/Schema.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use APP\core\Services;
use APP\publication\Publication;

use PKP\core\PKPApplication;
use PKP\services\PKPSchemaService;

Expand All @@ -34,6 +33,7 @@ protected function mapByProperties(array $props, Publication $publication, bool
'publication' => $publication,
'request' => $this->request,
'submission' => $this->submission,
'genres' => $this->genres,
];
$output['galleys'] = array_map(
function ($galley) use ($galleyArgs) {
Expand Down
8 changes: 6 additions & 2 deletions classes/services/GalleyService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public function getProperties($galley, $props, $args = null)
$submission = !empty($args['submission'])
? $args['submission']
: $args['submission'] = Repo::submission()->get($publication->getData('submissionId'));

$genres = !empty($args['genres'])
? $args['genres']
: $args['genres'] = DAORegistry::getDAO('GenreDAO')->getByContextId($context->getId())->toArray();
}


Expand Down Expand Up @@ -172,7 +176,7 @@ public function getProperties($galley, $props, $args = null)

$values[$prop] = Repo::submissionFile()
->getSchemaMap()
->map($submissionFile);
->map($submissionFile, $genres);
}
break;
default:
Expand Down Expand Up @@ -256,7 +260,7 @@ public function validate($action, $props, $allowedLocales, $primaryLocale)
});

if ($validator->fails()) {
$errors = $schemaService->formatValidationErrors($validator->errors(), $schemaService->get(PKPSchemaService::SCHEMA_GALLEY), $allowedLocales);
$errors = $schemaService->formatValidationErrors($validator->errors());
}

HookRegistry::call('Galley::validate', [&$errors, $action, $props, $allowedLocales, $primaryLocale]);
Expand Down
9 changes: 4 additions & 5 deletions classes/submission/Repository.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

namespace APP\submission;

use APP\core\Application;
use APP\article\ArticleTombstoneManager;
use APP\core\Application;
use APP\core\Services;
use APP\facades\Repo;
use PKP\db\DAORegistry;

class Repository extends \PKP\submission\Repository
Expand Down Expand Up @@ -58,11 +57,11 @@ public function getInSections(int $issueId, int $contextId): array
}

/** @copydoc \PKP\submission\Repo::updateStatus() */
public function updateStatus(Submission $submission)
public function updateStatus(Submission $submission, ?int $newStatus = null)
{
$oldStatus = $submission->getData('status');
parent::updateStatus($submission);
$newStatus = Repo::submission()->get($submission->getId())->getData('status');
parent::updateStatus($submission, $newStatus);
$newStatus = $submission->getData('status');

// Add or remove tombstones when submission is published or unpublished
if ($newStatus === Submission::STATUS_PUBLISHED && $newStatus !== $oldStatus) {
Expand Down
24 changes: 0 additions & 24 deletions classes/submission/reviewer/ReviewerSubmission.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class ReviewerSubmission extends Submission
/** @var array SubmissionComments peer review comments of this submission */
public $peerReviewComments;

/** @var array the editor decisions of this submission */
public $editorDecisions;


/**
* Get/Set Methods.
*/
Expand Down Expand Up @@ -115,26 +111,6 @@ public function setReviewerFullName($reviewerFullName)
$this->setData('reviewerFullName', $reviewerFullName);
}

/**
* Get editor decisions.
*
* @return array
*/
public function getDecisions()
{
return $this->editorDecisions;
}

/**
* Set editor decisions.
*
* @param array $editorDecisions
*/
public function setDecisions($editorDecisions)
{
return $this->editorDecisions = $editorDecisions;
}

/**
* Get reviewer recommendation.
*
Expand Down
5 changes: 0 additions & 5 deletions classes/submission/reviewer/ReviewerSubmissionDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public function _fromRow($row)
$reviewerSubmission->setAllData($submission->getAllData());
$reviewer = Repo::user()->get($row['reviewer_id'], true);

// Editor Decisions
$editDecisionDao = DAORegistry::getDAO('EditDecisionDAO'); /** @var EditDecisionDAO $editDecisionDao */
$decisions = $editDecisionDao->getEditorDecisions($row['submission_id']);
$reviewerSubmission->setDecisions($decisions);

// Review Assignment
$reviewerSubmission->setReviewId($row['review_id']);
$reviewerSubmission->setReviewerId($row['reviewer_id']);
Expand Down
Loading

0 comments on commit ce45de3

Please sign in to comment.