Skip to content

Commit

Permalink
#3594 Get new forms and schema working with OMP
Browse files Browse the repository at this point in the history
- 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
NateWr committed Jan 9, 2019
1 parent a095fdd commit 16c2c24
Show file tree
Hide file tree
Showing 90 changed files with 1,012 additions and 445 deletions.
112 changes: 112 additions & 0 deletions api/v1/_payments/PKPBackendPaymentsSettingsHandler.inc.php
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);
}
}
1 change: 0 additions & 1 deletion api/v1/users/PKPUserHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ private function _buildListRequestParams($slimRequest) {

case 'assignedToSubmissionStage':
case 'assignedToSubmission':
case 'assignedToSection':
$returnParams[$param] = (int) $val;
break;

Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/Field.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/Field.inc.php
* @file classes/components/form/Field.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldColor.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldColor.inc.php
* @file classes/components/form/FieldColor.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldHTML.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldHTML.inc.php
* @file classes/components/form/FieldHTML.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldMetadataSetting.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldMetadataSetting.inc.php
* @file classes/components/form/FieldMetadataSetting.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldOptions.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldOptions.inc.php
* @file classes/components/form/FieldOptions.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldRadioInput.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldRadioInput.inc.php
* @file classes/components/form/FieldRadioInput.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldRichTextarea.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldRichTextarea.inc.php
* @file classes/components/form/FieldRichTextarea.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldSelect.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldSelect.inc.php
* @file classes/components/form/FieldSelect.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldShowEnsuringLink.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldShowEnsuringLink.inc.php
* @file classes/components/form/FieldShowEnsuringLink.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldText.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldText.inc.php
* @file classes/components/form/FieldText.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldTextarea.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldTextarea.inc.php
* @file classes/components/form/FieldTextarea.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldUpload.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldUpload.inc.php
* @file classes/components/form/FieldUpload.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FieldUploadImage.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FieldUploadImage.inc.php
* @file classes/components/form/FieldUploadImage.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/FormComponent.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/FormComponent.inc.php
* @file classes/components/form/FormComponent.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPAnnouncementSettingsForm.inc.php
* @file classes/components/form/context/PKPAnnouncementSettingsForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPAppearanceAdvancedForm.inc.php
* @file classes/components/form/context/PKPAppearanceAdvancedForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPAppearanceSetupForm.inc.php
* @file classes/components/form/context/PKPAppearanceSetupForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPAuthorGuidelinesForm.inc.php
* @file classes/components/form/context/PKPAuthorGuidelinesForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/context/PKPContactForm.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPContactForm.inc.php
* @file classes/components/form/context/PKPContactForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
8 changes: 4 additions & 4 deletions classes/components/forms/context/PKPContextForm.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPContextForm.inc.php
* @file classes/components/form/context/PKPContextForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down Expand Up @@ -41,21 +41,21 @@ public function __construct($action, $successMessage, $locales, $baseUrl, $conte
$this->method = $context ? 'PUT' : 'POST';

$this->addField(new FieldText('name', [
'label' => __('manager.setup.journalTitle'),
'label' => __('manager.setup.contextTitle'),
'isRequired' => true,
'isMultilingual' => true,
'value' => $context ? $context->getData('name') : null,
]))
->addField(new FieldText('acronym', [
'label' => __('manager.setup.journalInitials'),
'label' => __('manager.setup.contextInitials'),
'size' => 'small',
'isRequired' => true,
'isMultilingual' => true,
'groupId' => 'identity',
'value' => $context ? $context->getData('acronym') : null,
]))
->addField(new FieldRichTextarea('description', [
'label' => __('admin.journals.journalDescription'),
'label' => __('admin.contexts.contextDescription'),
'isMultilingual' => true,
'value' => $context ? $context->getData('description') : null,
]))
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/context/PKPEmailSetupForm.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPEmailSetupForm.inc.php
* @file classes/components/form/context/PKPEmailSetupForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPInformationForm.inc.php
* @file classes/components/form/context/PKPInformationForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
13 changes: 1 addition & 12 deletions classes/components/forms/context/PKPLicenseForm.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPLicenseForm.inc.php
* @file classes/components/form/context/PKPLicenseForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand All @@ -13,7 +13,6 @@
*/
namespace PKP\components\forms\context;
use \PKP\components\forms\FormComponent;
use \PKP\components\forms\FieldOptions;
use \PKP\components\forms\FieldRadioInput;
use \PKP\components\forms\FieldRichTextarea;

Expand Down Expand Up @@ -77,16 +76,6 @@ public function __construct($action, $locales, $context) {
'options' => $licenseUrlOptions,
'value' => $context->getData('licenseUrl'),
]))
->addField(new FieldOptions('copyrightYearBasis', [
'label' => __('submission.copyrightYear'),
'description' => __('manager.distribution.copyrightYearBasis.description'),
'type' => 'radio',
'options' => [
['value' => 'issue', 'label' => __('manager.distribution.copyrightYearBasis.issue')],
['value' => 'submission', 'label' => __('manager.distribution.copyrightYearBasis.submission')],
],
'value' => $context->getData('copyrightYearBasis'),
]))
->addField(new FieldRichTextarea('licenseTerms', [
'label' => __('manager.distribution.licenseTerms'),
'tooltip' => __('manager.distribution.licenseTerms.description'),
Expand Down
2 changes: 1 addition & 1 deletion classes/components/forms/context/PKPListsForm.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @file controllers/form/context/PKPListsForm.inc.php
* @file classes/components/form/context/PKPListsForm.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2000-2018 John Willinsky
Expand Down
Loading

0 comments on commit 16c2c24

Please sign in to comment.