Skip to content

Commit

Permalink
pkp#10315 Move ORCID connect button to user Identity tab
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham authored and ewhanson committed Aug 19, 2024
1 parent 977beca commit e1cec28
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 deletions.
22 changes: 21 additions & 1 deletion classes/user/form/IdentityForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use APP\core\Application;
use APP\template\TemplateManager;
use PKP\orcid\OrcidManager;
use PKP\user\User;

class IdentityForm extends BaseProfileForm
Expand Down Expand Up @@ -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);
}

Expand All @@ -78,6 +97,7 @@ public function initData()
'givenName' => $user->getGivenName(null),
'familyName' => $user->getFamilyName(null),
'preferredPublicName' => $user->getPreferredPublicName(null),
'orcid' => $user->getOrcid(),
];
}

Expand All @@ -89,7 +109,7 @@ public function readInputData()
parent::readInputData();

$this->readUserVars([
'givenName', 'familyName', 'preferredPublicName',
'givenName', 'familyName', 'preferredPublicName', 'orcid',
]);
}

Expand Down
26 changes: 1 addition & 25 deletions classes/user/form/PublicProfileForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +49,6 @@ public function initData()
$user = $this->getUser();

$this->_data = [
'orcid' => $user->getOrcid(),
'userUrl' => $user->getUrl(),
'biography' => $user->getBiography(null), // Localized
];
Expand All @@ -65,9 +63,7 @@ public function readInputData()
{
parent::readInputData();

$this->readUserVars([
'orcid', 'userUrl', 'biography',
]);
$this->readUserVars(['userUrl', 'biography',]);
}

/**
Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions templates/user/identityForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}

<p>
{capture assign="privacyUrl"}{url router=PKP\core\PKPApplication::ROUTE_PAGE page="about" op="privacy"}{/capture}
{translate key="user.privacyLink" privacyUrl=$privacyUrl}
Expand Down
8 changes: 0 additions & 8 deletions templates/user/publicProfileForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

<p>
Expand Down

0 comments on commit e1cec28

Please sign in to comment.