Skip to content

Commit

Permalink
pkp#229 OrcidProfilePlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
withanage committed Feb 12, 2023
1 parent b07a3d4 commit ef9e751
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 33 deletions.
31 changes: 1 addition & 30 deletions OrcidProfileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,35 +169,6 @@ public function orcidAuthorize($args, $request)
break;
case 'profile':

Hook::add('Schema::get::user', function ($hookName, $args) {
$schema = &$args[0];

$schema->properties->orcidAccessToken = (object)[
'type' => 'string',
'apiSummary' => true,
'validation' => ['nullable']
];
$schema->properties->orcidAccessScope = (object)[
'type' => 'string',
'apiSummary' => true,
'validation' => ['nullable']
];
$schema->properties->orcidRefreshToken = (object)[
'type' => 'string',
'apiSummary' => true,
'validation' => ['nullable']
];
$schema->properties->orcidAccessExpiresOn = (object)[
'type' => 'string',
'apiSummary' => true,
'validation' => ['nullable']
];
$schema->properties->orcidAccessDenied = (object)[
'type' => 'string',
'apiSummary' => true,
'validation' => ['nullable']
];
});
$user = $request->getUser();
// Store the access token and other data for the user
$this->_setOrcidData($user, $orcidUri, $response);
Expand Down Expand Up @@ -327,7 +298,7 @@ public function orcidVerify($args, $request)
$templateMgr->assign('authFailure', true);
}
// Set the orcid id using the full https uri
$orcidUri = ($this->plugin->getSetting($contextId, 'isSandBox') == true ? ORCID_URL_SANDBOX : ORCID_URL) . $response['orcid'];
$orcidUri = ($this->isSandBox ? ORCID_URL_SANDBOX : ORCID_URL) . $response['orcid'];
if (!empty($authorToVerify->getOrcid()) && $orcidUri != $authorToVerify->getOrcid()) {
// another ORCID id is stored for the author
$templateMgr->assign('duplicateOrcid', true);
Expand Down
30 changes: 27 additions & 3 deletions OrcidProfilePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
use APP\template\TemplateManager;
use Carbon\Carbon;
use Illuminate\Support\Facades\Mail;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldShowEnsuringLink;
use PKP\components\forms\FieldText;
use PKP\components\forms\publication\ContributorForm;
use PKP\config\Config;
use PKP\core\Core;
Expand Down Expand Up @@ -215,25 +218,46 @@ function addOrcidFormFields($hookName, $form): bool
{

if (!$form instanceof ContributorForm) return Hook::CONTINUE;
$publication = $form->submission->getCurrentPublication();

$form->removeField('orcid');

// add Orcid Field to position 6
$form->addField(new FieldText('orcid', [
'label' => __('user.orcid'),
'optIntoEdit' => true,
'optIntoEditLabel' => __('common.override'),
'isLabelInline' => true,
'size' => 'normal',
'showWhen' => 'orcid'

]),[FIELD_POSITION_AFTER, 'url']);



$form->addField(new FieldOptions('requestOrcidAuthorization', [
'label' => __('plugins.generic.orcidProfile.verify.title'),
'options' => [
[
'value' => true,
'label' => __('plugins.generic.orcidProfile.author.requestAuthorization')
'label' => __('plugins.generic.orcidProfile.author.requestAuthorization'),

]
]
]));

$form->addField(new FieldOptions('deleteORCID', [
'label' => __('plugins.generic.orcidProfile.displayName'),
'options' => [
[
'value' => true,
'label' => __('plugins.generic.orcidProfile.author.deleteORCID')
'label' => __('plugins.generic.orcidProfile.author.deleteORCID'),

]
]
]));



return Hook::CONTINUE;
}

Expand Down

0 comments on commit ef9e751

Please sign in to comment.