first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/attachment/AuthorOpenReviewAttachmentsGridHandler.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 AuthorOpenReviewAttachmentsGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_attachment
|
||||
*
|
||||
* @brief Handle review attachment grid requests in open reviews (author's perspective)
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\attachment;
|
||||
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\security\Role;
|
||||
|
||||
class AuthorOpenReviewAttachmentsGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
// Show also files that are not viewable by default
|
||||
parent::__construct(
|
||||
new ReviewerReviewAttachmentGridDataProvider(),
|
||||
null
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT, Role::ROLE_ID_AUTHOR],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/attachment/AuthorReviewAttachmentsGridHandler.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 AuthorReviewAttachmentsGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_attachment
|
||||
*
|
||||
* @brief Handle review attachment grid requests (author's perspective)
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\attachment;
|
||||
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\controllers\grid\files\review\ReviewGridDataProvider;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class AuthorReviewAttachmentsGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
parent::__construct(
|
||||
new ReviewGridDataProvider(SubmissionFile::SUBMISSION_FILE_REVIEW_ATTACHMENT, true),
|
||||
null
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT, Role::ROLE_ID_AUTHOR],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
|
||||
// Set the grid title.
|
||||
$this->setTitle('grid.reviewAttachments.title');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/files/attachment/EditorReviewAttachmentsGridHandler.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 EditorReviewAttachmentsGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_attachment
|
||||
*
|
||||
* @brief Editor's view of the Review Attachments Grid.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\attachment;
|
||||
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class EditorReviewAttachmentsGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
parent::__construct(
|
||||
new ReviewerReviewAttachmentGridDataProvider(),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_DELETE | FilesGridCapabilities::FILE_GRID_ADD | FilesGridCapabilities::FILE_GRID_VIEW_NOTES | FilesGridCapabilities::FILE_GRID_EDIT
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT],
|
||||
[
|
||||
'fetchGrid', 'fetchRow'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/attachment/ReviewerReviewAttachmentGridDataProvider.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 ReviewerReviewAttachmentGridDataProvider
|
||||
*
|
||||
* @ingroup controllers_grid_files_attachment
|
||||
*
|
||||
* @brief Provide the reviewers access to their own review attachments data for grids.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\attachment;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use PKP\controllers\api\file\linkAction\AddFileLinkAction;
|
||||
use PKP\controllers\grid\files\SubmissionFilesGridDataProvider;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\security\authorization\internal\ReviewAssignmentRequiredPolicy;
|
||||
use PKP\security\authorization\ReviewStageAccessPolicy;
|
||||
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class ReviewerReviewAttachmentGridDataProvider extends SubmissionFilesGridDataProvider
|
||||
{
|
||||
/** @var int */
|
||||
public $_reviewId;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(SubmissionFile::SUBMISSION_FILE_REVIEW_ATTACHMENT);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Implement template methods from GridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc GridDataProvider::getAuthorizationPolicy()
|
||||
*/
|
||||
public function getAuthorizationPolicy($request, $args, $roleAssignments)
|
||||
{
|
||||
// Need to use the reviewId because this grid can either be
|
||||
// viewed by the reviewer (in which case, we could do a
|
||||
// $request->getUser()->getId() or by the editor when reading
|
||||
// the review. The following covers both cases...
|
||||
$assocType = (int) $request->getUserVar('assocType');
|
||||
$assocId = (int) $request->getUserVar('assocId');
|
||||
if ($assocType && $assocId) {
|
||||
// Viewing from a Reviewer perspective.
|
||||
assert($assocType == Application::ASSOC_TYPE_REVIEW_ASSIGNMENT);
|
||||
|
||||
$this->setUploaderRoles($roleAssignments);
|
||||
|
||||
$authorizationPolicy = new ReviewStageAccessPolicy($request, $args, $roleAssignments, 'submissionId', $request->getUserVar('stageId'));
|
||||
$paramName = 'assocId';
|
||||
} else {
|
||||
// Viewing from a context role perspective.
|
||||
$authorizationPolicy = parent::getAuthorizationPolicy($request, $args, $roleAssignments);
|
||||
$paramName = 'reviewId';
|
||||
}
|
||||
|
||||
$authorizationPolicy->addPolicy(new ReviewAssignmentRequiredPolicy($request, $args, $paramName));
|
||||
|
||||
return $authorizationPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridDataProvider::getRequestArgs()
|
||||
*/
|
||||
public function getRequestArgs()
|
||||
{
|
||||
return array_merge(
|
||||
parent::getRequestArgs(),
|
||||
[
|
||||
'assocType' => Application::ASSOC_TYPE_REVIEW_ASSIGNMENT,
|
||||
'assocId' => $this->_getReviewId()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridDataProvider::loadData()
|
||||
*/
|
||||
public function loadData($filter = [])
|
||||
{
|
||||
$submissionFiles = Repo::submissionFile()
|
||||
->getCollector()
|
||||
->filterByAssoc(
|
||||
Application::ASSOC_TYPE_REVIEW_ASSIGNMENT,
|
||||
[$this->_getReviewId()]
|
||||
)->filterBySubmissionIds([$this->getSubmission()->getId()])
|
||||
->getMany()
|
||||
->toArray();
|
||||
return $this->prepareSubmissionFileData($submissionFiles, false, $filter);
|
||||
}
|
||||
|
||||
//
|
||||
// Overridden public methods from FilesGridDataProvider
|
||||
//
|
||||
/**
|
||||
* @copydoc FilesGridDataProvider::getAddFileAction()
|
||||
*/
|
||||
public function getAddFileAction($request)
|
||||
{
|
||||
$submission = $this->getSubmission();
|
||||
|
||||
$reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /** @var ReviewAssignmentDAO $reviewAssignmentDao */
|
||||
$reviewAssignment = $reviewAssignmentDao->getById($this->_getReviewId());
|
||||
|
||||
return new AddFileLinkAction(
|
||||
$request,
|
||||
$submission->getId(),
|
||||
$this->getStageId(),
|
||||
$this->getUploaderRoles(),
|
||||
$this->getFileStage(),
|
||||
Application::ASSOC_TYPE_REVIEW_ASSIGNMENT,
|
||||
$this->_getReviewId(),
|
||||
$reviewAssignment->getReviewRoundId()
|
||||
);
|
||||
}
|
||||
//
|
||||
// Private helper methods
|
||||
//
|
||||
/**
|
||||
* Get the review id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function _getReviewId()
|
||||
{
|
||||
$reviewAssignment = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REVIEW_ASSIGNMENT);
|
||||
return $reviewAssignment->getId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* @file controllers/grid/files/attachment/ReviewerReviewAttachmentsGridHandler.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 ReviewerReviewAttachmentsGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_files_attachment
|
||||
*
|
||||
* @brief Handle file grid requests.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\grid\files\attachment;
|
||||
|
||||
use PKP\controllers\grid\files\fileList\FileListGridHandler;
|
||||
use PKP\controllers\grid\files\FilesGridCapabilities;
|
||||
use PKP\security\Role;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class ReviewerReviewAttachmentsGridHandler extends FileListGridHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Pass in null stageId to be set in initialize from request var.
|
||||
parent::__construct(
|
||||
new ReviewerReviewAttachmentGridDataProvider(),
|
||||
null,
|
||||
FilesGridCapabilities::FILE_GRID_ADD | FilesGridCapabilities::FILE_GRID_DELETE | FilesGridCapabilities::FILE_GRID_EDIT
|
||||
);
|
||||
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_REVIEWER],
|
||||
[
|
||||
'fetchGrid', 'fetchRow'
|
||||
]
|
||||
);
|
||||
|
||||
// Set the grid title.
|
||||
$this->setTitle('reviewer.submission.reviewerFiles');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc FileListGridHandler::initialize()
|
||||
*
|
||||
* @param null|mixed $args
|
||||
*/
|
||||
public function initialize($request, $args = null)
|
||||
{
|
||||
// Watch for flag from including template to warn about the
|
||||
// review already being complete. If so, remove some capabilities.
|
||||
$capabilities = $this->getCapabilities();
|
||||
if ($request->getUserVar('reviewIsClosed')) {
|
||||
$capabilities->setCanAdd(false);
|
||||
$capabilities->setCanDelete(false);
|
||||
}
|
||||
|
||||
parent::initialize($request, $args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user