Skip to content

Commit

Permalink
Merge branch 'addOASwitchboardTabOnWorkflow34-925' into 'main'
Browse files Browse the repository at this point in the history
Adds P1 message sending status to workflow tab.

See merge request softwares-pkp/plugins_ojs/OASwitchboard!52
  • Loading branch information
YvesLepidus committed Dec 27, 2024
2 parents 5d5dbef + c72202b commit 0f25a3a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 4 deletions.
1 change: 1 addition & 0 deletions OASwitchboardPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function register($category, $path, $mainContextId = null)
if ($success && $this->getEnabled()) {
$message = new Message($this);
$resources = new Resources($this);
Hook::add('Template::Workflow::Publication', [$message, 'addSubmissionStatusToWorkflow']);
Hook::add('Publication::publish', [$message, 'sendToOASwitchboard']);
Hook::add('TemplateManager::display', [$resources, 'addWorkflowNotificationsJavaScript']);
Hook::add('Form::config::before', [$message, 'validateBeforePublicationEvent']);
Expand Down
40 changes: 40 additions & 0 deletions classes/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,46 @@ public function validateBeforePublicationEvent($hookName, $form)
return false;
}

public function addSubmissionStatusToWorkflow($hookName, $params)
{
$smarty = &$params[1];
$output = &$params[2];
$request = Application::get()->getRequest();

$submission = $smarty->getTemplateVars('submission');
$contextId = $request->getContext()->getId();

try {
OASwitchboardService::validatePluginIsConfigured($this->plugin, $contextId);
} catch (\Exception $e) {
$message = '<div class="pkpNotification pkpNotification--information">' . $e->getMessage() . '</div>';
$smarty->assign([
'pluginIsNotConfiguredInfo' => $message,
]);
}

try {
$p1Pio = new P1Pio($submission);
$successMessage = $this->getSubmissionAlreadyToSendMessage($submission);
$smarty->assign([
'submissionIsAlreadySendMessage' => $successMessage,
]);
} catch (P1PioException $e) {
if ($e->getP1PioErrors()) {
$errorMessage = $this->getMandatoryDataErrorMessage($e->getP1PioErrors(), $submission);
$smarty->assign([
'submissionRequirementsIsPending' => $errorMessage,
]);
}
}

$output .= sprintf(
'<tab id="OASwitchboard" label="%s">%s</tab>',
__('plugins.generic.OASwitchboard.workflowTab.label'),
$smarty->fetch($this->plugin->getTemplateResource('submissionStatus.tpl'))
);
}

private function registerSubmissionEventLog($request, $submission, $error)
{
$eventLog = Repo::eventLog()->newDataObject([
Expand Down
6 changes: 6 additions & 0 deletions locale/en/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,9 @@ msgstr "You may review these metadata, or proceed with the publication without s

msgid "plugins.generic.OASwitchboard.postRequirementsSuccess"
msgstr "OA Switchboard: the requirements have been met and the P1 message will be sent to the OA Switchboard upon publishing the submission."

msgid "plugins.generic.OASwitchboard.workflowTab.label"
msgstr "OA Switchboard"

msgid "plugins.generic.OASwitchboard.workflowTab.title"
msgstr "Status of message sent to OA Switchboard"
8 changes: 7 additions & 1 deletion locale/es/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ msgid "plugins.generic.OASwitchboard.postRequirementsError.conclusionText"
msgstr "Puede revisar estos metadatos o continuar con la publicación sin enviar el mensaje al OA Switchboard."

msgid "plugins.generic.OASwitchboard.postRequirementsSuccess"
msgstr "OA Switchboard: se han cumplido los requisitos y el mensaje P1 será enviado al OA Switchboard al publicar la publicacíon."
msgstr "OA Switchboard: se han cumplido los requisitos y el mensaje P1 será enviado al OA Switchboard al publicar la publicacíon."

msgid "plugins.generic.OASwitchboard.workflowTab.label"
msgstr "OA Switchboard"

msgid "plugins.generic.OASwitchboard.workflowTab.title"
msgstr "Estado del Envío del Mensaje al OA Switchboard"
8 changes: 7 additions & 1 deletion locale/pt_BR/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ msgid "plugins.generic.OASwitchboard.postRequirementsError.conclusionText"
msgstr "Você pode rever estes metadados, ou continuar com a publicação sem o envio da mensagem para o OA Switchboard."

msgid "plugins.generic.OASwitchboard.postRequirementsSuccess"
msgstr "OA Switchboard: os requisitos foram atendidos e a mensagem P1 será enviada ao OA Switchboard ao publicar a submissão."
msgstr "OA Switchboard: os requisitos foram atendidos e a mensagem P1 será enviada ao OA Switchboard ao publicar a submissão."

msgid "plugins.generic.OASwitchboard.workflowTab.label"
msgstr "OA Switchboard"

msgid "plugins.generic.OASwitchboard.workflowTab.title"
msgstr "Situação do envio da mensagem para o OA Switchboard"
13 changes: 13 additions & 0 deletions templates/submissionStatus.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h2>{translate key="plugins.generic.OASwitchboard.workflowTab.title"}</h2>

{if $pluginIsNotConfiguredInfo}
{$pluginIsNotConfiguredInfo}
{else}
{if $submissionIsAlreadySendMessage}
{$submissionIsAlreadySendMessage}
{/if}

{if $submissionRequirementsIsPending}
{$submissionRequirementsIsPending}
{/if}
{/if}
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<version>
<application>OASwitchboard</application>
<type>plugins.generic</type>
<release>2.0.1.14</release>
<date>2024-11-04</date>
<release>2.0.1.15</release>
<date>2024-12-27</date>
</version>

0 comments on commit 0f25a3a

Please sign in to comment.