Skip to content

Commit

Permalink
pkp/pkp-lib#1660 Customizable Reviewer Recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Jan 10, 2025
1 parent 2ef3c55 commit b0cbeed
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/v1/contexts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@
* @brief Handle API requests for contexts (journals/presses).
*/

$urlParts = explode('/', trim($_SERVER['PATH_INFO'], '/'));

if (in_array('recommendations', $urlParts)) {
return new \PKP\handler\APIHandler(
new \PKP\API\v1\reviewers\recommendations\ReviewerRecommendationController()
);
}

return new \PKP\handler\APIHandler(new \PKP\API\v1\contexts\PKPContextController());
28 changes: 28 additions & 0 deletions classes/migration/install/ReviewerRecommendationsMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* @file classes/migration/install/ReviewerRecommendationsMigration.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ReviewerRecommendationsMigration
*
* @brief
*/

namespace APP\migration\install;

class ReviewerRecommendationsMigration extends \PKP\migration\install\ReviewerRecommendationsMigration
{
public function contextTable(): string
{
return 'journals';
}

public function contextPrimaryKey(): string
{
return 'journal_id';
}
}
37 changes: 37 additions & 0 deletions classes/migration/upgrade/v3_6_0/I1660_ReviewerRecommendations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* @file classes/migration/upgrade/v3_6_0/I1660_ReviewerRecommendations.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I1660_ReviewerRecommendations.php
*
* @brief
*
*/

namespace APP\migration\upgrade\v3_6_0;

use APP\migration\install\ReviewerRecommendationsMigration;

class I1660_ReviewerRecommendations extends \PKP\migration\Migration
{
/**
* Run the migration.
*/
public function up(): void
{
(new ReviewerRecommendationsMigration($this->_installer, $this->_attributes))->up();
}

/**
* Reverse the migration
*/
public function down(): void
{
(new ReviewerRecommendationsMigration($this->_installer, $this->_attributes))->down();
}
}
33 changes: 33 additions & 0 deletions pages/management/SettingsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use APP\components\forms\context\AccessForm;
use APP\components\forms\context\ArchivingLockssForm;
use APP\template\TemplateManager;
use PKP\API\v1\reviewers\recommendations\resources\ReviewerRecommendationResource;
use PKP\components\forms\context\PKPContextStatisticsForm;
use PKP\components\forms\context\PKPDisableSubmissionsForm;
use PKP\components\forms\context\PKPDoiRegistrationSettingsForm;
Expand All @@ -29,11 +30,14 @@
use PKP\components\forms\context\PKPReviewGuidanceForm;
use PKP\components\forms\context\PKPReviewSetupForm;
use PKP\components\forms\context\PKPSearchIndexingForm;
use PKP\components\listPanels\ReviewerRecommendationsListPanel;
use PKP\core\PKPApplication;
use PKP\core\PKPRequest;
use PKP\pages\management\ManagementHandler;
use PKP\plugins\Hook;
use PKP\plugins\PluginRegistry;
use PKP\security\Role;
use PKP\submission\reviewer\recommendation\ReviewerRecommendation;

class SettingsHandler extends ManagementHandler
{
Expand Down Expand Up @@ -77,6 +81,35 @@ public function workflow($args, $request)
$templateMgr->display('management/workflow.tpl');
}

/**
* Add support for review related forms in workflow.
*/
protected function addReviewFormWorkflowSupport(PKPRequest $request): void
{
parent::addReviewFormWorkflowSupport($request);

$templateManager = TemplateManager::getManager($request);
$components = $templateManager->getState('components');

$context = $request->getContext();
$recommendations = ReviewerRecommendation::withContextId($context->getId())->get();

$reviewerRecommendationsListPanel = new ReviewerRecommendationsListPanel(
__('manager.reviewerRecommendations'),
$context,
$this->getSupportedFormLocales($context),
array_values(
ReviewerRecommendationResource::collection($recommendations)
->toArray(app()->get('request'))
),
ReviewerRecommendation::withContextId($context->getId())->count()
);

$components[$reviewerRecommendationsListPanel->id] = $reviewerRecommendationsListPanel->getConfig();
$templateManager->setState(['components' => $components]);
$templateManager->assign('hasCustomizableRecommendation', true);
}

/**
* Add the archive and payments tabs to the distribution settings page
*
Expand Down

0 comments on commit b0cbeed

Please sign in to comment.