Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional fixes and text changes for the about page Stable 3 1 2 #77

Open
wants to merge 15 commits into
base: stable-3_1_2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 56 additions & 37 deletions OrcidProfilePlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
define('ORCID_EMAIL_URL', 'email');
define('ORCID_WORK_URL', 'work');

class OrcidProfilePlugin extends GenericPlugin {
class OrcidProfilePlugin extends GenericPlugin {
const PUBID_TO_ORCID_EXT_ID = [ "doi" => "doi", "other::urn" => "urn"];
const USERGROUP_TO_ORCID_ROLE = [ "Author" => "AUTHOR", "Translator" => "CHAIR_OR_TRANSLATOR"];

Expand All @@ -48,7 +48,7 @@ function register($category, $path, $mainContextId = null) {
if ($success && $this->getEnabled($mainContextId)) {
// Register callback for Smarty filters; add CSS
HookRegistry::register('TemplateManager::display', array($this, 'handleTemplateDisplay'));
// Add "Connect ORCID" button to PublicProfileForm
// Add "Connect ORCID" button to PublicProfileForm
HookRegistry::register('User::PublicProfile::AdditionalItems', array($this, 'handleUserPublicProfileDisplay'));
// Display additional ORCID access information and checkbox to send e-mail to authors in the AuthorForm
HookRegistry::register('authorform::display', array($this, 'handleFormDisplay'));
Expand Down Expand Up @@ -207,7 +207,7 @@ function handleTemplateDisplay($hookName, $args) {
$authors = $article->getAuthors();
foreach ($authors as $author) {
if(!empty($author->getOrcid()) && !empty($author->getData('orcidAccessToken'))) {
$script .= '$("a[href=\"'.$author->getOrcid().'\"]").prepend(orcidIconSvg);';
$script .= '$("a[href=\"'.$author->getOrcid().'\"]").html(orcidIconSvg + "' . $author->getOrcid() . '");';
}
}
$templateMgr->addJavaScript('orcidIconDisplay', $script, ['inline' => true]);
Expand All @@ -231,19 +231,32 @@ function getOauthPath() {
* @return string
*/
function getOrcidUrl() {
if ($this->usingSandbox()) {
return ORCID_URL_SANDBOX;
} else {
return ORCID_URL;
}
}

/**
* Check if the plugin is configured to use the ORCID Sandbox API
*
* @return boolean true if using the ORCID Sandbox API, false otherwise
*/
function usingSandbox() {
$context = Request::getContext();
$contextId = ($context == null) ? 0 : $context->getId();

$apiPath = $this->getSetting($contextId, 'orcidProfileAPIPath');
if ($apiPath == ORCID_API_URL_PUBLIC || $apiPath == ORCID_API_URL_MEMBER) {
return ORCID_URL;
if ($apiPath == ORCID_API_URL_PUBLIC_SANDBOX || $apiPath == ORCID_API_URL_MEMBER_SANDBOX) {
return true;
} else {
return ORCID_URL_SANDBOX;
return false;
}
}

/**
* Return an ORCID OAuth authorization link with
* Return an ORCID OAuth authorization link with
*
* @param $handlerMethod string containting a valid method of the OrcidHandler
* @param $redirectParams Array associative array with additional request parameters for the redirect URL
Expand All @@ -262,7 +275,7 @@ function buildOAuthUrl($handlerMethod, $redirectParams) {
$scope = ORCID_API_SCOPE_PUBLIC;
}
// We need to construct a page url, but the request is using the component router.
// Use the Dispatcher to construct the url and set the page router.
// Use the Dispatcher to construct the url and set the page router.
$redirectUrl = $request->getDispatcher()->url($request, ROUTE_PAGE, null, 'orcidapi',
$handlerMethod, null, $redirectParams);
return $this->getOauthPath() . 'authorize?' . http_build_query(array(
Expand Down Expand Up @@ -304,7 +317,7 @@ function registrationFilter($output, $templateMgr) {

/**
* Renders additional content for the PublicProfileForm.
*
*
* Called by @see lib/pkp/templates/user/publicProfileForm.tpl
*
* @param $output string
Expand All @@ -315,9 +328,12 @@ function handleUserPublicProfileDisplay($hookName, $params) {
$templateMgr =& $params[1];
$output =& $params[2];
$context = Request::getContext();
$user = Request::getUser();
$user = Request::getUser();
$contextId = ($context == null) ? 0 : $context->getId();
$targetOp = 'profile';
if ($user->getOrcid() && $user->getData('orcidSandbox')) {
$templateMgr->assign('orcid', rtrim(ORCID_URL_SANDBOX, '/') . parse_url($user->getOrcid(), PHP_URL_PATH));
}
$templateMgr->assign(array(
'targetOp' => $targetOp,
'orcidUrl' => $this->getOrcidUrl(),
Expand All @@ -326,7 +342,7 @@ function handleUserPublicProfileDisplay($hookName, $params) {
'orcidIcon' => $this->getIcon(),
'orcidAuthenticated' => !empty($user->getData('orcidAccessToken')),
));

$output = $templateMgr->fetch($this->getTemplateResource('orcidProfile.tpl'));
return true;
}
Expand Down Expand Up @@ -365,7 +381,7 @@ function handleAuthorFormExecute($hookname, $args) {
$form->readUserVars(array('requestOrcidAuthorization', 'deleteOrcid'));

$requestAuthorization = $form->getData('requestOrcidAuthorization');
$deleteOrcid = $form->getData('deleteOrcid');
$deleteOrcid = $form->getData('deleteOrcid');
$author = $form->getAuthor();
if ($author && $requestAuthorization) {
$this->sendAuthorMail($author);
Expand Down Expand Up @@ -441,15 +457,16 @@ function handleSubmissionSubmitStep3FormExecute($hookName, $params) {
* @return bool
*/
function handleAdditionalFieldNames($hookName, $params) {
$fields =& $params[1];
$fields =& $params[1];
// the ORCID id was retrieved from the ORCID sandbox API
$fields[] = 'orcidSandbox';
$fields[] = 'orcidAccessToken';
$fields[] = 'orcidAccessScope';
$fields[] = 'orcidRefreshToken';
$fields[] = 'orcidAccessExpiresOn';
$fields[] = 'orcidAccessDenied';
if ($hookName === 'authordao::getAdditionalFieldNames') {
// holds a one time hash string generated before sending the ORCID authorization e-mail
// holds a one time hash string generated before sending the ORCID authorization e-mail
$fields[] = 'orcidEmailToken';
// holds the id of the added work entry in the corresponding ORCID profile for updates
$fields[] = 'orcidWorkPutCode';
Expand Down Expand Up @@ -623,17 +640,17 @@ public function sendAuthorMail($author, $updateAuthor = false)
assert($context != null);
$contextId = $context->getId();
if ( $this->isMemberApiEnabled($contextId) ) {
$mailTemplate = 'ORCID_REQUEST_AUTHOR_AUTHORIZATION';
$mailTemplate = 'ORCID_REQUEST_AUTHOR_AUTHORIZATION';
}
else {
$mailTemplate = 'ORCID_COLLECT_AUTHOR_ID';
$mailTemplate = 'ORCID_COLLECT_AUTHOR_ID';
}
$mail = $this->getMailTemplate($mailTemplate, $context);
$emailToken = md5(microtime().$author->getEmail());
$author->setData('orcidEmailToken', $emailToken);
$articleDao = DAORegistry::getDAO('ArticleDAO');
$article = $articleDao->getById($author->getSubmissionId());
$oauthUrl = $this->buildOAuthUrl('orcidVerify', array('token' => $emailToken, 'articleId' => $author->getSubmissionId()));
$oauthUrl = $this->buildOAuthUrl('orcidVerify', array('token' => $emailToken, 'articleId' => $author->getSubmissionId()));
$aboutUrl = $request->getDispatcher()->url($request, ROUTE_PAGE, null, 'orcidapi', 'about', null);
// Set From to primary journal contact
$mail->setFrom($context->getSetting('contactEmail'), $context->getSetting('contactName'));
Expand Down Expand Up @@ -947,35 +964,37 @@ function($curl, $header) use (&$responseHeaders)
*/
public function buildOrcidWork($article, $journal, $authors, $issue, $request) {
$articleLocale = $article->getLocale();
$titles = $article->getTitle($articleLocale);
$titles = $article->getTitle($articleLocale);
$citationPlugin = PluginRegistry::getPlugin('generic', 'citationstylelanguageplugin');
$bibtexCitation = trim(strip_tags($citationPlugin->getCitation($request, $article, 'bibtex')));
$articleUrl = $request->getDispatcher()->url($request, ROUTE_PAGE, null, 'article', 'view', $article->getBestArticleId());
$orcidWork = [
'title' => [
'title' => [
'value' => $article->getLocalizedTitle($articleLocale)
],
'subtitle' => [
'value' => $article->getSubtitle($articleLocale)
]
],
'journal-title' => [
'value' => $journal->getName('en_US')
'value' => $journal->getLocalizedName($articleLocale)
],
'short-description' => trim(strip_tags($article->getAbstract('en_US'))),
'short-description' => trim(strip_tags($article->getLocalizedData('abstract', $articleLocale))),
'type' => 'JOURNAL_ARTICLE',
'external-ids' => [ 'external-id' => $this->buildOrcidExternalIds($article, $journal, $issue, $articleUrl)],
'publication-date' => $this->buildOrcidPublicationDate($issue),
'url' => $articleUrl,
'citation' => [
'citation-type' => 'BIBTEX',
'citation-value' => $bibtexCitation
],
'language-code' => substr($articleLocale, 0, 2),
'contributors' => [ 'contributor' => $this->buildOrcidContributors($authors, $journal->getId()) ]
];
if ($articleLocale !== 'en_US') {
if ($citationPlugin) {
$bibtexCitation = trim(strip_tags($citationPlugin->getCitation($request, $article, 'bibtex')));
$orcidWork['citation'] = [
'citation-type' => 'BIBTEX',
'citation-value' => $bibtexCitation
];
}
if ($article->getSubtitle($articleLocale)) {
$orcidWork['title']['subtitle'] = [ 'value' => $article->getSubtitle($articleLocale)];
}
if ($articleLocale !== 'en_US' && $article->getTitle('en_US')) {
$orcidWork['title']['translated-title'] = [
'value' => $article->getTitle('en_US'),
'language-code' => 'en'
Expand Down Expand Up @@ -1046,7 +1065,7 @@ private function buildOrcidExternalIds($article, $journal, $issue, $articleUrl)
}
else {
error_log("OrcidProfilePlugin::buildOrcidExternalIds: No pubId plugins could be loaded");
}
}
if ( !$articleHasStoredPubId ) {
// No pubidplugins available or article does not have any stored pubid
// Use URL as an external-id
Expand All @@ -1072,7 +1091,7 @@ private function buildOrcidExternalIds($article, $journal, $issue, $articleUrl)
/**
* Build associative array fitting for ORCID contributor mentions in an
* ORCID work from the supplied Authors array.
*
*
* @param $authors Author[] Array of Author objects
* @param $contextId int Id of the context the Author objects belong to
* @return array[] Array of associative arrays,
Expand Down Expand Up @@ -1116,9 +1135,9 @@ private function buildOrcidContributors($authors, $contextId) {
}

/**
* Remove all data fields, which belong to an ORCID access token from the
* Remove all data fields, which belong to an ORCID access token from the
* given Author object. Also updates fields in the db.
*
*
* @param $author Author object with ORCID access token
* @return void
*/
Expand All @@ -1134,7 +1153,7 @@ public function removeOrcidAccessToken($author, $saveAuthor=true) {
}
}

/**
/**
* @return string Path to a custom ORCID log file.
*/
public static function logFilePath() {
Expand All @@ -1143,7 +1162,7 @@ public static function logFilePath() {

/**
* Write error message to log.
*
*
* @param $message string Message to write
* @return void
*/
Expand All @@ -1153,7 +1172,7 @@ public function logError($message) {

/**
* Write info message to log.
*
*
* @param $message string Message to write
* @return void
*/
Expand All @@ -1168,7 +1187,7 @@ public function logInfo($message) {

/**
* Write a message with specified level to log
*
*
* @param $message string Message to write
* @param $level string Error level to add to message
* @return void
Expand Down
2 changes: 1 addition & 1 deletion OrcidProfileSettingsForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OrcidProfileSettingsForm extends Form {
const CONFIG_VARS = array(
'orcidProfileAPIPath' => 'string',
'orcidClientId' => 'string',
'orcidClientSecret' => 'string',
'orcidClientSecret' => 'string',
'sendMailToAuthorsOnPublication' => 'bool',
'logLevel' => 'string');
/** @var $contextId int */
Expand Down
32 changes: 20 additions & 12 deletions locale/de_DE/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<message key="plugins.generic.orcidProfile.manager.settings.orcidScope">Umfang des ORCID-API Zugriffs</message>
<message key="plugins.generic.orcidProfile.manager.settings.mailSectionTitle">E-Mail Einstellungen</message>
<message key="plugins.generic.orcidProfile.manager.settings.sendMailToAuthorsOnPublication">Sende E-Mails um ORCID Authorisierung von jedem/jeder Beiträger/in eines Artikels bei Veröffentlichung einer Ausgabe anzufragen</message>
<message key="plugins.generic.orcidProfile.manager.settings.logSectionTitle">ORCID Anfragen protokollieren</message>
<message key="plugins.generic.orcidProfile.manager.settings.logSectionTitle">ORCID Anfragen protokollieren</message>
<message key="plugins.generic.orcidProfile.manager.settings.logLevel.help">Wählen Sie die Art der Nachrichten die protokolliert werden sollen</message>
<message key="plugins.generic.orcidProfile.manager.settings.logLevel.error">Fehler</message>
<message key="plugins.generic.orcidProfile.manager.settings.logLevel.all">Alle</message>
Expand All @@ -44,25 +44,33 @@
<message key="plugins.generic.orcidProfile.author.orcidEmptyNotice">Siehe unten zur Authentifizierung der ORCID iD</message>
<message key="plugins.generic.orcidProfile.author.unauthenticated">ORCID iD nicht authentifiziert! Bitte Authorisierung anfragen.</message>
<message key="plugins.generic.orcidProfile.verify.title">ORCID Authorisierung</message>
<message key="plugins.generic.orcidProfile.verify.sendSubmissionToOrcid.success">Die Einreichung wurde zu Ihrem ORCID-Datensatz hinzugefügt.</message>
<message key="plugins.generic.orcidProfile.verify.sendSubmissionToOrcid.success">Die Einreichung wurde zu Ihrem ORCID-Datensatz hinzugefügt.</message>
<message key="plugins.generic.orcidProfile.verify.sendSubmissionToOrcid.failure">Die Einreichung konnte nicht zu ihrem ORCID-Datensatz hinzugefügt werden.</message>
<message key="plugins.generic.orcidProfile.verify.sendSubmissionToOrcid.notpublished">Die Einreichung wird bei Veröffentlichung zu ihrem ORCID-Datensatz hinzugefügt werden.</message>
<message key="plugins.generic.orcidProfile.verify.success">Ihre ORCID-ID wurde verifiziert und die Einreichung erfolgreich mit Ihrer ORCID-ID verknüpft.</message>
<message key="plugins.generic.orcidProfile.verify.failure">Ihre ORCID-ID konnte nicht verifiziert werden oder der Link ist nicht mehr gültig.</message>
<message key="plugins.generic.orcidProfile.verify.denied">Sie haben den Zugriff auf Ihren ORCID-Datensatz abgelehnt.</message>
<message key="plugins.generic.orcidProfile.verify.failure">Ihre ORCID-ID konnte nicht verifiziert werden oder der Link ist nicht mehr gültig.</message>
<message key="plugins.generic.orcidProfile.verify.denied">Sie haben den Zugriff auf Ihren ORCID-Datensatz abgelehnt.</message>
<message key="plugins.generic.orcidProfile.authFailure">OJS konnte nicht mit ORCID kommunizieren.</message>

<message key="plugins.generic.orcidProfile.failure.contact">Bitte kontaktieren Sie den/die Zeitschriftenverwalter/in und geben Sie Ihren Namen, ORCID-iD und Details zu der Einreichung an.</message>
<message key="plugins.generic.orcidProfile.failure.contact">Bitte kontaktieren Sie den/die Zeitschriftenverwalter/in und geben Sie Ihren Namen, ORCID-iD und Details zu der Einreichung an.</message>
<message key="plugins.generic.orcidProfile.fieldset">ORCID</message>
<message key="plugins.generic.orcidProfile.connect">ORCID iD anlegen und verknüpfen</message>
<message key="plugins.generic.orcidProfile.authorise">ORCID iD authorisieren und verknüpfen</message>
<message key="plugins.generic.orcidProfile.about.title">Was ist ORCID?</message>
<message key="plugins.generic.orcidProfile.about.orcidExplanation">Dies ist eine kurze orcid beschreibung</message>
<message key="plugins.generic.orcidProfile.about.title">Über ORCID</message>
<message key="plugins.generic.orcidProfile.about.orcidExplanation"><![CDATA[ORCID ist eine unabhängige gemeinnützige Organisation, die eine dauerhafte ID bereitstellt – die ORCID-iD –, mit der Sie von anderen Forschenden unterschieden werden können, und einen Mechanismus, um um Forschungsergebnisse und -aktivitäten mit Ihrer iD zu verknüpfen.<br>
ORCID ist in viele Systeme integriert, die von Verlagen, Forschungsförderern, Institutionen und anderen forschungsbezogenen Diensten genutzt werden.<br>
Erfahren Sie mehr unter <a href="https://www.orcid-de.org">www.orcid-de.org</a>.]]></message>
<message key="plugins.generic.orcidProfile.about.howAndWhy.title">Wie und warum werden ORCID iDs gesammelt?</message>
<message key="plugins.generic.orcidProfile.about.howAndWhy"><![CDATA[This journal is collecting your ORCID iD so we can [add purpose and distinguish between Member API and Public API].
When you click the “Authorize” button in the ORCID popup, we will ask you to share your iD using an authenticated process: either by <a href="https://support.orcid.org/hc/en-us/articles/360006897454">registering for an ORCID iD</a> or, if you already have one, <a href="https://support.orcid.org/hc/en-us/categories/360000661673">to sign into your ORCID account</a>, then granting us permission to get your ORCID iD. We do this to ensure that you are correctly identified and securely connecting your ORCID iD.<br>
Learn more in <a href="https://orcid.org/blog/2017/02/20/whats-so-special-about-signing">What’s so special about signing in.</a>]]></message>
<message key="plugins.generic.orcidProfile.about.purpose.publicapi">sammelt Ihre ORCID iD um Ihr Benutzerkonto und Ihre Veröffentlichungen eindeutig zu identfizieren.</message>
<message key="plugins.generic.orcidProfile.about.purpose.memberapi">sammelt Ihre ORCID iD um Ihr Benutzerkonto und Ihre Veröffentlichungen eindeutig zu identfizieren, sowie Ihren ORCID-Datensatz mit Informationen über Veröffentlichungen bei unserer Zeitschrift zu aktualisieren.</message>
<message key="plugins.generic.orcidProfile.about.authorize"><![CDATA[Wenn Sie die Schaltfläche „Autorisieren“ klicken, werden wir Sie bitten, Ihre iD nach einem Anmeldevorgang mit uns zu teilen: entweder durch die <a href="https://support.orcid.org/hc/en-us/articles/360006897454">Registrierung für eine ORCID-iD (Inhalt in Englisch)</a> oder, falls Sie bereits eine haben, durch die <a href="https://support.orcid.org/hc/en-us/categories/360000661673">Anmeldung in Ihrem ORCID-Konto (Inhalt in Englisch)</a>, und uns dann die Erlaubnis zu erteilen, Ihre ORCID-iD zu erhalten.
Wir tun dies, um sicherzustellen, dass Sie korrekt identifiziert und sicher mit Ihrer ORCID-iD verknüpft werden.<br>
Erfahren Sie mehr darüber, in <a href="https://www.orcid-de.org/was-ist-das-besondere-bei-der-authentifizierung/">„Was das Besondere an der Anmeldung ist“</a>.]]></message>
<message key="plugins.generic.orcidProfile.about.display.title">Wo werden ORCID iDs angezeigt?</message>
<message key="plugins.generic.orcidProfile.about.display"><![CDATA[To acknowledge that you have used your iD and that it has been authenticated, we display the ORCID iD icon <img src="https://orcid.org/sites/default/files/images/orcid_16x16(1).gif" alt="iD icon" width="16" height="16" border="0"> alongside your name on the article page of your submission and on your public user profile.<br>
Learn more in <a href="https://orcid.org/blog/2013/02/22/how-should-orcid-id-be-displayed">How should an ORCID iD be displayed.</a>]]></message>
<message key="plugins.generic.orcidProfile.about.display"><![CDATA[Um zu bestätigen, dass Sie Ihre iD benutzt haben und sie authentifiziert wurde, zeigen wir das ORCID-iD-Icon <img src="https://orcid.org/sites/default/files/images/orcid_16x16(1).gif" alt="iD icon" width="16" height="16" border="0"> neben Ihrem Namen in den Ihnen zugeordneten Veröffentlichungen und auf der Webseite an.<br>
Mehr dazu erfahren Sie unter <a href="https://orcid.org/blog/2013/02/22/how-should-orcid-id-be-displayed">„Wie sollte eine ORCID-iD angezeigt werden“ (Inhalt nur in Englisch)</a>.]]></message>
<message key="plugins.generic.orcidProfile.about.connect.title">Wie hilft es mir die ORCID iD zu teilen?</message>
<message key="plugins.generic.orcidProfile.about.connect"><![CDATA[Indem Sie Ihre iD mit unserer Zeitschrift teilen und uns die Erlaubnis erteilen, Ihren ORCID-Datensatz zu lesen und zu aktualisieren, ermöglichen Sie es uns, Ihnen zu helfen, Ihren Datensatz mit vertrauenswürdigen Informationen zu Ihren Veröffentlich bei unserer Zeitschrift auf dem neuesten Stand zu halten.<br>
Erfahren Sie mehr unter <a href="https://orcid.org/blog/2018/07/27/six-ways-make-your-orcid-id-work-you">„Sechs Möglichkeiten, Ihre ORCID-iD einzusetzen!“ (Inhalt nur in Englisch)</a>.
]]></message>
</locale>
Loading