diff --git a/classes/user/form/IdentityForm.php b/classes/user/form/IdentityForm.php index df5fb5771f4..d4503e2218f 100644 --- a/classes/user/form/IdentityForm.php +++ b/classes/user/form/IdentityForm.php @@ -18,6 +18,7 @@ use APP\core\Application; use APP\template\TemplateManager; +use PKP\orcid\OrcidManager; use PKP\user\User; class IdentityForm extends BaseProfileForm @@ -64,6 +65,24 @@ public function fetch($request, $template = null, $display = false) 'username' => $user->getUsername(), ]); + // FIXME: ORCID validation/authorization requires a context so this should not appear at the + // site level for the time-being + if ($request->getContext() && OrcidManager::isEnabled()) { + $targetOp = 'profile'; + $templateMgr->assign([ + 'orcidEnabled' => true, + 'targetOp' => $targetOp, + 'orcidUrl' => OrcidManager::getOrcidUrl(), + 'orcidOAuthUrl' => OrcidManager::buildOAuthUrl('authorizeOrcid', ['targetOp' => $targetOp]), + 'orcidClientId' => OrcidManager::getClientId(), + 'orcidIcon' => OrcidManager::getIcon(), + 'orcidAuthenticated' => $user !== null && $user->hasVerifiedOrcid(), + ]); + } else { + $templateMgr->assign([ + 'orcidEnabled' => false, + ]); + } return parent::fetch($request, $template, $display); } @@ -78,6 +97,7 @@ public function initData() 'givenName' => $user->getGivenName(null), 'familyName' => $user->getFamilyName(null), 'preferredPublicName' => $user->getPreferredPublicName(null), + 'orcid' => $user->getOrcid(), ]; } @@ -89,7 +109,7 @@ public function readInputData() parent::readInputData(); $this->readUserVars([ - 'givenName', 'familyName', 'preferredPublicName', + 'givenName', 'familyName', 'preferredPublicName', 'orcid', ]); } diff --git a/classes/user/form/PublicProfileForm.php b/classes/user/form/PublicProfileForm.php index e8ee58ee6bf..cd60aae7dfa 100644 --- a/classes/user/form/PublicProfileForm.php +++ b/classes/user/form/PublicProfileForm.php @@ -21,7 +21,6 @@ use APP\file\PublicFileManager; use APP\template\TemplateManager; use PKP\core\Core; -use PKP\orcid\OrcidManager; use PKP\user\User; class PublicProfileForm extends BaseProfileForm @@ -50,7 +49,6 @@ public function initData() $user = $this->getUser(); $this->_data = [ - 'orcid' => $user->getOrcid(), 'userUrl' => $user->getUrl(), 'biography' => $user->getBiography(null), // Localized ]; @@ -65,9 +63,7 @@ public function readInputData() { parent::readInputData(); - $this->readUserVars([ - 'orcid', 'userUrl', 'biography', - ]); + $this->readUserVars(['userUrl', 'biography',]); } /** @@ -160,26 +156,6 @@ public function fetch($request, $template = null, $display = false) 'publicSiteFilesPath' => $publicFileManager->getSiteFilesPath(), ]); - // FIXME: ORCID validation/authorization requires a context so this should not appear at the - // site level for the time-being - if ($request->getContext() !== null && OrcidManager::isEnabled()) { - $user = $request->getUser(); - $targetOp = 'profile'; - $templateMgr->assign([ - 'orcidEnabled' => true, - 'targetOp' => $targetOp, - 'orcidUrl' => OrcidManager::getOrcidUrl(), - 'orcidOAuthUrl' => OrcidManager::buildOAuthUrl('authorizeOrcid', ['targetOp' => $targetOp]), - 'orcidClientId' => OrcidManager::getClientId(), - 'orcidIcon' => OrcidManager::getIcon(), - 'orcidAuthenticated' => $user !== null && !empty($user->hasVerifiedOrcid()), - ]); - } else { - $templateMgr->assign([ - 'orcidEnabled' => false, - ]); - } - return parent::fetch($request, $template, $display); } diff --git a/templates/user/identityForm.tpl b/templates/user/identityForm.tpl index 3602b183fee..032281e9823 100644 --- a/templates/user/identityForm.tpl +++ b/templates/user/identityForm.tpl @@ -40,6 +40,14 @@ {fbvElement type="text" label="user.preferredPublicName" multilingual="true" name="preferredPublicName" id="preferredPublicName" value=$preferredPublicName size=$fbvStyles.size.LARGE} {/fbvFormSection} + {if $orcidEnabled} + {* FIXME: The form element is still required for "connect ORCID" functionality to work. *} + {fbvFormSection} + {fbvElement type="text" label="user.orcid" name="orcid" id="orcid" value=$orcid maxlength="46"} + {/fbvFormSection} + {include file="form/orcidProfile.tpl"} + {/if} +

{capture assign="privacyUrl"}{url router=PKP\core\PKPApplication::ROUTE_PAGE page="about" op="privacy"}{/capture} {translate key="user.privacyLink" privacyUrl=$privacyUrl} diff --git a/templates/user/publicProfileForm.tpl b/templates/user/publicProfileForm.tpl index c82fe242be8..7a1e5c8cd61 100755 --- a/templates/user/publicProfileForm.tpl +++ b/templates/user/publicProfileForm.tpl @@ -72,14 +72,6 @@ {fbvElement type="text" label="user.url" name="userUrl" id="userUrl" value=$userUrl maxlength="255"} {/fbvFormSection} - {if $orcidEnabled} - {* FIXME: The form element is still required for "connect ORCID" functionality to work. *} - {fbvFormSection} - {fbvElement type="text" label="user.orcid" name="orcid" id="orcid" value=$orcid maxlength="46"} - {/fbvFormSection} - {include file="form/orcidProfile.tpl"} - {/if} - {call_hook name="User::PublicProfile::AdditionalItems"}