-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp/pkp-lib#3594 Add entity schema, Context API, and Vue.js forms
- Add journal and site schema - Load journal and site defaults from schema - Add source file for generating API docs using cli tool - Document /context, /site, /temporaryFiles, /context/{id}/themeOptions, /_payments API endpoints - Update journal_settings and site_settings db schema to remove setting_type - Convert journal and site settings forms to Vue.js - Deprecate Context::getSettings() in favor of Context::getData() - Remove unused context settings: copyeditInstructions, refLinkInstructions, metaCitations, authorSelfArchivePolicy - Change sequence to seq in API to match underlying data structure - Add json linting to tests - Add private endpoint for handling payment settings forms - Migrate handling of journal stylesheet to pkp-lib - Migrate active block plugins from plugin_settings to journal_settings - Move article permission reset to tools - Improve authorization failure responses in API - Replace metadata grid with form fields - Remove unused Reading Tools locale strings - Replace journal settings wizard - Rename ListHandlers to ListPanels and move to /components directory - Add licenseTerms in place of copyrightNotice on article landing - Update help panel to avoid using .md extensions, to fix issues with serves which try to serve the actual file instead of routing to our handlers.
- Loading branch information
Showing
289 changed files
with
14,890 additions
and
9,244 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
112 changes: 112 additions & 0 deletions
112
api/v1/_payments/BackendPaymentsSettingsHandler.inc.php
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,112 @@ | ||
<?php | ||
/** | ||
* @file api/v1/_submissions/BackendPaymentsSettingsHandler.inc.php | ||
* | ||
* Copyright (c) 2014-2018 Simon Fraser University | ||
* Copyright (c) 2003-2018 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class BackendPaymentsSettingsHandler | ||
* @ingroup api_v1_backend | ||
* | ||
* @brief A private API endpoint handler for payment settings. It may be | ||
* possible to deprecate this when we have a working endpoint for plugin | ||
* settings. | ||
*/ | ||
import('lib.pkp.classes.handler.APIHandler'); | ||
import('classes.core.ServicesContainer'); | ||
|
||
class BackendPaymentsSettingsHandler extends APIHandler { | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() { | ||
$rootPattern = '/{contextPath}/api/{version}/_payments'; | ||
$this->_endpoints = array_merge_recursive($this->_endpoints, array( | ||
'PUT' => array( | ||
array( | ||
'pattern' => $rootPattern, | ||
'handler' => array($this, 'editPayments'), | ||
'roles' => array( | ||
ROLE_ID_SITE_ADMIN, | ||
ROLE_ID_MANAGER, | ||
), | ||
), | ||
), | ||
)); | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @copydoc PKPHandler::authorize | ||
*/ | ||
public function authorize($request, &$args, $roleAssignments) { | ||
import('lib.pkp.classes.security.authorization.PolicySet'); | ||
$rolePolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES); | ||
|
||
import('lib.pkp.classes.security.authorization.RoleBasedHandlerOperationPolicy'); | ||
foreach ($roleAssignments as $role => $operations) { | ||
$rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations)); | ||
} | ||
$this->addPolicy($rolePolicy); | ||
|
||
return parent::authorize($request, $args, $roleAssignments); | ||
} | ||
|
||
/** | ||
* Receive requests to edit the payments form | ||
* | ||
* @param $slimRequest Request Slim request object | ||
* @param $response Response object | ||
* | ||
* @return Response | ||
*/ | ||
public function editPayments($slimRequest, $response, $args) { | ||
$request = $this->getRequest(); | ||
$context = $request->getContext(); | ||
$params = $slimRequest->getParsedBody(); | ||
$contextService = ServicesContainer::instance()->get('context'); | ||
|
||
// Process query params to format incoming data as needed | ||
foreach ($slimRequest->getParsedBody() as $param => $val) { | ||
switch ($param) { | ||
case 'paymentsEnabled': | ||
$params[$param] = $val === 'true'; | ||
break; | ||
case 'currency': | ||
$params[$param] = (string) $val; | ||
break; | ||
} | ||
} | ||
|
||
if (isset($params['currency'])) { | ||
$errors = $contextService->validate( | ||
VALIDATE_ACTION_EDIT, | ||
['currency' => $params['currency']], | ||
$context->getSupportedLocales(), | ||
$context->getPrimaryLocale() | ||
); | ||
if (!empty($errors)) { | ||
return $response->withStatus(400)->withJson($errors); | ||
} | ||
} | ||
|
||
$paymentPlugins = PluginRegistry::loadCategory('paymethod', true); | ||
$errors = []; | ||
foreach ($paymentPlugins as $paymentPlugin) { | ||
$errors = array_merge( | ||
$errors, | ||
$paymentPlugin->saveSettings($params, $slimRequest, $request) | ||
); | ||
} | ||
if (!empty($errors)) { | ||
return $response->withStatus(400)->withJson($errors); | ||
} | ||
|
||
$context = $contextService->getContext($context->getId()); | ||
$context = $contextService->editContext($context, $params, $request); | ||
|
||
return $response->withJson($params); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
/** | ||
* @defgroup api_v1_backend Backend API requests for payments settings | ||
*/ | ||
|
||
/** | ||
* @file api/v1/_payments/index.php | ||
* | ||
* Copyright (c) 2014-2018 Simon Fraser University | ||
* Copyright (c) 2003-2018 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @ingroup api_v1_backend | ||
* @brief Handle requests for backend API. | ||
* | ||
*/ | ||
|
||
import('api.v1._payments.BackendPaymentsSettingsHandler'); | ||
return new BackendPaymentsSettingsHandler(); |
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,15 @@ | ||
<?php | ||
/** | ||
* @file api/v1/contexts/ContextHandler.inc.php | ||
* | ||
* Copyright (c) 2014-2018 Simon Fraser University | ||
* Copyright (c) 2003-2018 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class ContextHandler | ||
* @ingroup api_v1_contexts | ||
* | ||
* @brief Handle API requests for contexts (journals/presses). | ||
*/ | ||
import('lib.pkp.api.v1.contexts.PKPContextHandler'); | ||
class ContextHandler extends PKPContextHandler { } |
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,17 @@ | ||
<?php | ||
/** | ||
* @defgroup api_v1_contexts Context API requests | ||
*/ | ||
|
||
/** | ||
* @file api/v1/contexts/index.php | ||
* | ||
* Copyright (c) 2014-2018 Simon Fraser University | ||
* Copyright (c) 2003-2018 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @ingroup api_v1_contexts | ||
* @brief Handle API requests for contexts (journals/presses). | ||
*/ | ||
import('api.v1.contexts.ContextHandler'); | ||
return new ContextHandler(); |
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.