Skip to content

Commit

Permalink
Merge branch 'fixRorRecommendation-888' into 'main'
Browse files Browse the repository at this point in the history
Fixes the authors' ROR recommendation notification

See merge request softwares-pkp/plugins_ojs/OASwitchboard!39
  • Loading branch information
YvesLepidus committed Sep 23, 2024
2 parents 31c10d9 + 0002cf5 commit 964aa2b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions OASwitchboardPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function register($category, $path, $mainContextId = null)
$resources = new Resources($this);
Hook::add('Publication::publish', [$message, 'sendToOASwitchboard']);
Hook::add('TemplateManager::display', [$resources, 'addWorkflowNotificationsJavaScript']);
Hook::add('NotificationManager::getNotificationMessage', [$resources, 'addMessageToInformationNotification']);
}
return $success;
}
Expand Down
14 changes: 8 additions & 6 deletions classes/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ public function sendToOASwitchboard($hookName, $args)
if ($publication->getData('status') === Submission::STATUS_PUBLISHED) {
$OASwitchboard = new OASwitchboardService($this->plugin, $contextId, $submission);
$OASwitchboard->sendP1PioMessage();
if (!OASwitchboardService::isRorAssociated($submission)) {
$keyMessage = 'plugins.generic.OASwitchboard.postRequirementsError.recipient';
$this->sendNotification($userId, __($keyMessage), PKPNotification::NOTIFICATION_TYPE_WARNING);
$this->registerSubmissionEventLog($request, $submission, $keyMessage);
}
$keyMessage = 'plugins.generic.OASwitchboard.sendMessageWithSuccess';
$this->sendNotification(
$userId,
__('plugins.generic.OASwitchboard.sendMessageWithSuccess'),
__($keyMessage),
PKPNotification::NOTIFICATION_TYPE_SUCCESS
);
$this->registerSubmissionEventLog($request, $submission, $keyMessage);
if (!OASwitchboardService::isRorAssociated($submission)) {
$keyMessage = 'plugins.generic.OASwitchboard.rorRecommendation';
$this->sendNotification($userId, __($keyMessage), PKPNotification::NOTIFICATION_TYPE_INFORMATION);
$this->registerSubmissionEventLog($request, $submission, $keyMessage);
}
}
} catch (P1PioException $e) {
$this->sendNotification($userId, $e->getMessage(), PKPNotification::NOTIFICATION_TYPE_WARNING);
Expand Down
10 changes: 10 additions & 0 deletions classes/Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use APP\core\Application;
use APP\template\TemplateManager;
use PKP\notification\PKPNotification;
use PKP\db\DAORegistry;

class Resources
{
Expand Down Expand Up @@ -49,4 +50,13 @@ public function addWorkflowNotificationsJavaScript($hookName, $args)

return false;
}

public function addMessageToInformationNotification($hookName, $args)
{
$notification = & $args[0];
$message = & $args[1];
$notificationSettingsDao = DAORegistry::getDAO('NotificationSettingsDAO');
$notificationSettings = $notificationSettingsDao->getNotificationSettings($notification->getId());
$message = $notificationSettings['contents'];
}
}
2 changes: 1 addition & 1 deletion cypress/tests/Test4_sendMessageSuccess.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Send P1-PIO message with success', function () {
cy.get('.pkpPublication__header > .pkpHeader__actions > button.pkpButton').contains("Schedule For Publication").click();
cy.get('.pkpFormPage__footer button:contains("Publish")').click();

cy.get('.app__notifications').contains("At least one author of the article must have a ROR associated with their affiliation.");
cy.get('.app__notifications').contains("At least one author should have a ROR ID linked to their affiliation (requires the ROR plugin) for the message to be sent to the affiliation.");
cy.get('.app__notifications').contains("The message was successfully sent to the OA Switchboard");
})
})
4 changes: 2 additions & 2 deletions locale/en/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ msgstr "Server error when sending message. The OA Switchboard API server encount
msgid "plugins.generic.OASwitchboard.postRequirementsError"
msgstr "We don't have the mandatory data for sending the message to the OA Switchboard, please check the submission activity log to understand the pending requirements."

msgid "plugins.generic.OASwitchboard.postRequirementsError.recipient"
msgstr "At least one author of the article must have a ROR associated with their affiliation."
msgid "plugins.generic.OASwitchboard.rorRecommendation"
msgstr "At least one author should have a ROR ID linked to their affiliation (requires the ROR plugin) for the message to be sent to the affiliation."

msgid "plugins.generic.OASwitchboard.postRequirementsError.familyName"
msgstr "The family name of an author must be present."
Expand Down
4 changes: 2 additions & 2 deletions locale/es/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ msgstr "Error del servidor al enviar el mensaje. El servidor de la API de OA Swi
msgid "plugins.generic.OASwitchboard.postRequirementsError"
msgstr "No tenemos los datos obligatorios para enviar el mensaje al OA Switchboard, por favor revise el Registro de actividad de lo envío para entender los requisitos pendientes."

msgid "plugins.generic.OASwitchboard.postRequirementsError.recipient"
msgstr "Al menos uno de los autores del artículo debe tener un ROR asociado con su afiliación."
msgid "plugins.generic.OASwitchboard.rorRecommendation"
msgstr "Al menos un autor debe tener un ID ROR vinculado a su afiliación (requiere el plugin ROR) para que el mensaje sea enviado a la afiliación."

msgid "plugins.generic.OASwitchboard.postRequirementsError.familyName"
msgstr "El apellido de un autor debe estar presente."
Expand Down
4 changes: 2 additions & 2 deletions locale/pt_BR/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ msgstr "Erro do servidor ao enviar a mensagem. O servidor da API do OA Switchboa
msgid "plugins.generic.OASwitchboard.postRequirementsError"
msgstr "Não temos os dados obrigatórios para envio da mensagem para o OA Switchboard, verifique o histórico de atividades da submissão para entender os requisitos pendentes."

msgid "plugins.generic.OASwitchboard.postRequirementsError.recipient"
msgstr "Pelo menos um autor do artigo deve ter um ROR associado à sua afiliação."
msgid "plugins.generic.OASwitchboard.rorRecommendation"
msgstr "Pelo menos um autor deve ter um ID ROR vinculado à sua afiliação (requer o plugin ROR) para que a mensagem seja enviada à afiliação."

msgid "plugins.generic.OASwitchboard.postRequirementsError.familyName"
msgstr "O sobrenome de um autor deve estar presente."
Expand Down

0 comments on commit 964aa2b

Please sign in to comment.