Skip to content

Commit

Permalink
Merge branch 'fixRorRecommendationForOJS330-888' into 'stable-3_3_0'
Browse files Browse the repository at this point in the history
Fixes the author's ROR recommendation notification and adds a record in the activity log when the message is successfully sent.

See merge request softwares-pkp/plugins_ojs/OASwitchboard!40
  • Loading branch information
YvesLepidus committed Sep 23, 2024
2 parents 7c7c0e2 + 144ef73 commit 0caf86a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions OASwitchboardPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function register($category, $path, $mainContextId = null)
$resources = new Resources($this);
HookRegistry::register('Publication::publish', [$message, 'sendToOASwitchboard']);
HookRegistry::register('TemplateManager::display', [$resources, 'addWorkflowNotificationsJavaScript']);
HookRegistry::register('NotificationManager::getNotificationMessage', [$resources, 'addMessageToInformationNotification']);
}
return $success;
}
Expand Down
8 changes: 5 additions & 3 deletions classes/Message.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public function sendToOASwitchboard($hookName, $args)
if ($publication->getData('status') === STATUS_PUBLISHED) {
$OASwitchboard = new OASwitchboardService($this->plugin, $contextId, $submission);
$OASwitchboard->sendP1PioMessage();
$keyMessage = 'plugins.generic.OASwitchboard.sendMessageWithSuccess';
$this->sendNotification($userId, __($keyMessage), NOTIFICATION_TYPE_SUCCESS);
$this->registerSubmissionEventLog($request, $submission, $keyMessage);
if (!OASwitchboardService::isRorAssociated($submission)) {
$keyMessage = 'plugins.generic.OASwitchboard.postRequirementsError.recipient';
$this->sendNotification($userId, __($keyMessage), NOTIFICATION_TYPE_WARNING);
$keyMessage = 'plugins.generic.OASwitchboard.rorRecommendation';
$this->sendNotification($userId, __($keyMessage), NOTIFICATION_TYPE_INFORMATION);
$this->registerSubmissionEventLog($request, $submission, $keyMessage);
}
$this->sendNotification($userId, __('plugins.generic.OASwitchboard.sendMessageWithSuccess'), NOTIFICATION_TYPE_SUCCESS);
}
} catch (P1PioException $e) {
$this->sendNotification($userId, $e->getMessage(), NOTIFICATION_TYPE_WARNING);
Expand Down
9 changes: 9 additions & 0 deletions classes/Resources.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,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 @@ -54,7 +54,7 @@ describe('Send P1-PIO message with success', function () {
cy.get('.pkpPublication > .pkpHeader > .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_US/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_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
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<version>
<application>OASwitchboard</application>
<type>plugins.generic</type>
<release>1.1.1.2</release>
<date>2024-09-20</date>
<release>1.1.1.3</release>
<date>2024-09-23</date>
<lazy-load>1</lazy-load>
<class>OASwitchboardPlugin</class>
</version>

0 comments on commit 0caf86a

Please sign in to comment.