first commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/review/AuthorReviewRevisionsGridHandler.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 AuthorReviewRevisionsGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Display to authors the file revisions that they have uploaded.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class AuthorReviewRevisionsGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_REVISION : SubmissionFile::SUBMISSION_FILE_REVIEW_REVISION;
|
||||
parent::__construct(
|
||||
new ReviewGridDataProvider($fileStage),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_ADD | FilesGridCapabilities::FILE_GRID_EDIT | FilesGridCapabilities::FILE_GRID_DELETE
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_AUTHOR],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
|
||||
$this->setTitle('editor.submission.revisions');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getJSHandler()
|
||||
*/
|
||||
public function getJSHandler()
|
||||
{
|
||||
return '$.pkp.controllers.grid.files.review.AuthorReviewRevisionsGridHandler';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/review/EditorReviewFilesGridHandler.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 EditorReviewFilesGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Handle the editor review file grid (displays files that are to be reviewed in the current round)
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\controllers\grid\files\review\form\ManageReviewFilesForm;
|
||||
use PKP\core\JSONMessage;
|
||||
use PKP\core\PKPRequest;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class EditorReviewFilesGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_FILE : SubmissionFile::SUBMISSION_FILE_REVIEW_FILE;
|
||||
parent::__construct(
|
||||
new ReviewGridDataProvider($fileStage),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_EDIT | FilesGridCapabilities::FILE_GRID_MANAGE | FilesGridCapabilities::FILE_GRID_VIEW_NOTES | FilesGridCapabilities::FILE_GRID_DELETE
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT],
|
||||
['fetchGrid', 'fetchRow', 'selectFiles']
|
||||
);
|
||||
|
||||
$this->setTitle('reviewer.submission.reviewFiles');
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public handler methods
|
||||
//
|
||||
/**
|
||||
* Show the form to allow the user to select review files
|
||||
* (bring in/take out files from submission stage to review stage)
|
||||
*
|
||||
* FIXME: Move to its own handler so that it can be re-used among grids.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON object
|
||||
*/
|
||||
public function selectFiles($args, $request)
|
||||
{
|
||||
$submission = $this->getSubmission();
|
||||
|
||||
$manageReviewFilesForm = new ManageReviewFilesForm($submission->getId(), $this->getRequestArg('stageId'), $this->getRequestArg('reviewRoundId'));
|
||||
|
||||
$manageReviewFilesForm->initData();
|
||||
return new JSONMessage(true, $manageReviewFilesForm->fetch($request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/review/LimitReviewFilesGridHandler.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 LimitReviewFilesGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Display a selectable list of review files for the round to editors.
|
||||
* Items in this list can be selected or deselected to give a specific subset
|
||||
* to a particular reviewer.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\controllers\grid\files\fileList\SelectableFileListGridHandler;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\security\authorization\internal\ReviewAssignmentRequiredPolicy;
|
||||
use PKP\security\authorization\ReviewStageAccessPolicy;
|
||||
use PKP\security\Role;
|
||||
use PKP\submission\ReviewFilesDAO;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class LimitReviewFilesGridHandler extends SelectableFileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_FILE : SubmissionFile::SUBMISSION_FILE_REVIEW_FILE;
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
parent::__construct(
|
||||
new ReviewGridDataProvider($fileStage),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_VIEW_NOTES
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
|
||||
// Set the grid information.
|
||||
$this->setTitle('editor.submissionReview.restrictFiles');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
if ($reviewAssignmentId = $request->getUserVar('reviewAssignmentId')) {
|
||||
// If a review assignment ID is specified, preload the
|
||||
// checkboxes with the currently selected files. To do
|
||||
// this, we'll need the review assignment in the context.
|
||||
// Add the required policies:
|
||||
|
||||
// 1) Review stage access policy (fetches submission in context)
|
||||
$this->addPolicy(new ReviewStageAccessPolicy($request, $args, $roleAssignments, 'submissionId', $request->getUserVar('stageId')));
|
||||
|
||||
// 2) Review assignment
|
||||
$this->addPolicy(new ReviewAssignmentRequiredPolicy($request, $args, 'reviewAssignmentId', ['fetchGrid', 'fetchRow']));
|
||||
}
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::isDataElementSelected()
|
||||
*/
|
||||
public function isDataElementSelected($gridDataElement)
|
||||
{
|
||||
$reviewAssignment = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REVIEW_ASSIGNMENT);
|
||||
if ($reviewAssignment) {
|
||||
$submissionFile = $gridDataElement['submissionFile'];
|
||||
// A review assignment was specified in the request; preset the
|
||||
// checkboxes to the currently available set of files.
|
||||
$reviewFilesDao = DAORegistry::getDAO('ReviewFilesDAO'); /** @var ReviewFilesDAO $reviewFilesDao */
|
||||
return $reviewFilesDao->check($reviewAssignment->getId(), $submissionFile->getId());
|
||||
} else {
|
||||
// No review assignment specified; default to all files available.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/review/ManageReviewFilesGridHandler.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 ManageReviewFilesGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Handle the editor review file selection grid (selects which files to send to review or to next review round)
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\notification\NotificationManager;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\controllers\grid\files\review\form\ManageReviewFilesForm;
|
||||
use PKP\controllers\grid\files\SelectableSubmissionFileListCategoryGridHandler;
|
||||
use PKP\core\JSONMessage;
|
||||
use PKP\core\PKPRequest;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class ManageReviewFilesGridHandler extends SelectableSubmissionFileListCategoryGridHandler
|
||||
{
|
||||
/** @var array */
|
||||
public $_selectionArgs;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_FILE : SubmissionFile::SUBMISSION_FILE_REVIEW_FILE;
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
parent::__construct(
|
||||
new ReviewCategoryGridDataProvider($fileStage),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_ADD | FilesGridCapabilities::FILE_GRID_VIEW_NOTES
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT],
|
||||
['fetchGrid', 'fetchCategory', 'fetchRow', 'updateReviewFiles']
|
||||
);
|
||||
|
||||
// Set the grid title.
|
||||
$this->setTitle('reviewer.submission.reviewFiles');
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public handler methods
|
||||
//
|
||||
/**
|
||||
* Save 'manage review files' form.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON object
|
||||
*/
|
||||
public function updateReviewFiles($args, $request)
|
||||
{
|
||||
$submission = $this->getSubmission();
|
||||
|
||||
$manageReviewFilesForm = new ManageReviewFilesForm($submission->getId(), $this->getRequestArg('stageId'), $this->getRequestArg('reviewRoundId'));
|
||||
$manageReviewFilesForm->readInputData();
|
||||
|
||||
if ($manageReviewFilesForm->validate()) {
|
||||
$dataProvider = $this->getDataProvider();
|
||||
$manageReviewFilesForm->execute(
|
||||
$this->getGridCategoryDataElements($request, $this->getStageId())
|
||||
);
|
||||
|
||||
$this->setupTemplate($request);
|
||||
$user = $request->getUser();
|
||||
$notificationManager = new NotificationManager();
|
||||
$notificationManager->createTrivialNotification($user->getId(), PKPNotification::NOTIFICATION_TYPE_SUCCESS, ['contents' => __('notification.updatedReviewFiles')]);
|
||||
|
||||
// Let the calling grid reload itself
|
||||
return \PKP\db\DAO::getDataChangedEvent();
|
||||
} else {
|
||||
return new JSONMessage(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Extended methods from CategoryGridHandler.
|
||||
//
|
||||
/**
|
||||
* @copydoc CategoryGridHandler::getRequestArgs()
|
||||
*/
|
||||
public function getRequestArgs()
|
||||
{
|
||||
$stageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);
|
||||
return array_merge(['stageId' => $stageId], parent::getRequestArgs());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/review/ReviewCategoryGridDataProvider.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 ReviewCategoryGridDataProvider
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Provide access to review file data for category grids.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use PKP\controllers\grid\files\SubmissionFilesCategoryGridDataProvider;
|
||||
use PKP\submission\reviewRound\ReviewRound;
|
||||
|
||||
class ReviewCategoryGridDataProvider extends SubmissionFilesCategoryGridDataProvider
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $fileStage
|
||||
* @param int $viewableOnly Will be passed to the review grid data provider.
|
||||
* See parameter description there.
|
||||
*/
|
||||
public function __construct($fileStage, $viewableOnly = false)
|
||||
{
|
||||
parent::__construct($fileStage, ['viewableOnly' => $viewableOnly]);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and setters.
|
||||
//
|
||||
/**
|
||||
* @return ReviewRound
|
||||
*/
|
||||
public function getReviewRound()
|
||||
{
|
||||
/** @var ReviewGridDataProvider */
|
||||
$gridDataProvider = $this->getDataProvider();
|
||||
return $gridDataProvider->getReviewRound();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overriden public methods from SubmissionFilesCategoryGridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc SubmissionFilesCategoryGridDataProvider::loadCategoryData()
|
||||
*
|
||||
* @param null|mixed $filter
|
||||
* @param null|mixed $reviewRound
|
||||
*/
|
||||
public function loadCategoryData($request, $categoryDataElement, $filter = null, $reviewRound = null)
|
||||
{
|
||||
$reviewRound = $this->getReviewRound();
|
||||
return parent::loadCategoryData($request, $categoryDataElement, $filter, $reviewRound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc SubmissionFilesCategoryGridDataProvider::initGridDataProvider()
|
||||
*
|
||||
* @param null|mixed $initParams
|
||||
*/
|
||||
public function initGridDataProvider($fileStage, $initParams = null)
|
||||
{
|
||||
// This category grid data provider will use almost all the
|
||||
// same implementation of the ReviewGridDataProvider.
|
||||
$reviewFilesGridDataProvider = new ReviewGridDataProvider($fileStage);
|
||||
$reviewFilesGridDataProvider->setViewableOnly($initParams['viewableOnly']);
|
||||
|
||||
return $reviewFilesGridDataProvider;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
/**
|
||||
* @copydoc ReviewGridDataProvider::getSelectAction()
|
||||
*/
|
||||
public function getSelectAction($request)
|
||||
{
|
||||
/** @var ReviewGridDataProvider */
|
||||
$gridDataProvider = $this->getDataProvider();
|
||||
return $gridDataProvider->getSelectAction($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/review/ReviewGridDataProvider.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 ReviewGridDataProvider
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Provide access to review file data for grids.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use PKP\controllers\api\file\linkAction\AddFileLinkAction;
|
||||
use PKP\controllers\grid\files\fileList\linkAction\SelectReviewFilesLinkAction;
|
||||
use PKP\controllers\grid\files\SubmissionFilesGridDataProvider;
|
||||
use PKP\security\authorization\internal\ReviewRoundRequiredPolicy;
|
||||
use PKP\submission\reviewRound\ReviewRound;
|
||||
|
||||
class ReviewGridDataProvider extends SubmissionFilesGridDataProvider
|
||||
{
|
||||
/** @var bool */
|
||||
protected $_showAll;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @copydoc SubmissionFilesGridDataProvider::__construct()
|
||||
*
|
||||
* @param bool $showAll True iff all review round files should be included.
|
||||
*/
|
||||
public function __construct($fileStageId, $viewableOnly = false, $showAll = false)
|
||||
{
|
||||
$this->_showAll = $showAll;
|
||||
parent::__construct($fileStageId, $viewableOnly);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Implement template methods from GridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc GridDataProvider::getAuthorizationPolicy()
|
||||
*/
|
||||
public function getAuthorizationPolicy($request, $args, $roleAssignments)
|
||||
{
|
||||
// Get the parent authorization policy.
|
||||
$policy = parent::getAuthorizationPolicy($request, $args, $roleAssignments);
|
||||
|
||||
// Add policy to ensure there is a review round id.
|
||||
$policy->addPolicy(new ReviewRoundRequiredPolicy($request, $args));
|
||||
|
||||
return $policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridDataProvider::getRequestArgs()
|
||||
*/
|
||||
public function getRequestArgs()
|
||||
{
|
||||
$reviewRound = $this->getReviewRound();
|
||||
return array_merge(
|
||||
parent::getRequestArgs(),
|
||||
[
|
||||
'reviewRoundId' => $reviewRound->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridDataProvider::loadData()
|
||||
*/
|
||||
public function loadData($filter = [])
|
||||
{
|
||||
// Get all review files assigned to this submission.
|
||||
$collector = Repo::submissionFile()
|
||||
->getCollector()
|
||||
->filterBySubmissionIds([$this->getSubmission()->getId()])
|
||||
->filterByReviewRoundIds([$this->getReviewRound()->getId()]);
|
||||
|
||||
if (!$this->_showAll) {
|
||||
$collector = $collector->filterByFileStages([(int) $this->getFileStage()]);
|
||||
}
|
||||
|
||||
return $this->prepareSubmissionFileData($collector->getMany()->toArray(), $this->_viewableOnly, $filter);
|
||||
}
|
||||
|
||||
//
|
||||
// Overridden public methods from FilesGridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc FilesGridDataProvider::getSelectAction()
|
||||
*/
|
||||
public function getSelectAction($request)
|
||||
{
|
||||
$reviewRound = $this->getReviewRound();
|
||||
$modalTitle = __('editor.submission.review.currentFiles', ['round' => $reviewRound->getRound()]);
|
||||
return new SelectReviewFilesLinkAction(
|
||||
$request,
|
||||
$reviewRound,
|
||||
__('editor.submission.uploadSelectFiles'),
|
||||
$modalTitle
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc FilesGridDataProvider::getAddFileAction()
|
||||
*/
|
||||
public function getAddFileAction($request)
|
||||
{
|
||||
$submission = $this->getSubmission();
|
||||
$reviewRound = $this->getReviewRound();
|
||||
|
||||
return new AddFileLinkAction(
|
||||
$request,
|
||||
$submission->getId(),
|
||||
$this->getStageId(),
|
||||
$this->getUploaderRoles(),
|
||||
$this->getFileStage(),
|
||||
null,
|
||||
null,
|
||||
$reviewRound->getId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the review round object.
|
||||
*
|
||||
* @return ReviewRound
|
||||
*/
|
||||
public function getReviewRound()
|
||||
{
|
||||
$reviewRound = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REVIEW_ROUND);
|
||||
return $reviewRound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/review/ReviewRevisionsGridDataProvider.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 ReviewRevisionsGridDataProvider
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Provide access to review revisions (new files added during a
|
||||
* review round) for grids.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use PKP\controllers\api\file\linkAction\AddRevisionLinkAction;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class ReviewRevisionsGridDataProvider extends ReviewGridDataProvider
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_REVISION : SubmissionFile::SUBMISSION_FILE_REVIEW_REVISION;
|
||||
parent::__construct($fileStage);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Implement template methods from GridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc GridDataProvider::loadData()
|
||||
*/
|
||||
public function loadData($filter = [])
|
||||
{
|
||||
// Grab the files that are new (incoming) revisions
|
||||
// of those currently assigned to the review round.
|
||||
$submissionFiles = Repo::submissionFile()
|
||||
->getCollector()
|
||||
->filterBySubmissionIds([$this->getSubmission()->getId()])
|
||||
->filterByReviewRoundIds([$this->getReviewRound()->getId()])
|
||||
->filterByFileStages([(int) $this->getFileStage()])
|
||||
->getMany()
|
||||
->toArray();
|
||||
|
||||
return $this->prepareSubmissionFileData($submissionFiles, false, $filter);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden public methods from FilesGridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc FilesGridDataProvider::getAddFileAction()
|
||||
*/
|
||||
public function getAddFileAction($request)
|
||||
{
|
||||
$reviewRound = $this->getReviewRound();
|
||||
return new AddRevisionLinkAction(
|
||||
$request,
|
||||
$reviewRound,
|
||||
$this->getUploaderRoles()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/review/ReviewerReviewFilesGridDataProvider.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 ReviewerReviewFilesGridDataProvider
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Provide reviewer access to review file data for review file grids.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\security\authorization\internal\ReviewAssignmentRequiredPolicy;
|
||||
use PKP\security\authorization\internal\ReviewRoundRequiredPolicy;
|
||||
use PKP\security\authorization\internal\WorkflowStageRequiredPolicy;
|
||||
use PKP\security\authorization\SubmissionAccessPolicy;
|
||||
use PKP\submission\ReviewFilesDAO;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class ReviewerReviewFilesGridDataProvider extends ReviewGridDataProvider
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_FILE : SubmissionFile::SUBMISSION_FILE_REVIEW_FILE;
|
||||
parent::__construct($fileStage);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Implement template methods from GridDataProvider
|
||||
//
|
||||
/**
|
||||
* @see GridDataProvider::getAuthorizationPolicy()
|
||||
* Override the parent class, which defines a Workflow policy, to allow
|
||||
* reviewer access to this grid.
|
||||
*/
|
||||
public function getAuthorizationPolicy($request, $args, $roleAssignments)
|
||||
{
|
||||
$context = $request->getContext();
|
||||
$policy = new SubmissionAccessPolicy($request, $args, $roleAssignments, 'submissionId', !$context->getData('restrictReviewerFileAccess'));
|
||||
|
||||
$stageId = $request->getUserVar('stageId');
|
||||
$policy->addPolicy(new WorkflowStageRequiredPolicy($stageId));
|
||||
|
||||
// Add policy to ensure there is a review round id.
|
||||
$policy->addPolicy(new ReviewRoundRequiredPolicy($request, $args));
|
||||
|
||||
// Add policy to ensure there is a review assignment for certain operations.
|
||||
$policy->addPolicy(new ReviewAssignmentRequiredPolicy($request, $args, 'reviewAssignmentId'));
|
||||
|
||||
return $policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ReviewerReviewFilesGridDataProvider
|
||||
* Extend the parent class to filter out review round files that aren't allowed
|
||||
* for this reviewer according to ReviewFilesDAO.
|
||||
*
|
||||
* @param array $filter
|
||||
*/
|
||||
public function loadData($filter = [])
|
||||
{
|
||||
$submissionFileData = parent::loadData();
|
||||
$reviewFilesDao = DAORegistry::getDAO('ReviewFilesDAO'); /** @var ReviewFilesDAO $reviewFilesDao */
|
||||
$reviewAssignment = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REVIEW_ASSIGNMENT);
|
||||
foreach ($submissionFileData as $submissionFileId => $fileData) {
|
||||
if (!$reviewFilesDao->check($reviewAssignment->getId(), $submissionFileId)) {
|
||||
// Not permitted; remove from list.
|
||||
unset($submissionFileData[$submissionFileId]);
|
||||
}
|
||||
}
|
||||
return $submissionFileData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridDataProvider::getRequestArgs()
|
||||
*/
|
||||
public function getRequestArgs()
|
||||
{
|
||||
$reviewAssignment = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REVIEW_ASSIGNMENT);
|
||||
return array_merge(parent::getRequestArgs(), [
|
||||
'reviewAssignmentId' => $reviewAssignment->getId()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/review/ReviewerReviewFilesGridHandler.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.
|
||||
*
|
||||
* @class ReviewerReviewFilesGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Handle the reviewer review file grid (for reviewers to download files to review)
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\security\Role;
|
||||
|
||||
class ReviewerReviewFilesGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
parent::__construct(
|
||||
new ReviewerReviewFilesGridDataProvider(),
|
||||
null
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT, Role::ROLE_ID_REVIEWER],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
|
||||
// Set the grid title.
|
||||
$this->setTitle('reviewer.submission.reviewFiles');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/review/WorkflowReviewRevisionsGridHandler.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 WorkflowReviewRevisionsGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_review
|
||||
*
|
||||
* @brief Display in workflow pages the file revisions that authors have uploaded.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class WorkflowReviewRevisionsGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$stageId = (int) Application::get()->getRequest()->getUserVar('stageId');
|
||||
$fileStage = $stageId === WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_REVISION : SubmissionFile::SUBMISSION_FILE_REVIEW_REVISION;
|
||||
parent::__construct(
|
||||
new ReviewGridDataProvider($fileStage),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_ADD | FilesGridCapabilities::FILE_GRID_EDIT | FilesGridCapabilities::FILE_GRID_VIEW_NOTES | FilesGridCapabilities::FILE_GRID_DELETE
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT],
|
||||
['fetchGrid', 'fetchRow', 'addFile']
|
||||
);
|
||||
|
||||
$this->setTitle('editor.submission.revisions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/review/form/ManageReviewFilesForm.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.
|
||||
*
|
||||
* @class ManageReviewFilesForm
|
||||
*
|
||||
* @ingroup controllers_grid_files_review_form
|
||||
*
|
||||
* @brief Form for add or removing files from a review
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\review\form;
|
||||
|
||||
use APP\facades\Repo;
|
||||
use PKP\controllers\grid\files\form\ManageSubmissionFilesForm;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\submission\reviewRound\ReviewRound;
|
||||
use PKP\submission\reviewRound\ReviewRoundDAO;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class ManageReviewFilesForm extends ManageSubmissionFilesForm
|
||||
{
|
||||
/** @var int */
|
||||
public $_stageId;
|
||||
|
||||
/** @var int */
|
||||
public $_reviewRoundId;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($submissionId, $stageId, $reviewRoundId)
|
||||
{
|
||||
parent::__construct($submissionId, 'controllers/grid/files/review/manageReviewFiles.tpl');
|
||||
$this->_stageId = (int)$stageId;
|
||||
$this->_reviewRoundId = (int)$reviewRoundId;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters / Setters
|
||||
//
|
||||
/**
|
||||
* Get the review stage id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStageId()
|
||||
{
|
||||
return $this->_stageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the round
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getReviewRoundId()
|
||||
{
|
||||
return $this->_reviewRoundId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ReviewRound
|
||||
*/
|
||||
public function getReviewRound()
|
||||
{
|
||||
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
|
||||
return $reviewRoundDao->getById($this->getReviewRoundId());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden template methods
|
||||
//
|
||||
/**
|
||||
* @copydoc ManageSubmissionFilesForm::initData
|
||||
*/
|
||||
public function initData()
|
||||
{
|
||||
$this->setData('stageId', $this->getStageId());
|
||||
$this->setData('reviewRoundId', $this->getReviewRoundId());
|
||||
|
||||
$reviewRound = $this->getReviewRound();
|
||||
$this->setData('round', $reviewRound->getRound());
|
||||
|
||||
parent::initData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save review round files
|
||||
*
|
||||
* @stageSubmissionFiles array The files that belongs to a file stage
|
||||
* that is currently being used by a grid inside this form.
|
||||
*
|
||||
* @param int $fileStage SubmissionFile::SUBMISSION_FILE_...
|
||||
* @param null|mixed $stageSubmissionFiles
|
||||
*/
|
||||
public function execute($stageSubmissionFiles = null, $fileStage = null, ...$functionArgs)
|
||||
{
|
||||
parent::execute(
|
||||
$stageSubmissionFiles,
|
||||
$this->getReviewRound()->getStageId() == WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? SubmissionFile::SUBMISSION_FILE_INTERNAL_REVIEW_FILE : SubmissionFile::SUBMISSION_FILE_REVIEW_FILE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc ManageSubmissionFilesForm::importFile()
|
||||
*/
|
||||
protected function importFile($submissionFile, $fileStage)
|
||||
{
|
||||
$newSubmissionFile = parent::importFile($submissionFile, $fileStage);
|
||||
|
||||
Repo::submissionFile()
|
||||
->dao
|
||||
->assignRevisionToReviewRound(
|
||||
$newSubmissionFile,
|
||||
$this->getReviewRound()
|
||||
);
|
||||
|
||||
return $newSubmissionFile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user