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..9e115e5fd85 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 ''; + } + + return $this->hasVerifiedOrcid() ? $this->getOrcid() : $this->getOrcid() . ' (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/schemas/author.json b/schemas/author.json index 41a676edfb9..efa06ac020e 100644 --- a/schemas/author.json +++ b/schemas/author.json @@ -197,6 +197,13 @@ "orcidVerificationRequested": { "type": "boolean", "apiSummary": false + }, + "orcidDisplayValue": { + "types": "string", + "apiSummary": true, + "validation": [ + "nullable" + ] } } } diff --git a/schemas/user.json b/schemas/user.json index 63ac5e7e50e..049b5bd9707 100644 --- a/schemas/user.json +++ b/schemas/user.json @@ -342,6 +342,13 @@ "description": "The initials that will be displayed for a user.", "type": "string", "apiSummary": true + }, + "orcidDisplayValue": { + "types": "string", + "apiSummary": true, + "validation": [ + "nullable" + ] } } } diff --git a/templates/form/orcidProfile.tpl b/templates/form/orcidProfile.tpl index 54dd288a91b..0dfab7bf403 100644 --- a/templates/form/orcidProfile.tpl +++ b/templates/form/orcidProfile.tpl @@ -11,20 +11,23 @@ *} {capture name=orcidButton assign=orcidButton} - + + {if $orcid && !$orcidAuthenticated } + {$orcidUnauthenticatedIcon}{$orcidDisplayValue} + + {else} +
{$orcidIcon} {translate key='orcid.connect'}
+ {/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/images/orcid_unauthenticated.svg b/templates/images/orcid_unauthenticated.svg new file mode 100644 index 00000000000..7a5927c4167 --- /dev/null +++ b/templates/images/orcid_unauthenticated.svg @@ -0,0 +1,5 @@ + + + + +