-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3594 Get new forms and schema working with OMP
- Convert context getSetting to getData - Move assignedToSection user query arg to OJS - Fix assigned subeditors value in PKPSectionForm - Handle applications (OJS/OMP) that don't allow more than one context - Fix user access help liinks - Remove unused locale strings - Fix docblock for form components - Change journal to context in locale keys - Move several context properties to OJS and move paymentsEnabled from OJS to pkp-lib - Move shared migration scripts from OJS to pkp-lib - Remove references to ASSOC_TYPE_JOURNAL - Move add/edit/delete context into pkp-lib - Fix required citations check - Add app-specific classes for a few forms - Move /_payments API handler to pkp-lib - Update distribution settings tabs - Remove unused DateStringNormalizerFilter and ValidatorDate - Add test helper method for inline TinyMCE controls - Move some CreateContextTest methods to pkp-lib - Fix wrong variable name in WebTestCase::clickButton() - Fix missing competing interests fields in reviewer form - Fix test method to type into inline TinyMCE fields - Remove unused reviewerCompetingInterestsRequired context prop
- Loading branch information
Showing
90 changed files
with
1,012 additions
and
445 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
api/v1/_payments/PKPBackendPaymentsSettingsHandler.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/_payments/PKPBackendPaymentsSettingsHandler.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 PKPBackendPaymentsSettingsHandler | ||
* @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.Services'); | ||
|
||
class PKPBackendPaymentsSettingsHandler 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, 'edit'), | ||
'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 edit($slimRequest, $response, $args) { | ||
$request = $this->getRequest(); | ||
$context = $request->getContext(); | ||
$params = $slimRequest->getParsedBody(); | ||
$contextService = Services::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->get($context->getId()); | ||
$context = $contextService->edit($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
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
classes/components/forms/context/PKPAnnouncementSettingsForm.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
2 changes: 1 addition & 1 deletion
2
classes/components/forms/context/PKPAppearanceAdvancedForm.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
2 changes: 1 addition & 1 deletion
2
classes/components/forms/context/PKPAppearanceSetupForm.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
2 changes: 1 addition & 1 deletion
2
classes/components/forms/context/PKPAuthorGuidelinesForm.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
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
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
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.