diff --git a/classes/author/maps/Schema.php b/classes/author/maps/Schema.php index e8d26444613..3204344970d 100644 --- a/classes/author/maps/Schema.php +++ b/classes/author/maps/Schema.php @@ -1,4 +1,5 @@ hasVerifiedOrcid(); break; + case 'orcidDisplayValue': + $output[$prop] = $item->getOrcidDisplayValue(); + break; default: $output[$prop] = $item->getData($prop); break; diff --git a/classes/identity/Identity.php b/classes/identity/Identity.php index e152a635204..5761043ba88 100644 --- a/classes/identity/Identity.php +++ b/classes/identity/Identity.php @@ -280,6 +280,19 @@ public function getOrcid() return $this->getData('orcid'); } + /** + * Return the string that should be displayed when showing a user's ORCiD + * + */ + public function getOrcidDisplayValue(): ?string + { + if (!$this->getOrcid()) { + return null; + } + + return $this->hasVerifiedOrcid() ? $this->getOrcid() : $this->getOrcid() . ' (' . __('orcid.unauthenticated') . ')'; + } + /** * Set ORCID identifier. * diff --git a/classes/orcid/OrcidManager.php b/classes/orcid/OrcidManager.php index 636d9ccbd15..2640c807531 100644 --- a/classes/orcid/OrcidManager.php +++ b/classes/orcid/OrcidManager.php @@ -79,6 +79,17 @@ public static function getIcon(): string return file_exists($path) ? file_get_contents($path) : ''; } + /** + * Return a string of the ORCiD unauthenticated SVG icon + * + */ + public static function getUnauthenticatedIcon(): string + { + $path = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/templates/images/orcid_unauthenticated.svg'; + return file_exists($path) ? file_get_contents($path) : ''; + } + + /** * Checks if ORCID functionality is enabled. Works at the context-level. */ diff --git a/classes/user/form/IdentityForm.php b/classes/user/form/IdentityForm.php index 0fc0da6348f..315f1742a38 100644 --- a/classes/user/form/IdentityForm.php +++ b/classes/user/form/IdentityForm.php @@ -77,7 +77,9 @@ public function fetch($request, $template = null, $display = false) 'orcidOAuthUrl' => OrcidManager::buildOAuthUrl('authorizeOrcid', ['targetOp' => $targetOp]), 'orcidClientId' => OrcidManager::getClientId(), 'orcidIcon' => OrcidManager::getIcon(), + 'orcidUnauthenticatedIcon' => OrcidManager::getUnauthenticatedIcon(), 'orcidAuthenticated' => $user !== null && $user->hasVerifiedOrcid(), + 'orcidDisplayValue' => $user->getOrcidDisplayValue(), ]); } else { $templateMgr->assign([ diff --git a/classes/user/maps/Schema.php b/classes/user/maps/Schema.php index 24f39a88528..83bec374d81 100644 --- a/classes/user/maps/Schema.php +++ b/classes/user/maps/Schema.php @@ -1,4 +1,5 @@ context) { $interests = collect(Repo::userInterest()->getInterestsForUser($user)) - ->map(fn($value, $index) => ['id' => $index, 'interest' => $value]) + ->map(fn ($value, $index) => ['id' => $index, 'interest' => $value]) ->values() ->toArray(); @@ -255,6 +256,9 @@ protected function mapByProperties(array $props, User $user, array $auxiliaryDat case 'displayInitials': $output['displayInitials'] = $user->getDisplayInitials(); break; + case 'orcidDisplayValue': + $output[$prop] = $user->getOrcidDisplayValue(); + break; default: $output[$prop] = $user->getData($prop); break; diff --git a/locale/en/user.po b/locale/en/user.po index 3b4976478cf..0f36f9339f1 100644 --- a/locale/en/user.po +++ b/locale/en/user.po @@ -627,6 +627,9 @@ msgstr "See below to request authenticated ORCID iD" msgid "orcid.author.unauthenticated" msgstr "ORCID iD not authenticated! Please request authentication from the contributor." +msgid "orcid.unauthenticated" +msgstr "unauthenticated" + msgid "orcid.verify.title" msgstr "ORCID Authorization" diff --git a/schemas/author.json b/schemas/author.json index 9d6726dc0ba..084b9127683 100644 --- a/schemas/author.json +++ b/schemas/author.json @@ -197,6 +197,14 @@ "orcidVerificationRequested": { "type": "boolean", "apiSummary": false + }, + "orcidDisplayValue": { + "type": "string", + "apiSummary": true, + "readOnly": true, + "validation": [ + "nullable" + ] } } } diff --git a/schemas/user.json b/schemas/user.json index 63ac5e7e50e..7dc5d944f0a 100644 --- a/schemas/user.json +++ b/schemas/user.json @@ -342,6 +342,14 @@ "description": "The initials that will be displayed for a user.", "type": "string", "apiSummary": true + }, + "orcidDisplayValue": { + "type": "string", + "apiSummary": true, + "readOnly": true, + "validation": [ + "nullable" + ] } } } diff --git a/templates/form/orcidProfile.tpl b/templates/form/orcidProfile.tpl index 54dd288a91b..ccaceb0459e 100644 --- a/templates/form/orcidProfile.tpl +++ b/templates/form/orcidProfile.tpl @@ -11,20 +11,25 @@ *} {capture name=orcidButton assign=orcidButton} - + {else} + - {translate key='orcid.about.title'} + + {/if} + + {translate key='orcid.about.title'} {/capture} {capture name=orcidLink assign=orcidLink} {if $orcidAuthenticated} - {$orcidIcon}{$orcid} + {$orcidIcon}{$orcidDisplayValue} {else} {$orcidButton} {/if} diff --git a/templates/frontend/pages/editorialHistory.tpl b/templates/frontend/pages/editorialHistory.tpl index fb6c4d623db..e00b35213be 100644 --- a/templates/frontend/pages/editorialHistory.tpl +++ b/templates/frontend/pages/editorialHistory.tpl @@ -30,7 +30,7 @@ {$mastheadUser['user']->getFullName()|escape} - {if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken')} + {if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken') && $mastheadUser['user']->hasVerifiedOrcid()} getFullName()|escape}"> {$orcidIcon} diff --git a/templates/frontend/pages/editorialMasthead.tpl b/templates/frontend/pages/editorialMasthead.tpl index 50adcf3ca1b..ad2df33625d 100644 --- a/templates/frontend/pages/editorialMasthead.tpl +++ b/templates/frontend/pages/editorialMasthead.tpl @@ -24,8 +24,8 @@ {translate key="common.fromUntil" from=$mastheadUser['dateStart'] until=""} {$mastheadUser['user']->getFullName()|escape} - {if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken')} - + {if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken') && $mastheadUser['user']->hasVerifiedOrcid()} + getFullName()|escape}"> {$orcidIcon} diff --git a/templates/images/orcid_unauthenticated.svg b/templates/images/orcid_unauthenticated.svg new file mode 100644 index 00000000000..9c20929182b --- /dev/null +++ b/templates/images/orcid_unauthenticated.svg @@ -0,0 +1,5 @@ + + + + +