forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp#5717 Refactor editorial decisions and introduce email composer UI…
… component - Refactor editorial decisions to use EntityDAO and Repo - Add class for each editorial decision type - Add new decision types for back to review, back to copyediting, etc - Add new decision types for reverting declined decisions - Add new decision type for skip review - Add event when decision added - Add API endpoint to record a decision - Add step-by-step workflow page to record decisions - Add steps to send emails, promote files and complete forms - Add composer UI component with template search, file attachments and multiple locales - Add support for file attachments by upload, review files, submission files and library files - Add private API endpoint to get library files - Add email notification to all authors when editorial decision is made - Add file genre of submission files to API responses - Add new email templates for all new email notifications - Update editorial statistics to include skip review as accept decision - Remove EditDecisionDAO, EditorDecisionActionsManager, and related code
- Loading branch information
Showing
199 changed files
with
10,509 additions
and
4,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
|
||
/** | ||
* @file api/v1/_library/PKPLibraryHandler.inc.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 PKPLibraryHandler | ||
* @ingroup api_v1_announcement | ||
* | ||
* @brief Handle API requests for announcement operations. | ||
* | ||
*/ | ||
|
||
use APP\core\Application; | ||
use APP\core\Services; | ||
use APP\file\LibraryFileManager; | ||
use PKP\context\LibraryFile; | ||
use PKP\context\LibraryFileDAO; | ||
use PKP\core\APIResponse; | ||
use PKP\db\DAORegistry; | ||
use PKP\db\DAOResultFactory; | ||
use PKP\handler\APIHandler; | ||
use PKP\security\authorization\PolicySet; | ||
use PKP\security\authorization\RoleBasedHandlerOperationPolicy; | ||
use PKP\security\authorization\SubmissionAccessPolicy; | ||
use PKP\security\Role; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
class PKPLibraryHandler extends APIHandler | ||
{ | ||
public function __construct() | ||
{ | ||
$this->_handlerPath = '_library'; | ||
$this->_endpoints = [ | ||
'GET' => [ | ||
[ | ||
'pattern' => $this->getEndpointPattern(), | ||
'handler' => [$this, 'getLibrary'], | ||
'roles' => [Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], | ||
], | ||
], | ||
]; | ||
parent::__construct(); | ||
|
||
} | ||
|
||
/** | ||
* @copydoc PKPHandler::authorize | ||
*/ | ||
public function authorize($request, &$args, $roleAssignments) | ||
{ | ||
$rolePolicy = new PolicySet(PolicySet::COMBINING_PERMIT_OVERRIDES); | ||
|
||
foreach ($roleAssignments as $role => $operations) { | ||
$rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations)); | ||
} | ||
$this->addPolicy($rolePolicy); | ||
|
||
if ($request->getUserVar('includeSubmissionId')) { | ||
$this->addPolicy(new SubmissionAccessPolicy($request, $args, $roleAssignments, 'includeSubmissionId')); | ||
} | ||
|
||
return parent::authorize($request, $args, $roleAssignments); | ||
} | ||
|
||
/** | ||
* Get a list of all files in the library | ||
* | ||
* @param array $args arguments | ||
* | ||
* @return APIResponse | ||
*/ | ||
public function getLibrary(ServerRequestInterface $slimRequest, APIResponse $response, array $args) | ||
{ | ||
/** @var LibraryFileDAO $libraryFileDao */ | ||
$libraryFileDao = DAORegistry::getDAO('LibraryFileDAO'); | ||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION); | ||
$context = $this->getRequest()->getContext(); | ||
$contextId = $context->getId(); | ||
$libraryFileManager = new LibraryFileManager($contextId); | ||
|
||
$files = []; | ||
|
||
$params = $slimRequest->getQueryParams(); | ||
if (isset($params['includeSubmissionId'])) { | ||
/** @var DAOResultFactory $result */ | ||
$result = $libraryFileDao->getBySubmissionId($submission->getId()); | ||
/** @var LibraryFile $file */ | ||
while ($file = $result->next()) { | ||
$files[] = $this->fileToResponse($file, $libraryFileManager); | ||
} | ||
} | ||
|
||
/** @var DAOResultFactory $result */ | ||
$result = $libraryFileDao->getByContextId($contextId); | ||
/** @var LibraryFile $file */ | ||
while ($file = $result->next()) { | ||
$files[] = $this->fileToResponse($file, $libraryFileManager); | ||
} | ||
|
||
return $response->withJson([ | ||
'items' => $files, | ||
'itemsMax' => count($files), | ||
], 200); | ||
} | ||
|
||
/** | ||
* Convert a file object to the JSON response object | ||
*/ | ||
protected function fileToResponse(LibraryFile $file, LibraryFileManager $libraryFileManager): array | ||
{ | ||
$request = Application::get()->getRequest(); | ||
|
||
$urlArgs = [ | ||
'libraryFileId' => $file->getId(), | ||
]; | ||
if ($file->getSubmissionId()) { | ||
$urlArgs['submissionId'] = $file->getSubmissionId(); | ||
} | ||
|
||
return [ | ||
'id' => $file->getId(), | ||
'filename' => $file->getServerFileName(), | ||
'name' => $file->getName(null), | ||
'mimetype' => $file->getFileType(), | ||
'documentType' => Services::get('file')->getDocumentType($file->getFileType()), | ||
'submissionId' => $file->getSubmissionId() ?? 0, | ||
'type' => $file->getType(), | ||
'typeName' => __($libraryFileManager->getTitleKeyFromType($file->getType())), | ||
'url' => $request->getDispatcher()->url( | ||
$request, | ||
Application::ROUTE_COMPONENT, | ||
null, | ||
'api.file.FileApiHandler', | ||
'downloadLibraryFile', | ||
null, | ||
$urlArgs | ||
), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.